Skip to content
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

Copy job attempt state to configs database #7219

Merged
merged 24 commits into from
Oct 26, 2021

Conversation

tuliren
Copy link
Contributor

@tuliren tuliren commented Oct 20, 2021

@github-actions github-actions bot added area/core area/worker Related to worker labels Oct 20, 2021
@@ -22,6 +22,12 @@ create table "public"."airbyte_configs_migrations"(
constraint "airbyte_configs_migrations_pk"
primary key ("installed_rank")
);
create table "public"."sync_state"(
"sync_id" uuid not null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably also want to keep the connection_id there. Not even sure you want the sync id actually

I can see the job database being purged but you still want to know what is the latest state for a connection.

Copy link
Contributor Author

@tuliren tuliren Oct 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sync_id is the connection_id. The reason I name it sync_id is that the connectionId is the primary key for a StandardSync. I imagine that in the future when we implement the project to normalize the tables, the primary key of the Sync table (removing the Standard- prefix) will just be id, not connectionId. So sync_id will be consistent with that future schema.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't a StandardSync eventually become a Connection and then this would become ConnectionState with a connection_id?

"Sync" / "StandardSync" feel out of place with the UI/how we usually talk about this. I would think that a "Sync" is more of a "Job" today than the connection itself.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with jared :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I synced with Charles on this. For now we are just going to persist the state in the airbyte_configs table as a json blob. To not cause confusion, the new type is STANDARD_SYNC_STATE. When we normalize this table, we can change the name sync to connection.

@cgardens cgardens added area/platform issues related to the platform and removed area/core labels Oct 23, 2021
@tuliren tuliren temporarily deployed to more-secrets October 24, 2021 16:21 Inactive
@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 13:02 Inactive
@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 13:50 Inactive
@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 14:16 Inactive
@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 15:16 Inactive
@tuliren tuliren force-pushed the liren/copy-job-attempt-state-take-2 branch from b2872dc to aa20d11 Compare October 25, 2021 17:24
@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 17:25 Inactive
@tuliren tuliren force-pushed the liren/copy-job-attempt-state-take-2 branch from f781684 to 3198ed4 Compare October 25, 2021 17:27
@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 17:29 Inactive
@tuliren tuliren force-pushed the liren/copy-job-attempt-state-take-2 branch from 3198ed4 to 1f24699 Compare October 25, 2021 17:31
@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 17:33 Inactive
@tuliren tuliren requested a review from cgardens October 25, 2021 18:02
Copy link
Contributor

@cgardens cgardens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

// state schema: State.yaml, e.g. { "state": { "cursor": 1000 } }
final Field<JSONB> attemptState = DSL.field("attempts.output -> 'sync' -> 'state'", SQLDataType.JSONB);

return jobsDatabase.query(ctx -> ctx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! i like this query.

@tuliren
Copy link
Contributor Author

tuliren commented Oct 25, 2021

Cannot merge this yet. There is a fatal flaw resulting in lost state. Glad that we have an acceptance test that catches this bug. But also scary that this issue is only caught by one test. I think I have located the root cause, but need more tests.

@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 22:04 Inactive
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Oct 25, 2021
@tuliren
Copy link
Contributor Author

tuliren commented Oct 25, 2021

Alright, it should be more robust now with the new unit tests.

@tuliren tuliren temporarily deployed to more-secrets October 25, 2021 22:50 Inactive
@tuliren tuliren merged commit 779c39c into master Oct 26, 2021
@tuliren tuliren deleted the liren/copy-job-attempt-state-take-2 branch October 26, 2021 00:08
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
* Add migration to create latest state table

* Log migration name

* Expose db variables to airbyte-db

* Implement migration

* Fix migration test

* temp

* Rebase on master

* Save state in temporal (airbytehq#7253)

* Copy state to airbyte_configs table

* Add standard sync state

* Move state methods to config repository

* Add unit tests

* Fix unit tests

* Register standard sync state in migration

* Add comment

* Use config model instead of json node

* Add comments

* Remove unnecessary method

* Fix migration query

* Remove unused config database

* Move persist statement and log the call

* Update dev doc

* Add unit tests for sync workflow

Co-authored-by: Charles <giardina.charles@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation area/platform issues related to the platform area/scheduler area/server area/worker Related to worker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update config and job persistence unit tests to run migrations Move state from jobs db to configs db
4 participants