-
Notifications
You must be signed in to change notification settings - Fork 81
ENG-663: add StagedResourceAncestors
table and remove child_diff_statuses
#6185
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
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6185 +/- ##
==========================================
+ Coverage 87.07% 87.11% +0.03%
==========================================
Files 423 424 +1
Lines 26321 26356 +35
Branches 2870 2872 +2
==========================================
+ Hits 22920 22960 +40
+ Misses 2776 2769 -7
- Partials 625 627 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
||
ancestor_links: RelationshipProperty[List[StagedResourceAncestor]] = relationship( | ||
"StagedResourceAncestor", | ||
back_populates="descendant_staged_resource", |
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.
Shouldn't this be ancestor_staged_resource
and in relation descendant_links
be descendant_staged_resource
? Sorry, my head is exploding a little thinking about ancestors and descendants 🤯
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.
hmm, my head is exploding a bit too now...let me double check on this, thanks for calling it out. at a minimum it deserves a code comment
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.
still need to circle back to this, but since tests that evaluate the relationships are passing, i'm going to leave these as-is 👍
src/fides/api/alembic/migrations/versions/bf713b5a021d_staged_resource_ancestor_link_data_.py
Show resolved
Hide resolved
src/fides/api/alembic/migrations/versions/bf713b5a021d_staged_resource_ancestor_link_data_.py
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.
Great work!
fides
|
Project |
fides
|
Branch Review |
main
|
Run status |
|
Run duration | 00m 52s |
Commit |
|
Committer | Adam Sachs |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
0
|
|
0
|
|
0
|
|
5
|
View all changes introduced in this branch ↗︎ |
Supports https://github.com/ethyca/fidesplus/pull/2201
Description Of Changes
DB model updates to support computing
child_diff_statuses
at query time, not tracking it in DB.Also moves our
post_upgrade_index_creation
utility to be kicked off as part of fides server startup, rather than as a standalone script executed outside of app runtime. This is so that we don't have to manually execute the script from a location with app DB access, against all tenants/clients that need the indexes created; instead, it happens automatically when the server boots up.This PR contains a data migration which can take a long time (>5 minutes) to run on environments with many (>500k)
stagedresource
records. App health checks should be adjusted in environments where this is anticipated, in order to avoid crash loops on upgrade.The data migration can also be memory intensive in these cases (~2GB utilized locally on a case with 1.5 million
stagedresource
records), so memory allocation should be adjusted accordingly for the duration of the migration.Code Changes
post_upgrade_index_creation
utility to be executed as a non-blocking operation kicked off on on server startupchild_diff_statuses
fromStagedResource
DB modeldiff_status
inStagedResource
tableStagedResourceAncestor
junction table to be used for efficiently calculatingchild_diff_statuses
at query timestagedresourceancestor
table (2) populate that table with data, based on existingstagedresource
records and their hierarchical relationships, then add indexes and constraints to that table (3) remove thestagedresource.child_diff_statuses
column (this is done after (2) so that we don't remove this column until (2) completes successfully)stagedresourceancestor
records are created as part of the migration, to avoid long-running operations during the migration execution, which will prevent the server from starting up quickly. Instead, an INFO message is logged, and the"post upgrade creation" utility handles creation of the index.
Steps to Confirm
initial migration:
post upgrade index creation:
Pre-Merge Checklist
CHANGELOG.md
updatedmain
downgrade()
migration is correct and works