Skip to content

Commit 9b24667

Browse files
authored
Merge pull request #5 from XiaoMi/qinzuoyan
not return NoNeedOperate in FlushMemTable() & copy options file in CreateCheckpointQuick()
2 parents 85770cb + 5372db0 commit 9b24667

8 files changed

+13
-25
lines changed

db/db_compaction_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ TEST_P(DBCompactionTestWithParam, ConvertCompactionStyle) {
19461946
ASSERT_OK(Put(Key(i), RandomString(&rnd, 10000)));
19471947
}
19481948
dbfull()->Flush(FlushOptions());
1949-
ASSERT_TRUE(Flush().IsNoNeedOperate());
1949+
ASSERT_OK(Flush(1));
19501950
dbfull()->TEST_WaitForCompact();
19511951

19521952
for (int i = 1; i < options.num_levels; i++) {

db/db_filesnapshot.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,15 @@ Status DBImpl::GetLiveFilesQuick(std::vector<std::string>& ret,
177177
}
178178

179179
ret.clear();
180-
ret.reserve(live.size() + 2); //*.sst + CURRENT + MANIFEST
180+
ret.reserve(live.size() + 3); //*.sst + CURRENT + MANIFEST + OPTIONS
181181

182182
// Put current and manifest files firstly to make them copied quickly,
183183
// because the manifest file may be deleted when copying sstables.
184+
// TODO(qinzuoyan): but now it may be not necessary because the manifest file
185+
// must not be deleted when copying sstables..
184186
ret.push_back(CurrentFileName(""));
185187
ret.push_back(DescriptorFileName("", versions_->manifest_file_number()));
188+
ret.push_back(OptionsFileName("", versions_->options_file_number()));
186189

187190
// create names of the live files. The names are not absolute
188191
// paths, instead they are relative to dbname_;

db/db_impl_compaction_flush.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ Status DBImpl::CompactRange(const CompactRangeOptions& options,
288288
bool exclusive = options.exclusive_manual_compaction;
289289

290290
Status s = FlushMemTable(cfd, FlushOptions());
291-
// NOTE: FlushMemTable will return NoNeedOperate when memtable is empty
292-
if (!s.ok() && !s.IsNoNeedOperate()) {
291+
if (!s.ok()) {
293292
LogFlush(immutable_db_options_.info_log);
294293
return s;
295294
}
@@ -957,7 +956,7 @@ Status DBImpl::FlushMemTable(ColumnFamilyData* cfd,
957956
if (cfd->imm()->NumNotFlushed() == 0 && cfd->mem()->IsEmpty() &&
958957
cached_recoverable_state_empty_.load()) {
959958
// Nothing to flush
960-
return Status::NoNeedOperate();
959+
return Status::OK();
961960
}
962961

963962
if (!cfd->mem()->IsEmpty()) {

db/external_sst_file_test.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ TEST_F(ExternalSSTFileTest, Basic) {
349349
std::string value = Key(k) + "_val";
350350
ASSERT_EQ(Get(Key(k)), value);
351351
}
352-
ASSERT_TRUE(Flush().ok() || Flush().IsNoNeedOperate());
352+
ASSERT_TRUE(Flush().ok());
353353
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
354354
}
355355

@@ -593,7 +593,7 @@ TEST_F(ExternalSSTFileTest, AddList) {
593593
std::string value = Key(k) + "_val";
594594
ASSERT_EQ(Get(Key(k)), value);
595595
}
596-
ASSERT_TRUE(Flush().ok() || Flush().IsNoNeedOperate());
596+
ASSERT_TRUE(Flush().ok());
597597
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
598598
}
599599

@@ -884,7 +884,7 @@ TEST_F(ExternalSSTFileTest, MultiThreaded) {
884884
std::string value = (k % 100 == 0) ? (key + "_new") : key;
885885
ASSERT_EQ(Get(key), value);
886886
}
887-
ASSERT_TRUE(Flush().ok() || Flush().IsNoNeedOperate());
887+
ASSERT_TRUE(Flush().ok());
888888
ASSERT_OK(db_->CompactRange(CompactRangeOptions(), nullptr, nullptr));
889889
}
890890

include/rocksdb/status.h

-11
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ class Status {
5959
kBusy = 11,
6060
kExpired = 12,
6161
kTryAgain = 13,
62-
63-
kNoNeedOperate = 101,
6462
};
6563

6664
Code code() const { return code_; }
@@ -174,11 +172,6 @@ class Status {
174172
return Status(kAborted, kMemoryLimit, msg, msg2);
175173
}
176174

177-
static Status NoNeedOperate(SubCode msg = kNone) { return Status(kNoNeedOperate, msg); }
178-
static Status NoNeedOperate(const Slice& msg, const Slice& msg2 = Slice()) {
179-
return Status(kNoNeedOperate, msg, msg2);
180-
}
181-
182175
// Returns true iff the status indicates success.
183176
bool ok() const { return code() == kOk; }
184177

@@ -228,10 +221,6 @@ class Status {
228221
// re-attempted.
229222
bool IsTryAgain() const { return code() == kTryAgain; }
230223

231-
// Returns true iff the status indicates a NoNeedOperate error.
232-
// This usually means that the operation is not need to do.
233-
bool IsNoNeedOperate() const { return code() == kNoNeedOperate; }
234-
235224
// Returns true iff the status indicates a NoSpace error
236225
// This is caused by an I/O error returning the specific "out of space"
237226
// error condition. Stricto sensu, an NoSpace error is an I/O error

util/status.cc

-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ std::string Status::ToString() const {
8484
case kTryAgain:
8585
type = "Operation failed. Try again.: ";
8686
break;
87-
case kNoNeedOperate:
88-
type = "No need to operate: ";
89-
break;
9087
default:
9188
snprintf(tmp, sizeof(tmp), "Unknown code(%d): ",
9289
static_cast<int>(code()));

utilities/checkpoint/checkpoint_impl.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ Status CheckpointImpl::CreateCheckpointQuick(const std::string& checkpoint_dir,
442442
s = Status::Corruption("Can't parse file name. This is very bad");
443443
break;
444444
}
445-
// we should only get sst, manifest and current files here
445+
// we should only get sst, manifest, current and options files here
446446
assert(type == kTableFile || type == kDescriptorFile ||
447-
type == kCurrentFile);
447+
type == kCurrentFile || type == kOptionsFile);
448448
assert(live_files[i].size() > 0 && live_files[i][0] == '/');
449449
const std::string& src_fname = live_files[i];
450450

utilities/checkpoint/checkpoint_test.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ TEST_F(CheckpointTest, CurrentFileModifiedWhileCheckpointing) {
438438
rocksdb::port::Thread t([&]() {
439439
Checkpoint* checkpoint;
440440
ASSERT_OK(Checkpoint::Create(db_, &checkpoint));
441-
ASSERT_EQ(Status::NoNeedOperate(), checkpoint->CreateCheckpoint(kSnapshotName));
441+
ASSERT_OK(checkpoint->CreateCheckpoint(kSnapshotName));
442442
delete checkpoint;
443443
});
444444
TEST_SYNC_POINT(

0 commit comments

Comments
 (0)