From e446bc65e647f86feb8c2784a2ba473832ccd80e Mon Sep 17 00:00:00 2001 From: Burton Li Date: Fri, 5 Aug 2022 23:03:51 -0700 Subject: [PATCH] Remove local static string (#8103) Summary: Local static string is not friendly to Jemalloc arena aware implementation, as it will be allocated on the arena of the first caller, which causes crash if the allocated arena gets refunded earlier. P.S. A Jemalloc arena aware implementation is each rocksdb instance only use certain Jemalloc arenas, and arena will be refunded after associated DB instance is destroyed. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8103 Reviewed By: ajkr Differential Revision: D38477235 Pulled By: ltamasi fbshipit-source-id: a58d32cb647ed64c144b4736fb2d5db27c2c28f9 --- db/blob/blob_index.h | 2 +- db/blob/blob_log_format.cc | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/db/blob/blob_index.h b/db/blob/blob_index.h index 67535472c..e9944d784 100644 --- a/db/blob/blob_index.h +++ b/db/blob/blob_index.h @@ -92,7 +92,7 @@ class BlobIndex { } Status DecodeFrom(Slice slice) { - static const std::string kErrorMessage = "Error while decoding blob index"; + const char* kErrorMessage = "Error while decoding blob index"; assert(slice.size() > 0); type_ = static_cast(*slice.data()); if (type_ >= Type::kUnknown) { diff --git a/db/blob/blob_log_format.cc b/db/blob/blob_log_format.cc index 482bd078e..8e26281e3 100644 --- a/db/blob/blob_log_format.cc +++ b/db/blob/blob_log_format.cc @@ -26,8 +26,7 @@ void BlobLogHeader::EncodeTo(std::string* dst) { } Status BlobLogHeader::DecodeFrom(Slice src) { - static const std::string kErrorMessage = - "Error while decoding blob log header"; + const char* kErrorMessage = "Error while decoding blob log header"; if (src.size() != BlobLogHeader::kSize) { return Status::Corruption(kErrorMessage, "Unexpected blob file header size"); @@ -71,8 +70,7 @@ void BlobLogFooter::EncodeTo(std::string* dst) { } Status BlobLogFooter::DecodeFrom(Slice src) { - static const std::string kErrorMessage = - "Error while decoding blob log footer"; + const char* kErrorMessage = "Error while decoding blob log footer"; if (src.size() != BlobLogFooter::kSize) { return Status::Corruption(kErrorMessage, "Unexpected blob file footer size"); @@ -112,7 +110,7 @@ void BlobLogRecord::EncodeHeaderTo(std::string* dst) { } Status BlobLogRecord::DecodeHeaderFrom(Slice src) { - static const std::string kErrorMessage = "Error while decoding blob record"; + const char* kErrorMessage = "Error while decoding blob record"; if (src.size() != BlobLogRecord::kHeaderSize) { return Status::Corruption(kErrorMessage, "Unexpected blob record header size");