From fcf080b63bf16ca51a610d720954de43562b9249 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Thu, 30 Nov 2023 14:24:00 +0300 Subject: [PATCH] sstable_directory: Close dir on exception When committing the deletion log creation its containing directory is sync-ed via opened file. This place is not exception safe and directory can be left unclosed Signed-off-by: Pavel Emelyanov --- sstables/sstable_directory.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sstables/sstable_directory.cc b/sstables/sstable_directory.cc index 6d9a6bffc0..f9dce37e30 100644 --- a/sstables/sstable_directory.cc +++ b/sstables/sstable_directory.cc @@ -590,12 +590,13 @@ future> sstable_directory::create_pending_deletion_l close_out.close_now(); auto dir_f = open_directory(pending_delete_dir).get0(); + auto close_dir = deferred_close(dir_f); // Once flushed and closed, the temporary log file can be renamed. rename_file(tmp_pending_delete_log, pending_delete_log).get(); // Guarantee that the changes above reached the disk. dir_f.flush().get(); - dir_f.close().get(); + close_dir.close_now(); sstlog.debug("{} written successfully.", pending_delete_log); } catch (...) { sstlog.warn("Error while writing {}: {}. Ignoring.", pending_delete_log, std::current_exception());