engine_rocks: ignore NoSpace error during flush or compaction
* ignore NoSpace error during flush or compaction
fix
* use constant
* fix typo
@@ -9,6 +9,9 @@ use rocksdb::{
};
use tikv_util::set_panic_mark;
+// Message for RocksDB status subcode kNoSpace.
+const NO_SPACE_ERROR: &str = "IO error: No space left on device";
+
pub struct RocksEventListener {
db_name: String,
}
@@ -95,6 +98,14 @@ impl rocksdb::EventListener for RocksEventListener {
fn on_background_error(&self, reason: DBBackgroundErrorReason, result: Result<(), String>) {
assert!(result.is_err());
if let Err(err) = result {
+ if matches!(
+ reason,
+ DBBackgroundErrorReason::Flush | DBBackgroundErrorReason::Compaction
+ ) && err.starts_with(NO_SPACE_ERROR)
+ {
+ // Ignore NoSpace error and let RocksDB automatically recover.
+ return;
+ }
let r = match reason {
DBBackgroundErrorReason::Flush => "flush",
DBBackgroundErrorReason::Compaction => "compaction",
