-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Fail DB::Open if hashing features enabled with incompatible Comparator #10293
base: main
Are you sure you want to change the base?
Conversation
Summary: RocksDB allows Comparators to treat keys with different byte contents as equal, if that's appropriate for the application, but that makes the comparator incompatible with a number of hashing-based features that assume equal keys generate the same hash. Before now, the only protection against getting wrong results with such incompatible combinations is quietly disabling data block hash index if the Comparator returns true for `CanKeysWithDifferentByteContentsBeEqual()`. This change attempts to detect all the cases in which RocksDB can produce wrong results with such a Comparator and fail DB::Open with an appropriate status. (More nuiance in HISTORY entry.) Also included: * ... Test Plan: substantially updated unit tests
@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@pdillinger has updated the pull request. You must reimport the pull request before landing. |
@pdillinger has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@pdillinger note that the added checks make the check in the Also, a possible issue is that with the added checks, Java code that calls |
@pdillinger has updated the pull request. You must reimport the pull request before landing. |
int (*compare_ts_)(void*, const char* a_ts, size_t a_tslen, const char* b_ts, | ||
size_t b_tslen); | ||
int (*compare_without_ts_)(void*, const char* a, size_t alen, | ||
unsigned char a_has_ts, const char* b, size_t blen, | ||
unsigned char b_has_ts); | ||
const char* name_; | ||
unsigned char ckwdbcbe_; |
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.
Can we replace this with the full name?
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.
The full name on snake case is really really long. It's easy to see what it means with code navigation
{ | ||
Status s = TryReopen(new_options); | ||
if (expect_open_failure) { | ||
ASSERT_NOK(s); |
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.
Should we at least assert the NOK status is InvalidArg to prevent false positive?
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.
Can do that
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.
Thanks for a very helpful PR summary! Mostly LGTM with minor comments!
Before approving, just want to double check with the author on any thoughts about how this might affect internal users (https://github.com/facebook/rocksdb/pull/10293/files?show-viewed-files=true&file-filters%5B%5D=#r922044847) - we can chat more internally offline.
Thanks!
@pdillinger has updated the pull request. You must reimport the pull request before landing. |
@pdillinger has updated the pull request. You must reimport the pull request before landing. |
1 similar comment
@pdillinger has updated the pull request. You must reimport the pull request before landing. |
I'm considering putting this on hold because
|
Correction: only if they are provided as Seek key |
The Comparator mentions providing ordering for slices "used as keys in an sstable or a database". Should |
Summary: RocksDB allows Comparators to treat keys with different byte
contents as equal, if that's appropriate for the application, but that
makes the comparator incompatible with a number of hashing-based
features that assume equal keys generate the same hash. Before now, the
only protection against getting wrong results with such incompatible
combinations is quietly disabling data block hash index if the
Comparator returns true for
CanKeysWithDifferentByteContentsBeEqual()
.This change attempts to detect all the cases in which RocksDB can
produce wrong results with such a Comparator and fail DB::Open with an
appropriate status. (More nuiance in HISTORY entry.) Many of the cases
were found by expanding the unit test and seeing what fails in data
correctness.
Also included:
CanKeysWithDifferentByteContentsBeEqual()
for most of thetesting comparators, as appropriate. (Didn't find any "bad configuration"
cases in unit tests.)
and move
name
to be achar*
rather than a function pointer to afunction returning
char*
. (What would be the reason for that complexity?)an existing configuration. (Now
kVectorRepAndMemtableBloom
)ReverseBytewiseComparator
ReverseBytewiseComparator
but actually quite different.Related to #10256
Test Plan: substantially updated unit tests