Skip to content

fix: set close-on-exec on log file descriptors - #405

Merged
ti-chi-bot[bot] merged 1 commit into
tikv:masterfrom
drifting-shard:fix/close-on-exec-log-fds
Aug 24, 2026
Merged

fix: set close-on-exec on log file descriptors#405
ti-chi-bot[bot] merged 1 commit into
tikv:masterfrom
drifting-shard:fix/close-on-exec-log-fds

Conversation

@drifting-shard

@drifting-shard drifting-shard commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

What changed

Set O_CLOEXEC when opening and creating log files in the default
Unix backend.

Without this flag, applications embedding Raft Engine can leak log file
descriptors into spawned child processes. Those children may keep purged
files alive after unlinking, preventing disk space from being reclaimed.

The flag is applied at open time to avoid the fork/exec race in
multithreaded applications.

Fixes #404

Tests

  • cargo fmt --check
  • cargo check --lib

The full test suite was not run locally because the bundled grpcio-sys
dependency fails to build on ARM macOS. GitHub Actions runs it on Ubuntu.

Summary by CodeRabbit

  • Bug Fixes
    • Improved file descriptor handling to ensure log files are automatically closed when executing other programs.
    • Applied consistent close-on-exec behavior when opening and creating log files.

Signed-off-by: drifting-shard <amitsharma0843@gmail.com>
@ti-chi-bot ti-chi-bot Bot added dco-signoff: yes Indicates the PR's author has signed the dco. contribution This PR is from a community contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Aug 7, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

Hi @drifting-shard. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot

ti-chi-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

Welcome @drifting-shard!

It looks like this is your first PR to tikv/raft-engine 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to tikv/raft-engine. 😃

@ti-chi-bot ti-chi-bot Bot added the first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. label Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3beb504c-6821-4eff-a340-d929945c76e8

📥 Commits

Reviewing files that changed from the base of the PR and between 3258ed1 and 6fa7ac6.

📒 Files selected for processing (1)
  • src/env/log_fd/unix.rs

📝 Walkthrough

Walkthrough

Unix log file opening and creation now include O_CLOEXEC. LogFd::open derives and reuses the combined permission flags.

Changes

Log file descriptor flags

Layer / File(s) Summary
Apply close-on-exec flags
src/env/log_fd/unix.rs
LogFd::open combines permission flags with O_CLOEXEC. LogFd::create adds O_CLOEXEC to its read/write/create flags.

Estimated code review effort: 2 (Simple) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: enabling close-on-exec for log file descriptors.
Linked Issues check ✅ Passed The changes set O_CLOEXEC when opening and creating Unix log files, directly addressing issue #404.
Out of Scope Changes check ✅ Passed The four changed lines are limited to adding O_CLOEXEC in the Unix log descriptor open and create paths.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 7, 2026
@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Aug 15, 2026
@tabokie
tabokie requested a review from LykxSassinator August 22, 2026 13:57
@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LykxSassinator, tabokie

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [LykxSassinator,tabokie]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot

ti-chi-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-08-15 11:41:48.752149325 +0000 UTC m=+3478694.788244380: ☑️ agreed by tabokie.
  • 2026-08-24 03:08:48.767518587 +0000 UTC m=+471163.938612701: ☑️ agreed by LykxSassinator.

@ti-chi-bot
ti-chi-bot Bot merged commit 8c8624c into tikv:master Aug 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. lgtm needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disk space is not reclaimed after log purge when the host application has spawned child processes

3 participants