-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create jobs database tables without init container #4942
Conversation
0078452
to
50416ba
Compare
The assumptions sound reasonable to me. I did a quick skim of this and it looks good, I'll do a more in-depth review Monday. |
@tuliren why not also create the airbyte database and grant as part of the server start up? I'd prefer that since we might not be able to use the init script with Cloud Dbs (CloudSql doesn't support it, not sure about RDS) and it'll be nice if we don't need to add additional hooks/do manual work to spin things up. |
Mainly because to create a database, the user must be a superuser or have the Also the process can be complicated, because we need to first connect to the database server without specifying the database, create it, and then connect to the created database. (By the way, the grant statement is unnecessary. If the user can create a database, that user will become the owner of the database, and naturally have all the privileges on the database.) The new minimized init script is only needed for acceptance test. For CloudSQL, we don't need that. Since this is a database is a resource, I think terraform can take care of it. Is it not the case? I can still look into creating the database in Java if it is not an easy thing in terraform. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I double checked and looks like it's possible to create db tables in CloudSql via terraform. So should be ok. I also agree with ya those steps are too much trouble for what it's worth - we'll figure something else out.
I like the approach! It's much cleaner. My comments were around what I think are some missing schemas in DatabaseSchemas
and quite a bit of duplicated code in the setup of the XDatabaseInstances
classes. I think it's worth DRY-ing these since Cloud will have it's own tables and will be able to reuse some of this logic. Want to hear ya thoughts.
The new minimized init script is only needed for acceptance test.
Regarding this, looks like the init script is loaded in the airbyte-db pod, so is used outside of acceptance test when a prior DB isn't provided. Am I misunderstanding this?
...yte-scheduler/persistence/src/main/java/io/airbyte/scheduler/persistence/DatabaseSchema.java
Outdated
Show resolved
Hide resolved
airbyte-scheduler/persistence/src/main/resources/airbyte_jobs_table.sql
Outdated
Show resolved
Hide resolved
airbyte-db/src/main/java/io/airbyte/db/instance/JobsDatabaseInstance.java
Outdated
Show resolved
Hide resolved
airbyte-db/src/main/java/io/airbyte/db/instance/JobsDatabaseInstance.java
Outdated
Show resolved
Hide resolved
airbyte-db/src/main/java/io/airbyte/db/instance/ConfigsDatabaseInstance.java
Outdated
Show resolved
Hide resolved
airbyte-db/src/main/java/io/airbyte/db/instance/ConfigsDatabaseInstance.java
Outdated
Show resolved
Hide resolved
airbyte-db/src/main/java/io/airbyte/db/instance/JobsDatabaseInstance.java
Outdated
Show resolved
Hide resolved
airbyte-db/src/main/java/io/airbyte/db/instance/JobsDatabaseInstance.java
Outdated
Show resolved
Hide resolved
96de674
to
a0503dc
Compare
Oh, right. It is still used for acceptance test, or local deployment that uses internal database. For cloud deployment or any deployment that uses an external database, we don't need it. |
@davinchia, your comments are really helpful. I will tag you for another round of review once I finish the TODOs. |
Cool! Wanted to make sure I understood correctly. @tuliren I'm glad! I always feel like a tool when I bug people about DRY + code grouping, especially since you are so kind to pick this up. Happy to review a second time! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome! I really like how the BaseDatabaseInstance
class turned out.
airbyte-db/src/main/java/io/airbyte/db/instance/configs/ConfigsDatabaseInstance.java
Outdated
Show resolved
Hide resolved
airbyte-db/src/main/java/io/airbyte/db/instance/jobs/JobsDatabaseInstance.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Very fast turnaround!
When I tested the jobs importing and exporting locally, it looks like the For example, this is the metadata before the import:
If I import the same data, here is the metadata table after the import:
I don't think this bug is caused by this PR. Will look into it. |
What
How
JobsDatabaseInstance
takes in a jobs database connection, and prepares it by creating tables and indices if necessary.ConfigsDatabaseInstance
does the same for the configs database.airbyte
by default) exists in the db server.TODOs
DatabaseSchema
for more than just the jobs database.DatabaseSchema
for the configs database.DatabaseSchema
for the database instance classes.Recommended reading order
JobsDatabaseInstance.java
job_tables/schema.sql
: table schema for the jobs database to be executed in Java.init.sql
: new initialization sql script that just creates the database, and grant user permission.