diff --git a/be/src/load/stream_load/stream_load_recorder.cpp b/be/src/load/stream_load/stream_load_recorder.cpp index 742bcd82ecf05d..64971833e7080c 100644 --- a/be/src/load/stream_load/stream_load_recorder.cpp +++ b/be/src/load/stream_load/stream_load_recorder.cpp @@ -18,6 +18,7 @@ #include "load/stream_load/stream_load_recorder.h" #include +#include #include #include @@ -39,16 +40,24 @@ StreamLoadRecorder::StreamLoadRecorder(std::string root_path) StreamLoadRecorder::~StreamLoadRecorder() { if (_db != nullptr) { - for (auto* handle : _handles) { - _db->DestroyColumnFamilyHandle(handle); - handle = nullptr; - } rocksdb::Status s = _db->SyncWAL(); if (!s.ok()) { LOG(WARNING) << "rocksdb sync wal failed: " << s.ToString(); } - // no need to Close(), will be called in destruction + rocksdb::CancelAllBackgroundWork(_db.get(), true); + for (auto* handle : _handles) { + s = _db->DestroyColumnFamilyHandle(handle); + if (!s.ok()) { + LOG(WARNING) << "rocksdb destroy column family handle failed: " << s.ToString(); + } + } + _handles.clear(); + s = _db->Close(); + if (!s.ok()) { + LOG(WARNING) << "rocksdb close failed: " << s.ToString(); + } LOG(INFO) << "finish close rocksdb for ~StreamLoadRecorder"; + _db.reset(); } }