66#include < chrono>
77#include < sstream>
88#include < ctime>
9- #include < thread>
109
1110#include " rocksdb/env.h"
1211
@@ -272,9 +271,9 @@ void SelectColumnFamilyHandles(const DataType& option_type, const ColumnFamilyTy
272271Status Redis::LongestNotCompactionSstCompact (const DataType& option_type, std::vector<Status>* compact_result_vec,
273272 const ColumnFamilyType& type) {
274273 bool no_compact = false ;
275- bool to_comapct = true ;
276- if (!in_compact_flag_.compare_exchange_weak (no_compact, to_comapct , std::memory_order_relaxed,
277- std::memory_order_relaxed)) {
274+ bool to_compact = true ;
275+ if (!in_compact_flag_.compare_exchange_strong (no_compact, to_compact , std::memory_order_relaxed,
276+ std::memory_order_relaxed)) {
278277 return Status::Busy (" compact running" );
279278 }
280279
@@ -465,8 +464,8 @@ Status Redis::IncrementalCompact(const DataType& option_type, std::vector<Status
465464 // 1. 并发控制
466465 bool no_compact = false ;
467466 bool to_compact = true ;
468- if (!in_compact_flag_.compare_exchange_weak (no_compact, to_compact, std::memory_order_relaxed,
469- std::memory_order_relaxed)) {
467+ if (!in_compact_flag_.compare_exchange_strong (no_compact, to_compact, std::memory_order_relaxed,
468+ std::memory_order_relaxed)) {
470469 return Status::Busy (" compact running" );
471470 }
472471 DEFER { in_compact_flag_.store (false ); };
@@ -551,6 +550,9 @@ Status Redis::IncrementalCompact(const DataType& option_type, std::vector<Status
551550 if (!s.ok ()) {
552551 LOG (WARNING) << " IncrementalCompact failed for file " << oldest_file
553552 << " : " << s.ToString ();
553+ if (compact_result_vec) {
554+ compact_result_vec->push_back (s);
555+ }
554556 break ;
555557 }
556558
@@ -568,7 +570,7 @@ Status Redis::IncrementalCompact(const DataType& option_type, std::vector<Status
568570 processed++;
569571 }
570572
571- if (compact_result_vec) {
573+ if (compact_result_vec && (compact_result_vec-> empty () || compact_result_vec-> back (). ok ()) ) {
572574 compact_result_vec->push_back (Status::OK ());
573575 }
574576 }
0 commit comments