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

fix(database): use datasource's environment as database's environment to prevent data inconsistency #659

Merged
merged 3 commits into from
Oct 31, 2023

Conversation

MarkPotato777
Copy link
Collaborator

@MarkPotato777 MarkPotato777 commented Oct 30, 2023

What type of PR is this?

type-bug

What this PR does / why we need it:

Both connect_connection and connect_database maintain the environemnt_id which may cause data inconsistencies.
For example, the migration of the environment_id in the connect_connection table occurs during the TeamOrganizationMigrator process, which is triggered when the first user of the current organization logs in. On the other hand, the synchronization of connect_database is triggered by a scheduled task. If syncDatabase happens before TeamOrganizationMigrator, then the value of connect_database.environment_id will be -1.

The solution is that we no longer rely on the environment_id of the connect_database, but set the environment of the database to the environment of the data source in the conversion layer of entity to model. Considering compatibility, we do not change any schema or migrate any data here, and the caller of the DatabaseService doesn't need to care about this change, because all changes happen in-ground.

Which issue(s) this PR fixes:

Fixes #575

Special notes for your reviewer:

Additional documentation e.g., usage docs, etc.:


@MarkPotato777 MarkPotato777 added the type-bug Something isn't working label Oct 30, 2023
@MarkPotato777 MarkPotato777 added this to the ODC 4.2.2 milestone Oct 30, 2023
@MarkPotato777 MarkPotato777 self-assigned this Oct 30, 2023
@oceanbase oceanbase deleted a comment from yizhouxw Oct 31, 2023
Copy link
Contributor

@yizhouxw yizhouxw left a comment

Choose a reason for hiding this comment

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

lgtm

@yhilmare yhilmare merged commit 36de77d into dev/4.2.2 Oct 31, 2023
19 checks passed
@yhilmare yhilmare deleted the lebie_422_fix_datasource_1030 branch October 31, 2023 07:18
yhilmare pushed a commit that referenced this pull request Jan 15, 2024
… to prevent data inconsistency (#659)

* ignore connect_database.id

* fix conflict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants