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: Fix inconsistency when deleting dash entries #1734

Merged
merged 1 commit into from
Aug 24, 2023
Merged

fix: Fix inconsistency when deleting dash entries #1734

merged 1 commit into from
Aug 24, 2023

Conversation

romange
Copy link
Collaborator

@romange romange commented Aug 24, 2023

Partially addresses #1730.

Beforehand we removed entries from mcflag only inside DbSlice::Del function but we delete entries in other cases too (like expiration) and in this case we left dangling entries in mcflag table. The fix adds the deletion of mcflag entries into PerformDeletion function.

It by itself does not explain the crash but
dangling entries cause UB (because the keys are references to non-existent PrimeKeys) so maybe this somehow causes inconsistency where a key is not present in mcflags.

I am not sure I fixed the original issue but I surely fixed a corruption bug. In addition, I removed the redundant check fail and added error logs to follow up on this later.

Partially addresses #1730.

Beforehand we removed entries from mcflag only inside DbSlice::Del function
but we delete entries in other cases too (like expiration) and in this case we left
dangling entries in mcflag table. The fix adds the deletion of mcflag entries into PerformDeletion function.

It by itself does not explain the crash but
dangling entries cause UB (because the keys are references to non-existent PrimeKeys)
so maybe this somehow causes inconsistency where a key is not present in mcflags.

I am not sure I fixed the original issue but I surely fixed a corruption bug.
In addition, I removed the redundant check fail and added error logs to follow up on this later.

Signed-off-by: Roman Gershman <[email protected]>
@romange romange requested a review from kostasrim August 24, 2023 12:29
@@ -38,6 +38,13 @@ void PerformDeletion(PrimeIterator del_it, ExpireIterator exp_it, EngineShard* s
table->expire.Erase(exp_it);
}

if (del_it->second.HasFlag()) {
if (table->mcflag.Erase(del_it->first) == 0) {
LOG(ERROR) << "Internal error, inconsistent state, mcflag should be present but not found "
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this affect the rest of the execution of this function, but if this is an internal error, shouldn't we also return from this function and not continue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we try to delete it anyway. This internal error is not fatal, at least it does not seem so.

@@ -38,6 +38,13 @@ void PerformDeletion(PrimeIterator del_it, ExpireIterator exp_it, EngineShard* s
table->expire.Erase(exp_it);
}

if (del_it->second.HasFlag()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Small nit you can squash the two if's under one condition with &&. Not sure if this is imposed by our style guide or if this is purely a stylistic opinion. Ignore me if this is not useful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

specifically here I prefer to leave it as is :)

@romange romange merged commit e4ea868 into main Aug 24, 2023
@romange romange deleted the Pr3 branch August 24, 2023 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants