Skip to content

fix: stop a prune cycle cleanly and count what it actually pruned - #360

Open
mennatnaga wants to merge 7 commits into
mainfrom
menna/pruner-bounded-stop
Open

fix: stop a prune cycle cleanly and count what it actually pruned#360
mennatnaga wants to merge 7 commits into
mainfrom
menna/pruner-bounded-stop

Conversation

@mennatnaga

@mennatnaga mennatnaga commented Aug 11, 2026

Copy link
Copy Markdown
Member

Related #365

Stacked on #357.

DrainDocs empties every collection up front, so a cycle that ends before reaching them all has to put the rest back. Nothing else re-adds a document once it has replicated, so anything left behind is never pruned. A stop now re-queues every collection still drained.

The purge is handed to DefraDB in batches. DefraDB does not check the context inside a call, so a batch boundary is the only place a stop can be noticed.

PurgeByDocIDs reports only an error, and a document that was already gone purges silently, so the number it yields is documents submitted rather than deleted. The counter, its JSON tag and the log lines now say so.

Blocks are counted only when their own purge succeeded. A re-queued block collection is drained and counted again on a later cycle, so counting it on the failed cycle let the total exceed the blocks that were ever pruned.

@mennatnaga
mennatnaga force-pushed the menna/pruner-bounded-stop branch from 1422011 to 5d87e5f Compare August 12, 2026 14:14
@mennatnaga
mennatnaga force-pushed the menna/pruner-bounded-stop branch 2 times, most recently from dd39810 to 10d0928 Compare August 14, 2026 22:54
@mennatnaga
mennatnaga changed the base branch from menna/host-stats to menna/signal-shutdown August 14, 2026 22:54
@mennatnaga mennatnaga changed the title fix: bound the pruner shutdown and report submitted docs honestly fix: stop a prune cycle cleanly and count what it actually pruned Aug 14, 2026
@mennatnaga mennatnaga self-assigned this Aug 14, 2026
@mennatnaga
mennatnaga marked this pull request as ready for review August 14, 2026 23:35
@mennatnaga mennatnaga mentioned this pull request Aug 16, 2026
4 tasks
dvncan
dvncan previously approved these changes Aug 18, 2026
@tzdybal
tzdybal force-pushed the menna/signal-shutdown branch from e91f062 to a18094b Compare September 1, 2026 10:03
@mennatnaga
mennatnaga changed the base branch from menna/signal-shutdown to main September 1, 2026 11:55
@mennatnaga
mennatnaga dismissed dvncan’s stale review September 1, 2026 11:55

The base branch was changed.

@mennatnaga
mennatnaga force-pushed the menna/pruner-bounded-stop branch from b2c9102 to f08bf24 Compare September 1, 2026 11:59
@mennatnaga
mennatnaga requested a review from dvncan September 1, 2026 12:01
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 56.00000% with 66 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/pruner/pruner.go 59.74% 29 Missing and 2 partials ⚠️
pkg/host/stats.go 48.27% 30 Missing ⚠️
pkg/pruner/event_queue.go 64.28% 3 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@mennatnaga
mennatnaga force-pushed the menna/pruner-bounded-stop branch from e7d050e to 66a1b8b Compare September 2, 2026 02:26
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.

2 participants