Provide status to both MaxAllowedSpaceReached callbacks

This commit is contained in:
Adam Retter 2021-01-03 08:25:21 +01:00
parent 30cd38c687
commit f34d90b3fe
2 changed files with 9 additions and 7 deletions

View File

@ -1559,14 +1559,12 @@ Status CompactionJob::FinishCompactionOutputFile(
s = add_s;
}
if (sfm->IsMaxAllowedSpaceReached()) {
// TODO(ajkr): should we return OK() if max space was reached by the final
// compaction output file (similarly to how flush works when full)?
s = Status::SpaceLimit("Max allowed space was reached");
TEST_SYNC_POINT(
Status new_bg_error = Status::SpaceLimit("Max allowed space was reached");
TEST_SYNC_POINT_CALLBACK(
"CompactionJob::FinishCompactionOutputFile:"
"MaxAllowedSpaceReached");
"MaxAllowedSpaceReached", &new_bg_error);
InstrumentedMutexLock l(db_mutex_);
db_error_handler_->SetBGError(s, BackgroundErrorReason::kCompaction);
db_error_handler_->SetBGError(new_bg_error, BackgroundErrorReason::kCompaction);
}
}
#endif

View File

@ -927,6 +927,7 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
"DBImpl::FlushMemTableToOutputFile:MaxAllowedSpaceReached",
[&](void* arg) {
Status* bg_error = static_cast<Status*>(arg);
EXPECT_TRUE(bg_error->IsIOError());
bg_error_set = true;
reached_max_space_on_flush++;
// clear error to ensure compaction callback is called
@ -941,9 +942,12 @@ TEST_F(DBSSTTest, DBWithMaxSpaceAllowedRandomized) {
ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack(
"CompactionJob::FinishCompactionOutputFile:MaxAllowedSpaceReached",
[&](void* /*arg*/) {
[&](void* arg) {
Status* bg_error = static_cast<Status*>(arg);
EXPECT_TRUE(bg_error->IsIOError());
bg_error_set = true;
reached_max_space_on_compaction++;
// do not clear bg_error, it is used for while loop termination below!
});
for (auto limit_mb : max_space_limits_mbs) {