Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
yapple committed Jul 5, 2022
1 parent 591fedf commit 82a1e6e
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,8 @@ rocksdbjavastaticreleasedocker: rocksdbjavastatic rocksdbjavastaticdockerx86_64

fterark:rocksdbjavastatic
cd java;jar -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md
cd java/target;jar -uf $(ROCKSDB_JAR_ALL) libterarkdbjni-*.so libterarkdbjni-*
cd java/target;jar -uf $(ROCKSDB_JAR_ALL) libterarkdbjni-*
#cd java/target;jar -uf $(ROCKSDB_JAR_ALL) libterarkdbjni-*.so libterarkdbjni-*
cd java/target/classes;jar -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class

# update apache license
Expand Down
11 changes: 8 additions & 3 deletions db/db_filesnapshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,14 @@ Status DBImpl::FakeFlush(std::vector<std::string>& ret) {
VersionEdit* edit = &iter->second;
autovector<MemTable*> mems;
cfd->imm()->PickMemtablesToFlush(nullptr,&mems);
for(auto& m: mems){
status = WriteLevel0TableForRecovery(job_id, cfd, m , edit);
if(!status.ok()) break;
if (!mems.empty()) {
cfd->imm()->RollbackMemtableFlush(mems, 0, status);
}
if (status.ok()) {
for (auto& m : mems) {
status = WriteLevel0TableForRecovery(job_id, cfd, m, edit);
if (!status.ok()) break;
}
}
if(status.ok()){
status = WriteLevel0TableForRecovery(job_id, cfd, cfd->mem(), edit);
Expand Down
57 changes: 57 additions & 0 deletions utilities/checkpoint/checkpoint_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,63 @@ class CheckpointTest : public testing::Test {
}
};

TEST_F(CheckpointTest, RepeatGetSnapshotLink) {
for (uint64_t log_size_for_flush : {0, 1000000}) {
Options options;
DB* snapshotDB;
ReadOptions roptions;
std::string result;
Checkpoint* checkpoint;

options = CurrentOptions();
delete db_;
db_ = nullptr;
ASSERT_OK(DestroyDB(dbname_, options));

// Create a database
Status s;
options.create_if_missing = true;
ASSERT_OK(DB::Open(options, dbname_, &db_));
std::string key = std::string("foo");
ASSERT_OK(Put(key, "v1"));
// Take a snapshot
for (int i = 0; i < 10; i++) {
ASSERT_OK(Checkpoint::Create(db_, &checkpoint));
std::string snap_shot = snapshot_name_;
snap_shot.push_back(('a' + i));
ASSERT_OK(checkpoint->CreateCheckpoint(snap_shot, log_size_for_flush));
ASSERT_OK(Put(key, "v2"));
ASSERT_EQ("v2", Get(key));
ASSERT_OK(Flush());
ASSERT_EQ("v2", Get(key));
// Open snapshot and verify contents while DB is running
options.create_if_missing = false;
ASSERT_OK(DB::Open(options, snap_shot, &snapshotDB));
ASSERT_OK(snapshotDB->Get(roptions, key, &result));
ASSERT_EQ("v1", result);
delete snapshotDB;
snapshotDB = nullptr;
}
delete db_;
db_ = nullptr;

// Destroy original DB
ASSERT_OK(DestroyDB(dbname_, options));

// Open snapshot and verify contents
options.create_if_missing = false;
dbname_ = snapshot_name_;
ASSERT_OK(DB::Open(options, dbname_, &db_));
ASSERT_EQ("v1", Get(key));
delete db_;
db_ = nullptr;
ASSERT_OK(DestroyDB(dbname_, options));
delete checkpoint;

// Restore DB name
dbname_ = test::PerThreadDBPath(env_, "db_test");
}
}
TEST_F(CheckpointTest, GetSnapshotLink) {
for (uint64_t log_size_for_flush : {0, 1000000}) {
Options options;
Expand Down

0 comments on commit 82a1e6e

Please sign in to comment.