fix: apply post-check propagation delay per file with elapsed-time credit#224
Closed
javi11 wants to merge 2 commits into
Closed
fix: apply post-check propagation delay per file with elapsed-time credit#224javi11 wants to merge 2 commits into
javi11 wants to merge 2 commits into
Conversation
…edit Track postedAt on each Post when its upload completes, and in checkLoop wait only the remainder of PostCheck.RetryDelay that hasn't already elapsed since that file finished posting. Removes the firstPost-gated single wait, which caused files 2..N within a multi-file Post() call to skip the propagation grace period entirely while file 1 paid the full delay. Refs #184.
Issue #184: with MaxConcurrentUploads=1, every uploaded file paid the full PostCheck.RetryDelay because each file was its own Post() call that spawned a fresh per-call checkLoop and only returned after STAT verification. Refactor postLoop and checkLoop to be poster-lifetime goroutines spawned once (lazily) per poster instance, sharing the postQueue and checkQueue. Post() now returns as soon as all uploads complete; the propagation delay and STAT verification run in the background on the long-lived checkLoop. Permanent verification failures (articles exhausting MaxRePost) are now surfaced via a per-call CheckExhaustedCallback set on the Postie wrapper via SetVerificationCallback. The processor wires this callback to queue.AddPendingArticleChecks, so the existing PostCheckRetryWorker keeps draining failures from the deferred-check DB queue exactly as before. Behavior changes: - Post() no longer returns DeferredCheckError synchronously; verification results are reported asynchronously through the existing deferred path. - Non-deferred verification exhaustion (post_check.deferred_check_delay=0) is now logged-only instead of returned as an error from Post(); the upload itself still succeeds. - poster.Close() now drains the long-lived loops with a 30s soft timeout before force-cancelling. Compile-time API additions: - poster.Poster gains PostWithCallback(ctx, files, rootDir, nzbGen, relativePaths, completedItemID, onCheckExhausted). - pkg/postie.Postie gains SetVerificationCallback(itemID, cb). Existing call sites in pkg/postie and the CLI keep working unchanged because callbacks default to nil (matches the legacy "drop on failure" behavior). DeferredCheckError type and the old synchronous catch sites in pkg/postie + processor remain as harmless dead code; can be removed in a follow-up. Refs #184. Builds on #224 (Phase 1, per-file postedAt).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
+ "postedAt time.Time" +to+ "Post" +; set in+ "postLoop" +after upload success.+ "checkLoop" +, replace the+ "firstPost" +-gated single wait with a per-file residual:+ "remaining = RetryDelay - time.Since(post.postedAt)" +, clamped to 0.Why
Refs #184. The previous behavior only sleeped before file 1's check; files 2..N within a multi-file
+ "Post()" +call were STAT'd immediately. With small/fast files that risks false-negative+ "STAT" +results that trigger needless reposts. This is the first half of the fix javi11 outlined in the issue's penultimate comment ("propagation delay for all the post file instead of just one article").Out of scope
Async lifecycle refactor (move
+ "postLoop" +/+ "checkLoop" +off+ "Post()" +'s critical path so+ "Post()" +returns after upload, not after check) — needed to actually fix throughput at+ "MaxConcurrentUploads=1" +. Tracked separately.Test plan
+ "go build ./internal/poster/..." ++ "go test -race -count=1 ./internal/poster/..." +(passes, 1.5s)