Skip to content

Commit

Permalink
Enable persistent cache for rocksdb-cloud.
Browse files Browse the repository at this point in the history
Summary:
The persistent-cache is a lookaside cache that can be
used to store data from cloud storage on local disk.

Test Plan: Added unit test

Reviewers: hieu, haneeshr, kw, joe, igor

Reviewed By: hieu, igor

Subscribers: #platform

Differential Revision: https://rockset.phacility.com/D6378
  • Loading branch information
dhruba committed May 5, 2020
1 parent 32e77ec commit d82aa33
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cloud/cloud_storage_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ size_t CloudStorageReadableFileImpl::GetUniqueId(char* id,
WalFileType log_type;
ParseFileName(RemoveEpoch(basename(fname_)), &file_number, &file_type,
&log_type);
if (max_size < kMaxVarint64Length && file_number > 0) {
if (max_size >= kMaxVarint64Length && file_number > 0) {
char* rid = id;
rid = EncodeVarint64(rid, file_number);
return static_cast<size_t>(rid - id);
Expand Down
11 changes: 6 additions & 5 deletions cloud/db_cloud_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "rocksdb/status.h"
#include "rocksdb/table.h"
#include "util/xxhash.h"
#include "utilities/persistent_cache/block_cache_tier.h"

namespace rocksdb {

Expand Down Expand Up @@ -140,11 +141,11 @@ Status DBCloud::Open(const Options& opt, const std::string& local_dbname,
BlockBasedTableOptions* tableopt =
static_cast<BlockBasedTableOptions*>(bopt);
if (!tableopt->persistent_cache) {
std::shared_ptr<PersistentCache> pcache;
st =
NewPersistentCache(options.env, persistent_cache_path,
persistent_cache_size_gb * 1024L * 1024L * 1024L,
options.info_log, false, &pcache);
PersistentCacheConfig config(
local_env, persistent_cache_path,
persistent_cache_size_gb * 1024L * 1024L * 1024L, options.info_log);
auto pcache = std::make_shared<BlockCacheTier>(config);
st = pcache->Open();
if (st.ok()) {
tableopt->persistent_cache = pcache;
Log(InfoLogLevel::INFO_LEVEL, options.info_log,
Expand Down
2 changes: 0 additions & 2 deletions cloud/db_cloud_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,6 @@ TEST_F(CloudTest, CopyObjectTest) {
CloseDB();
}

#ifdef AWS_DO_NOT_RUN
//
// Verify that we can cache data from S3 in persistent cache.
//
Expand All @@ -1483,7 +1482,6 @@ TEST_F(CloudTest, PersistentCache) {
ASSERT_EQ(value, "World");
CloseDB();
}
#endif /* AWS_DO_NOT_RUN */

} // namespace rocksdb

Expand Down

0 comments on commit d82aa33

Please sign in to comment.