-
Notifications
You must be signed in to change notification settings - Fork 40
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
[nexus] Delete "inv_dataset" records from inventory collections #6632
Conversation
@@ -1241,6 +1242,17 @@ impl DataStore { | |||
.await? | |||
}; | |||
|
|||
// Remove rows for datasets | |||
let ndatasets = |
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.
This is the portion of the PR that actually fixes the underlying issue
@@ -2731,6 +2746,12 @@ mod test { | |||
.await | |||
.unwrap(); | |||
assert_eq!(0, count); | |||
let count = schema::inv_dataset::dsl::inv_dataset |
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.
This is the portion of the test where I should have looked for the inv_dataset being gone
/// NOTE: This test depends on the naming convention "inv_" prefix name | ||
/// to identify pieces of the inventory. | ||
#[tokio::test] | ||
async fn test_inventory_deletion() { |
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.
This is a new test I added, out of paranoia, to try to help catch future cases like this, if any "inv_..." tables are added in the future, and they are not deleted.
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.
This might fix #5305
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.
Yeah, it's not exactly a database snapshot, but querying for all present and future inv_
tables is an approximation
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.
Yeah the ticket isn't so much about that specific implementation so much as having a test to catch this problem.
I can't think of why you'd need a snapshot. A possible risk is that another inventory collection is inserted by a background task in the meantime, but since this is a datastore test and not an app-level test, there's no Nexus, and so that should be impossible.
Do you think we should have a test for the representative collection that it has rows for all inv_*
tables? I'm a little afraid this test won't catch this problem in the future because someone might forget to add it to that, too. (It wouldn't have caught this specific instance for that reason, right?)
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.
I'm gonna merge this PR first, but yes, totally agreed, we should have a test for that. I'll file another issue.
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.
@@ -321,8 +321,19 @@ pub fn representative() -> Representative { | |||
slot: 3, | |||
}, | |||
]; | |||
let zpools = vec![]; | |||
let datasets = vec![]; | |||
let zpools = vec![InventoryZpool { |
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.
This was another oversight, I really should have added both of these to the representative inventory.
In the future, if anything is added to this representative inventory, but not deleted, the test_inventory_deletion
test should now help catch it.
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.
LGTM. I'm on board with declaring #5305 fixed with this; it's by convention, but it's a pretty strong convention at this point.
Fixes #6615
Does not patch existing systems (dogfood) which may have unnecessary inventory entries