-
Notifications
You must be signed in to change notification settings - Fork 6.4k
[bugfix] compare key equality in blob file reader using user comparator instead of simply using equal sign #13457
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
base: main
Are you sure you want to change the base?
Conversation
…or instead simply using equal sign
Hi @lnparker! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@lnparker Would you be able to |
@lnparker has updated the pull request. You must reimport the pull request before landing. |
…thub.com:lnparker/rocksdb into fix-read-blob-corruption-using-custom-comparator
@lnparker has updated the pull request. You must reimport the pull request before landing. |
@jaykorean already done. thanks |
@bigfootjon has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
2 similar comments
@bigfootjon has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@bigfootjon has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@jaykorean has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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.
Blob verification exactly needs to do a byte by byte check. If you are doing user defined ttl with the example customer comparator, how ttl is encoded into a user key should be completely opaque to RocksDB and consistently followed through out all DB read/write invocations. All keys provided via DB::Write(key, value), DB::Get(key) should have its key format follow the expectation of the Comparator and the last 8 bytes being TTL. Otherwise, it will by design fail. Both record_slice.user_key and user_key are expected to have TTL already included in it and blob verification expect them to be exactly the same.
@jowlyzhang @jaykorean |
Get(key) is a point look up that is intended to look for the exact match. A range scan is needed in this case with the key without ttl part as prefix. That gets all versions of keys. Making a custom comparator to treat [userkey][timstamp:0] and [userkey][timestamp:now()+36000] as the same keys is a hack that would break RocksDB invariants, such as this blob verification. With that said, why not encode ttl into the value, as opposed to key so that point look up can work. It seems like you do not want to retain multiple versions of the same key with different timestamps. RocksDB's built-in ttl is doing similar thing to encode time into value: https://github.com/facebook/rocksdb/wiki/Time-to-Live |
With custom comparator which only compare part of user_key, record.key is always not equal to user_key
in BlobFileReader::VerifyBlob().
For example, user_key is always suffixed with ttl, and custom comparator without ttl like below would make record.key not equal to user_key.