Make RateLimiter::GetTotalPendingRequest() non pure virtual for backward compability (#8938)
Summary: Context/Summary: https://github.com/facebook/rocksdb/pull/8890 added a public API `RateLimiter::GetTotalPendingRequest()` but mistakenly marked it as pure virtual, forcing RateLimiter's derived classes to implement this function and breaking backward compatibility. This PR makes `RateLimiter::GetTotalPendingRequest()` as non-pure virtual method by providing a trivial implementation in rate_limiter.h Pull Request resolved: https://github.com/facebook/rocksdb/pull/8938 Test Plan: Passing existing tests Reviewed By: pdillinger Differential Revision: D31100661 Pulled By: hx235 fbshipit-source-id: 06eff1005156a6e5a881e393b2c5b2ad706897d8
This commit is contained in:
parent
e74dfee7fc
commit
c92f7a29aa
@ -31,10 +31,10 @@
|
|||||||
* Added new callback APIs `OnBlobFileCreationStarted`,`OnBlobFileCreated`and `OnBlobFileDeleted` in `EventListener` class of listener.h. It notifies listeners during creation/deletion of individual blob files in Integrated BlobDB. It also log blob file creation finished event and deletion event in LOG file.
|
* Added new callback APIs `OnBlobFileCreationStarted`,`OnBlobFileCreated`and `OnBlobFileDeleted` in `EventListener` class of listener.h. It notifies listeners during creation/deletion of individual blob files in Integrated BlobDB. It also log blob file creation finished event and deletion event in LOG file.
|
||||||
* Batch blob read requests for `DB::MultiGet` using `MultiRead`.
|
* Batch blob read requests for `DB::MultiGet` using `MultiRead`.
|
||||||
* Add support for fallback to local compaction, the user can return `CompactionServiceJobStatus::kUseLocal` to instruct RocksDB to run the compaction locally instead of waiting for the remote compaction result.
|
* Add support for fallback to local compaction, the user can return `CompactionServiceJobStatus::kUseLocal` to instruct RocksDB to run the compaction locally instead of waiting for the remote compaction result.
|
||||||
|
* Add built-in rate limiter's implementation for `RateLimiter::GetTotalPendingRequests()` for the total number of requests that are pending for bytes in the rate limiter.
|
||||||
|
|
||||||
### Public API change
|
### Public API change
|
||||||
* Remove obsolete implementation details FullKey and ParseFullKey from public API
|
* Remove obsolete implementation details FullKey and ParseFullKey from public API
|
||||||
* Add a public API RateLimiter::GetTotalPendingRequests() for the total number of requests that are pending for bytes in the rate limiter.
|
|
||||||
* Change `SstFileMetaData::size` from `size_t` to `uint64_t`.
|
* Change `SstFileMetaData::size` from `size_t` to `uint64_t`.
|
||||||
* Made Statistics extend the Customizable class and added a CreateFromString method. Implementations of Statistics need to be registered with the ObjectRegistry and to implement a Name() method in order to be created via this method.
|
* Made Statistics extend the Customizable class and added a CreateFromString method. Implementations of Statistics need to be registered with the ObjectRegistry and to implement a Name() method in order to be created via this method.
|
||||||
* Extended `FlushJobInfo` and `CompactionJobInfo` in listener.h to provide information about the blob files generated by a flush/compaction and garbage collected during compaction in Integrated BlobDB. Added struct members `blob_file_addition_infos` and `blob_file_garbage_infos` that contain this information.
|
* Extended `FlushJobInfo` and `CompactionJobInfo` in listener.h to provide information about the blob files generated by a flush/compaction and garbage collected during compaction in Integrated BlobDB. Added struct members `blob_file_addition_infos` and `blob_file_garbage_infos` that contain this information.
|
||||||
|
@ -3937,6 +3937,56 @@ TEST_F(DBTest, DISABLED_RateLimitingTest) {
|
|||||||
ASSERT_LT(ratio, 0.6);
|
ASSERT_LT(ratio, 0.6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a mocked customed rate limiter without implementing optional APIs
|
||||||
|
// (e.g, RateLimiter::GetTotalPendingRequests())
|
||||||
|
class MockedRateLimiterWithNoOptionalAPIImpl : public RateLimiter {
|
||||||
|
public:
|
||||||
|
MockedRateLimiterWithNoOptionalAPIImpl() {}
|
||||||
|
|
||||||
|
~MockedRateLimiterWithNoOptionalAPIImpl() override {}
|
||||||
|
|
||||||
|
void SetBytesPerSecond(int64_t bytes_per_second) override {
|
||||||
|
(void)bytes_per_second;
|
||||||
|
}
|
||||||
|
|
||||||
|
using RateLimiter::Request;
|
||||||
|
void Request(const int64_t bytes, const Env::IOPriority pri,
|
||||||
|
Statistics* stats) override {
|
||||||
|
(void)bytes;
|
||||||
|
(void)pri;
|
||||||
|
(void)stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t GetSingleBurstBytes() const override { return 200; }
|
||||||
|
|
||||||
|
int64_t GetTotalBytesThrough(
|
||||||
|
const Env::IOPriority pri = Env::IO_TOTAL) const override {
|
||||||
|
(void)pri;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t GetTotalRequests(
|
||||||
|
const Env::IOPriority pri = Env::IO_TOTAL) const override {
|
||||||
|
(void)pri;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t GetBytesPerSecond() const override { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
// To test that customed rate limiter not implementing optional APIs (e.g,
|
||||||
|
// RateLimiter::GetTotalPendingRequests()) works fine with RocksDB basic
|
||||||
|
// operations (e.g, Put, Get, Flush)
|
||||||
|
TEST_F(DBTest, CustomedRateLimiterWithNoOptionalAPIImplTest) {
|
||||||
|
Options options = CurrentOptions();
|
||||||
|
options.rate_limiter.reset(new MockedRateLimiterWithNoOptionalAPIImpl());
|
||||||
|
DestroyAndReopen(options);
|
||||||
|
ASSERT_OK(Put("abc", "def"));
|
||||||
|
ASSERT_EQ(Get("abc"), "def");
|
||||||
|
ASSERT_OK(Flush());
|
||||||
|
ASSERT_EQ(Get("abc"), "def");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(DBTest, TableOptionsSanitizeTest) {
|
TEST_F(DBTest, TableOptionsSanitizeTest) {
|
||||||
Options options = CurrentOptions();
|
Options options = CurrentOptions();
|
||||||
options.create_if_missing = true;
|
options.create_if_missing = true;
|
||||||
|
@ -90,8 +90,15 @@ class RateLimiter {
|
|||||||
const Env::IOPriority pri = Env::IO_TOTAL) const = 0;
|
const Env::IOPriority pri = Env::IO_TOTAL) const = 0;
|
||||||
|
|
||||||
// Total # of requests that are pending for bytes in rate limiter
|
// Total # of requests that are pending for bytes in rate limiter
|
||||||
|
// For convenience, this function is implemented by the RateLimiter returned
|
||||||
|
// by NewGenericRateLimiter but is not required by RocksDB. The default
|
||||||
|
// implementation indicates "not supported".
|
||||||
virtual int64_t GetTotalPendingRequests(
|
virtual int64_t GetTotalPendingRequests(
|
||||||
const Env::IOPriority pri = Env::IO_TOTAL) const = 0;
|
const Env::IOPriority pri = Env::IO_TOTAL) const {
|
||||||
|
assert(false);
|
||||||
|
(void)pri;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
virtual int64_t GetBytesPerSecond() const = 0;
|
virtual int64_t GetBytesPerSecond() const = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user