Skip to content

fix(watch): delete a large batch of synced paths in several execs - #14528

Merged
ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/watch-delete-arg-limit
Nov 18, 2026
Merged

ndeloof merged 1 commit into
docker:mainfrom
htoyoda18:fix/watch-delete-arg-limit

Conversation

@htoyoda18

@htoyoda18 htoyoda18 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does

When a watch batch deletes many files under a sync path, Compose removed them all with a single rm -rf exec. Once the paths add up to about 2 MiB, which is Linux's default ARG_MAX, that exec fails with argument list too long. None of the deletions are applied and watch only logs a warning, so the deleted files silently stay in the container.

Related issue

Fixes #14527

Changes made

  • internal/sync/tar.go: add deleteCommands, which splits the paths to delete, in order, into rm -rf commands whose arguments stay under maxDeleteArgsSize (128 KiB). Tar.Sync runs them one after another for each container. If one fails, it stops deleting in that container and records the same deleting paths in <id> error as before. The copy step is unchanged.
  • internal/sync/tar_test.go: add TestSync_SplitsALargeDeletionIntoSeveralExecs. It deletes 12,000 paths of about 200 bytes each and checks that every rm stays under 2 MiB of arguments, and that all paths are deleted exactly once, in order. Without the fix, the test fails with a single rm of 2,412,007 bytes.

Testing done

  • Unit tests pass: make test
  • E2E tests pass: make e2e-compose or make e2e-compose-standalone
  • Linting passes: make lint
  • Code formatted: make fmt
  • Manually tested (describe):

Additional context

(not mandatory) A picture of a cute animal, if possible in relation to what you did

image

Signed-off-by: Hiroto Toyoda <hirototoyoda20020927@gmail.com>
@htoyoda18
htoyoda18 marked this pull request as ready for review November 17, 2026 15:45
@htoyoda18
htoyoda18 requested review from a team as code owners November 17, 2026 15:45
@htoyoda18
htoyoda18 requested review from glours and ndeloof November 17, 2026 15:45

@ndeloof ndeloof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

nit: the new break on the first failing rm chunk is not covered by a test (a fake Exec returning an error on the 2nd call would pin that the remaining chunks are skipped, the error is recorded once, and the copy still runs).

@ndeloof
ndeloof enabled auto-merge (rebase) November 18, 2026 07:02
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/sync/tar.go 94.44% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@ndeloof
ndeloof merged commit ee6f7f3 into docker:main Nov 18, 2026
63 of 66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] watch: deleting many files at once leaves them all in the container ("argument list too long")

2 participants