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 <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2023-11-30 14:24:00 +03:00
parent bb167dcca5
commit fcf080b63b

View File

@@ -590,12 +590,13 @@ future<std::pair<sstring, sstring>> 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());