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 misbehaviour of value_found in DBImpl::KeyMayExist. #12935

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rhubner
Copy link
Contributor

@rhubner rhubner commented Aug 14, 2024

KeyMayExist set value_found by default to true. Then if the value is not in cache, TTLDB returns false because it thinks the value vas found and then mark it as corrupted. False is returned even for values which are in TTLDB.

Fix #12921

@rhubner rhubner force-pushed the eb/key-exists-bug branch 2 times, most recently from 8bbe2bc to 61bba81 Compare August 14, 2024 10:58
Copy link
Contributor

@alanpaxton alanpaxton left a comment

Choose a reason for hiding this comment

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

LGTM - just my usual "can we add a test"..
Could you link to the ticket (Closes ...) in the description ?

// If block_cache is enabled and the index block of the table didn't
// not present in block_cache, the return value will be Status::Incomplete.
// In this case, key may still exist in the table.
if(value_found != nullptr && s.IsIncomplete()) {
if (value_found != nullptr && s.IsIncomplete()) {
// falsify later if key-may-exist but can't fetch value
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it feasible to make a test for this case ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alanpaxton I have test in Java, do yo think I should also write test in C++?

Copy link
Contributor

Choose a reason for hiding this comment

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

@rhubner I was unclear. I mean to say, can you test the case where keyMayExist but has_value is false ? I presume the functionality you have tested in Java already has C++ tests.
It is probably easier to have a C++ test for this case. My principle with the Java API is that we need to test going from Java to C++ and back. This is usually best achieved by having a Java test which basically mirrors the C++ test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alanpaxton Added test.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM thanks

@rhubner rhubner force-pushed the eb/key-exists-bug branch 2 times, most recently from 12373e1 to ee118c8 Compare August 29, 2024 08:17
@rhubner rhubner marked this pull request as ready for review August 30, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java keyExists() has an incorrect behaviour in most cases
3 participants