@@ -201,7 +201,7 @@ Status DBImpl::FlushMemTableToOutputFile(
201
201
cfd->current ()->storage_info ()->LevelSummary (&tmp));
202
202
}
203
203
204
- if (!s.ok () && !s.IsShutdownInProgress ()) {
204
+ if (!s.ok () && !s.IsShutdownInProgress () && !s. IsColumnFamilyDropped () ) {
205
205
Status new_bg_error = s;
206
206
error_handler_.SetBGError (new_bg_error, BackgroundErrorReason::kFlush );
207
207
}
@@ -254,7 +254,7 @@ Status DBImpl::FlushMemTablesToOutputFiles(
254
254
snapshot_checker, log_buffer, thread_pri);
255
255
if (!s.ok ()) {
256
256
status = s;
257
- if (!s.IsShutdownInProgress ()) {
257
+ if (!s.IsShutdownInProgress () && !s. IsColumnFamilyDropped () ) {
258
258
// At this point, DB is not shutting down, nor is cfd dropped.
259
259
// Something is wrong, thus we break out of the loop.
260
260
break ;
@@ -385,7 +385,8 @@ Status DBImpl::AtomicFlushMemTablesToOutputFiles(
385
385
for (const auto & e : exec_status) {
386
386
if (!e.second .ok ()) {
387
387
s = e.second ;
388
- if (!e.second .IsShutdownInProgress ()) {
388
+ if (!e.second .IsShutdownInProgress () &&
389
+ !e.second .IsColumnFamilyDropped ()) {
389
390
// If a flush job did not return OK, and the CF is not dropped, and
390
391
// the DB is not shutting down, then we have to return this result to
391
392
// caller later.
@@ -397,15 +398,11 @@ Status DBImpl::AtomicFlushMemTablesToOutputFiles(
397
398
s = error_status.ok () ? s : error_status;
398
399
}
399
400
400
- // If db is NOT shutting down, and one or more column families have been
401
- // dropped.
402
- // TODO: use separate status code for db shutdown and column family dropped.
403
- if (s.IsShutdownInProgress () &&
404
- !shutting_down_.load (std::memory_order_acquire)) {
401
+ if (s.IsColumnFamilyDropped ()) {
405
402
s = Status::OK ();
406
403
}
407
404
408
- if (s.ok () || s.IsShutdownInProgress ()) {
405
+ if (s.ok () || s.IsShutdownInProgress () || s. IsColumnFamilyDropped () ) {
409
406
// Sync on all distinct output directories.
410
407
for (auto dir : distinct_output_dirs) {
411
408
if (dir != nullptr ) {
@@ -523,7 +520,7 @@ Status DBImpl::AtomicFlushMemTablesToOutputFiles(
523
520
524
521
// Need to undo atomic flush if something went wrong, i.e. s is not OK and
525
522
// it is not because of CF drop.
526
- if (!s.ok () && !s.IsShutdownInProgress ()) {
523
+ if (!s.ok () && !s.IsColumnFamilyDropped ()) {
527
524
// Have to cancel the flush jobs that have NOT executed because we need to
528
525
// unref the versions.
529
526
for (int i = 0 ; i != num_cfs; ++i) {
@@ -1052,7 +1049,7 @@ Status DBImpl::CompactFilesImpl(
1052
1049
1053
1050
if (status.ok ()) {
1054
1051
// Done
1055
- } else if (status.IsShutdownInProgress ()) {
1052
+ } else if (status.IsColumnFamilyDropped ()) {
1056
1053
// Ignore compaction errors found during shutting down
1057
1054
} else {
1058
1055
ROCKS_LOG_WARN (immutable_db_options_.info_log ,
@@ -1697,7 +1694,10 @@ Status DBImpl::WaitUntilFlushWouldNotStallWrites(ColumnFamilyData* cfd,
1697
1694
cfd->GetName ().c_str ());
1698
1695
bg_cv_.Wait ();
1699
1696
}
1700
- if (cfd->IsDropped () || shutting_down_.load (std::memory_order_acquire)) {
1697
+ if (cfd->IsDropped ()) {
1698
+ return Status::ColumnFamilyDropped ();
1699
+ }
1700
+ if (shutting_down_.load (std::memory_order_acquire)) {
1701
1701
return Status::ShutdownInProgress ();
1702
1702
}
1703
1703
@@ -2159,7 +2159,7 @@ void DBImpl::BackgroundCallFlush(Env::Priority thread_pri) {
2159
2159
2160
2160
Status s = BackgroundFlush (&made_progress, &job_context, &log_buffer,
2161
2161
&reason, thread_pri);
2162
- if (!s.ok () && !s.IsShutdownInProgress () &&
2162
+ if (!s.ok () && !s.IsShutdownInProgress () && !s. IsColumnFamilyDropped () &&
2163
2163
reason != FlushReason::kErrorRecovery ) {
2164
2164
// Wait a little bit before retrying background flush in
2165
2165
// case this is an environmental problem and we do not want to
@@ -2184,7 +2184,8 @@ void DBImpl::BackgroundCallFlush(Env::Priority thread_pri) {
2184
2184
2185
2185
// If flush failed, we want to delete all temporary files that we might have
2186
2186
// created. Thus, we force full scan in FindObsoleteFiles()
2187
- FindObsoleteFiles (&job_context, !s.ok () && !s.IsShutdownInProgress ());
2187
+ FindObsoleteFiles (&job_context, !s.ok () && !s.IsShutdownInProgress () &&
2188
+ !s.IsColumnFamilyDropped ());
2188
2189
// delete unnecessary files if any, this is done outside the mutex
2189
2190
if (job_context.HaveSomethingToClean () ||
2190
2191
job_context.HaveSomethingToDelete () || !log_buffer.IsEmpty ()) {
@@ -2248,7 +2249,8 @@ void DBImpl::BackgroundCallCompaction(PrepickedCompaction* prepicked_compaction,
2248
2249
mutex_.Unlock ();
2249
2250
env_->SleepForMicroseconds (10000 ); // prevent hot loop
2250
2251
mutex_.Lock ();
2251
- } else if (!s.ok () && !s.IsShutdownInProgress ()) {
2252
+ } else if (!s.ok () && !s.IsShutdownInProgress () &&
2253
+ !s.IsColumnFamilyDropped ()) {
2252
2254
// Wait a little bit before retrying background compaction in
2253
2255
// case this is an environmental problem and we do not want to
2254
2256
// chew up resources for failed compactions for the duration of
@@ -2272,7 +2274,8 @@ void DBImpl::BackgroundCallCompaction(PrepickedCompaction* prepicked_compaction,
2272
2274
// If compaction failed, we want to delete all temporary files that we might
2273
2275
// have created (they might not be all recorded in job_context in case of a
2274
2276
// failure). Thus, we force full scan in FindObsoleteFiles()
2275
- FindObsoleteFiles (&job_context, !s.ok () && !s.IsShutdownInProgress ());
2277
+ FindObsoleteFiles (&job_context, !s.ok () && !s.IsShutdownInProgress () &&
2278
+ !s.IsColumnFamilyDropped ());
2276
2279
TEST_SYNC_POINT (" DBImpl::BackgroundCallCompaction:FoundObsoleteFiles" );
2277
2280
2278
2281
// delete unnecessary files if any, this is done outside the mutex
@@ -2710,7 +2713,7 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
2710
2713
2711
2714
if (status.ok () || status.IsCompactionTooLarge ()) {
2712
2715
// Done
2713
- } else if (status.IsShutdownInProgress ()) {
2716
+ } else if (status.IsColumnFamilyDropped ()) {
2714
2717
// Ignore compaction errors found during shutting down
2715
2718
} else {
2716
2719
ROCKS_LOG_WARN (immutable_db_options_.info_log , " Compaction error: %s" ,
0 commit comments