-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
fix(hybrid-cloud): Cross-DB tombstone resubmission #69814
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #69814 +/- ##
==========================================
+ Coverage 79.14% 79.84% +0.70%
==========================================
Files 6486 6488 +2
Lines 288272 288414 +142
Branches 49667 49684 +17
==========================================
+ Hits 228139 230295 +2156
+ Misses 59731 57717 -2014
Partials 402 402
|
# @region_silo_test | ||
# class TestCrossDatabaseTombstoneCascadeBehavior(TestCase): | ||
# def assert_monitors_unchanged(self, unaffected_data: list[dict]): | ||
# for u_data in unaffected_data: | ||
# u_user, u_monitor = itemgetter("user", "monitor")(u_data) | ||
# queried_monitor = Monitor.objects.get(id=u_monitor.id) | ||
# # Validate that none of the existing user's monitors have been affected | ||
# assert u_monitor.owner_user_id is not None | ||
# assert u_monitor.owner_user_id == queried_monitor.owner_user_id | ||
# assert u_monitor.owner_user_id == u_user.id | ||
# | ||
# def assert_monitors_user_ids_null(self, monitors: list[Monitor]): | ||
# for monitor in monitors: | ||
# monitor.refresh_from_db() | ||
# assert monitor.owner_user_id is None | ||
# | ||
# def run_hybrid_cloud_fk_jobs(self): | ||
# with override_options({"hybrid_cloud.allow_cross_db_tombstones": True}): | ||
# with BurstTaskRunner() as burst: | ||
# schedule_hybrid_cloud_foreign_key_jobs() | ||
# | ||
# burst() | ||
# | ||
# def test_raises_when_option_disabled(self): | ||
# data = setup_cross_db_deletion_data() |
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.
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.
Instead of checking in commented out code which can be misinterpreted as a mistake, you could use pytest.mark.skip
to not run the tests but include them as well.
|
||
object_ids_to_check = fk_to_model_id_map.keys() | ||
tombstone_entries = tombstone_cls.objects.filter( | ||
object_identifier__in=object_ids_to_check |
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.
Do we need a table condition here?
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.
We do, adding this and another test for this as well 🤦🏼♂️
# @region_silo_test | ||
# class TestCrossDatabaseTombstoneCascadeBehavior(TestCase): | ||
# def assert_monitors_unchanged(self, unaffected_data: list[dict]): | ||
# for u_data in unaffected_data: | ||
# u_user, u_monitor = itemgetter("user", "monitor")(u_data) | ||
# queried_monitor = Monitor.objects.get(id=u_monitor.id) | ||
# # Validate that none of the existing user's monitors have been affected | ||
# assert u_monitor.owner_user_id is not None | ||
# assert u_monitor.owner_user_id == queried_monitor.owner_user_id | ||
# assert u_monitor.owner_user_id == u_user.id | ||
# | ||
# def assert_monitors_user_ids_null(self, monitors: list[Monitor]): | ||
# for monitor in monitors: | ||
# monitor.refresh_from_db() | ||
# assert monitor.owner_user_id is None | ||
# | ||
# def run_hybrid_cloud_fk_jobs(self): | ||
# with override_options({"hybrid_cloud.allow_cross_db_tombstones": True}): | ||
# with BurstTaskRunner() as burst: | ||
# schedule_hybrid_cloud_foreign_key_jobs() | ||
# | ||
# burst() | ||
# | ||
# def test_raises_when_option_disabled(self): | ||
# data = setup_cross_db_deletion_data() |
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.
Instead of checking in commented out code which can be misinterpreted as a mistake, you could use pytest.mark.skip
to not run the tests but include them as well.
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
Resubmission of PR #69480 with added support for row watermarking, which covers the case when a row is created after the relevant tombstone is already processed.
To make this behavior easier to test, I've split the convenience helper method that queries for model IDs requiring cascade changes into multiple new functions that can be tested individually.
This PR also adds commented tests that assert that this watermarking behavior is working as expected. Please pay attention to both the commented and uncommented test cases when reviewing.