-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(backup): Fix query logic for dangling model exports
There are a small number of models that have no unambiguous direct connection to their relocation scope's root model - these are called "dangling" models. The key factor that defines them, and makes them difficult to handle, is that we cannot use our "query already exported foreign keys" filtering methodology to select only the models relevant to our export targets, because these models have no foreign keys that connect them back to the root of that target. For example, `TimeSeriesSnapshot` has no foreign keys at all, see: https://tinyurl.com/27z4x6tk. In cases like the one above, we ended up exporting ALL of the `TimeSeriesSnapshot`s in the database - clearly a very bad outcome when we only want to export those related to a specific org! A better approach is to define custom filtering logic for these models, thereby enabling them to use "adjacent" models in the model graph to select only models that we care about for a given export. In the example above, we query all `Incident`s filtered down by our previous exports to get a sneak-peek at the set of `IncidentSnapshot`s (a set that is currently empty due to going in reverse dependency order), then use that information to work backwards to grab the `TimeSeriesSnapshot`s we need. The upshot is that this commit introduces a generic method for constructing filtered queries for a specific model, the overridable `query_for_relocation_export`. Issue: getsentry/team-ospo#203
- Loading branch information
1 parent
288e0fd
commit a79ef11
Showing
13 changed files
with
357 additions
and
74 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.