Skip to content

Commit 1f7f0a1

Browse files
LaurentiuCristoforLaurentiu Cristofor
andauthored
Fix fds leaking after log truncation (#540)
Co-authored-by: Laurentiu Cristofor <[email protected]>
1 parent 47700a6 commit 1f7f0a1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

production/db/core/src/db_client.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,11 @@ void client::rollback_transaction()
587587
size_t log_size;
588588
s_log.truncate_seal_and_close(fd_log, log_size);
589589

590+
// We now own destruction of fd_log.
591+
auto cleanup_fd_log = make_scope_guard([&]() {
592+
close_fd(fd_log);
593+
});
594+
590595
// Avoid sending transaction log fd to the server read only transactions.
591596
if (log_size > 0)
592597
{
@@ -623,6 +628,11 @@ void client::commit_transaction()
623628
size_t log_size;
624629
s_log.truncate_seal_and_close(fd_log, log_size);
625630

631+
// We now own destruction of fd_log.
632+
auto cleanup_fd_log = make_scope_guard([&]() {
633+
close_fd(fd_log);
634+
});
635+
626636
// Send the server the commit event with the log segment fd.
627637
FlatBufferBuilder builder;
628638
build_client_request(builder, session_event_t::COMMIT_TXN);

0 commit comments

Comments
 (0)