Skip to content

jj-diff-* temp directories leak in $TMPDIR, eventually filling the disk (440 GB / 4,101 dirs observed) #282

Description

@TomerAberbach

jjk leaves orphaned jj-diff-XXXXXX directories in the OS temp dir. They accumulate indefinitely and each contains a full materialized checkout of the repo, so on large repos they consume enormous space. On my machine they grew to 4,101 directories totaling ~440 GB, filling my disk to 100%.

Environment

  • jjk: v0.11.0
  • jj: 0.42.0
  • OS: macOS (Apple Silicon)
  • No external ui.diff.tool / ui.diff-editor configured by me; jjk is the only thing invoking jj's external-tool diff path.

What I observed

  • $TMPDIR contained thousands of jj-diff-* dirs, created in bursts of 100–200+ per minute during active editing sessions.
  • Each dir contains jj's materialized trees: left, left_state, and sometimes right, right_state.
  • The majority have only left/left_state (no right); i.e. the jj process was terminated early, after the left tree was checked out but before the right.
  • A leftover jjk-signal-* dir was also present.

Likely mechanism

jjk drives jj's interactive diff machinery with the bundled fakeeditor, e.g.:

jj squash --from … --into … --interactive --tool <fakeeditor> --use-destination-message …

jj materializes the trees into a jj-diff-* temp dir (cleaned up by Rust's tempfile::TempDir only on graceful process exit) and runs the tool. jjk's bundle calls .kill() / process.kill(pid, "SIGTERM") on the jj/fakeeditor child processes when an operation is cancelled or superseded (the SCM/graph view refreshes on every file change, so in-flight operations are killed frequently).

A jj process killed by SIGTERM never runs the TempDir destructor, so the jj-diff-* dir is orphaned. The prevalence of left-only dirs is consistent with the kill arriving mid-checkout. This isn't really a jj bug, a signal-killed process can't clean its own temp dir, but jjk triggers these checkouts and kills the process without cleaning up after itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions