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 a issue with initializing blob header buffer #8537

Closed
wants to merge 3 commits into from

Conversation

zaorangyang
Copy link
Contributor

No description provided.

@zaorangyang zaorangyang changed the title Fix a issue with initializing a buffer Fix a issue with initializing blob header buffer Jul 15, 2021
@siying siying requested a review from ltamasi July 15, 2021 19:08
@@ -69,7 +71,8 @@ class BlobLogSequentialReader {
Statistics* statistics_;

Slice buffer_;
char header_buf_[BlobLogRecord::kHeaderSize];
char header_buf_[MAX_HEADER_SIZE(BlobLogHeader::kSize, BlobLogFooter::kSize,
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically, BlobLogRecord::kHeaderSize is large enough to cover all three, see also the static_asserts here:

https://github.com/facebook/rocksdb/blob/master/db/blob/blob_log_sequential_reader.cc#L48-L49
https://github.com/facebook/rocksdb/blob/master/db/blob/blob_log_sequential_reader.cc#L67-L68
https://github.com/facebook/rocksdb/blob/master/db/blob/blob_log_sequential_reader.cc#L117-L118

Having said that, I think this is a good change from a theoretical standpoint.

@@ -10,6 +10,8 @@
#include "db/blob/blob_log_format.h"
#include "rocksdb/slice.h"

#define MAX_HEADER_SIZE(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to use std::max here but it is unfortunately constexpr only since C++14.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you #undef the macro near the bottom of the file just in 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.

Done :)

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@zaorangyang has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@jay-zhuang merged this pull request in 8e91bd9.

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.

5 participants