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 BlobDB::Get which only get out the value offset #2553

Closed
wants to merge 2 commits into from

Conversation

foolenough
Copy link
Contributor

Blob db use StackableDB::get which only get out the
value offset, but not the value.
Fix by making BlobDB::Get override the designated getter.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up 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 the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@sagar0 sagar0 requested a review from yiwu-arbug July 10, 2017 19:17
@yiwu-arbug
Copy link
Contributor

@foolenough Thank you for the fix! Do you mind signing the CLA?

@foolenough
Copy link
Contributor Author

@yiwu-arbug I've signed the CLA now. Thanks for your review.

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@yiwu-arbug
Copy link
Contributor

@foolenough Thanks. Actually I don't quite understand the fix. It seems that we forget to update BlobDB::Get with PinnableSlice, but how does it cause blob db return offset rather than value? And it doesn't seems to be caught by blob_db_test.

@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@foolenough
Copy link
Contributor Author

foolenough commented Jul 11, 2017

@yiwu-arbug There are three version of Get method in db.h

// db.h
virtual inline Status Get(const ReadOptions& options,
                           ColumnFamilyHandle* column_family, const Slice& key,
                           std::string* value) {
   assert(value != nullptr);
   PinnableSlice pinnable_val(value);
   assert(!pinnable_val.IsPinned());
   auto s = Get(options, column_family, key, &pinnable_val);
   if (s.ok() && pinnable_val.IsPinned()) {
     value->assign(pinnable_val.data(), pinnable_val.size());
   }  // else value is already assigned
   return s;
 }
 virtual Status Get(const ReadOptions& options,
                    ColumnFamilyHandle* column_family, const Slice& key,
                    PinnableSlice* value) = 0;
 virtual Status Get(const ReadOptions& options, const Slice& key, std::string* value) {
   return Get(options, DefaultColumnFamily(), key, value);
 }

The StackableDB override the designated getter of DB correctly.

// Stackable
using DB::Get;
  virtual Status Get(const ReadOptions& options,
                     ColumnFamilyHandle* column_family, const Slice& key,
                     PinnableSlice* value) override {
    return db_->Get(options, column_family, key, value);
  }

But the BlobDB::Get override the wrong version of getter.

// blob_db.h
virtual Status Get(const ReadOptions& options,
                 ColumnFamilyHandle* column_family, const Slice& key,
                 std::string* value)

Thus the Get(const ReadOptions& options, ColumnFamilyHandle* column_family, const Slice& key, PinnableSlice* value) is not overrided, and it would call the StackableDB::Get, which just return the value offset but not the actual value.

The blob_db_test calls blobdb->Get(const ReadOptions& options, ColumnFamilyHandle* column_family, const Slice& key, std::string* value), which is correctly override. But this method is not the designated getter, the getter methods is not consistent with each other.

When run benchmark with db_bench readrandom -use_blob_db, which use PinnableSlice version getter, the result is wrongly too high, as it doesn't fetch the value in blob file.

@facebook-github-bot
Copy link
Contributor

@foolenough updated the pull request - view changes - changes since last import

@yiwu-arbug
Copy link
Contributor

I see. Do you mind adding a test to blob_db_test, which wrap BlobDB with a StackableDB and verify return value of StackableDB::Get is correct?

@yiwu-arbug
Copy link
Contributor

BTW are you trying to use blob db? The feature is not ready yet. There are bug fixing ongoing.

@facebook-github-bot
Copy link
Contributor

@foolenough updated the pull request - view changes - changes since last import

The verifyDB method in BlobDBTest uses only one version of
BlobDB::Get.
Add test case in blob_db_test to test all Get methods.
Blob db use StackableDB::get which only get out the
value offset, but not the value.
Fix by making BlobDB::Get override the designated getter.
@facebook-github-bot
Copy link
Contributor

@foolenough updated the pull request - view changes - changes since last import

@foolenough
Copy link
Contributor Author

@yiwu-arbug I've added the test case which would fail without the fix patch.

I am currently benchmarking the blob db, and want to add a config option like Use_BlobDB_Value_Size. When the value size is large than the configure value, the value
is stored in blob file. And when the value size is small, it is store in LSM tree.
This may help improve performance in some cases. Is there any advice for this opinion?

What's your mean about NOT ready? How long would it take to use blob db in production?

@facebook-github-bot
Copy link
Contributor

@yiwu-arbug has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@yiwu-arbug
Copy link
Contributor

@foolenough Appreciate the fix. There a crashes we see in our shadow test need to fix, and I'm still investigating it. No ETA for production yet. Where do you plan to use blob db?

To me, option to store value in LSM is something blob db should have. How do you plan to implement it? We have a placeholder here which is unimplemented :/
https://github.com/facebook/rocksdb/blob/master/utilities/blob_db/blob_db.h#L55-L57

yiwu-arbug pushed a commit that referenced this pull request Jul 18, 2017
Summary:
Blob db use StackableDB::get which only get out the
value offset, but not the value.
Fix by making BlobDB::Get override the designated getter.
Closes #2553

Differential Revision: D5396823

Pulled By: yiwu-arbug

fbshipit-source-id: 5a7d1cf77ee44490f836a6537225955382296878
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.

None yet

3 participants