Skip to content

Commit

Permalink
Fix fds leaking after log truncation (#540)
Browse files Browse the repository at this point in the history
Co-authored-by: Laurentiu Cristofor <[email protected]>
  • Loading branch information
LaurentiuCristofor and Laurentiu Cristofor authored Feb 11, 2021
1 parent 47700a6 commit 1f7f0a1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions production/db/core/src/db_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ void client::rollback_transaction()
size_t log_size;
s_log.truncate_seal_and_close(fd_log, log_size);

// We now own destruction of fd_log.
auto cleanup_fd_log = make_scope_guard([&]() {
close_fd(fd_log);
});

// Avoid sending transaction log fd to the server read only transactions.
if (log_size > 0)
{
Expand Down Expand Up @@ -623,6 +628,11 @@ void client::commit_transaction()
size_t log_size;
s_log.truncate_seal_and_close(fd_log, log_size);

// We now own destruction of fd_log.
auto cleanup_fd_log = make_scope_guard([&]() {
close_fd(fd_log);
});

// Send the server the commit event with the log segment fd.
FlatBufferBuilder builder;
build_client_request(builder, session_event_t::COMMIT_TXN);
Expand Down

0 comments on commit 1f7f0a1

Please sign in to comment.