Repository navigation
Export: bounded retry + skip on transient fetch failure - #243
Open
rickhuizinga wants to merge 1 commit into
Open
rickhuizinga wants to merge 1 commit into
rickhuizinga wants to merge 1 commit into
Conversation
In ExportChangesDiff->Synchronize(), the step counter only advances when no exception propagates. A single transient StatusException from the backend's StatMessage/GetMessage pair (e.g. a one-off empty FETCH response from the IMAP server on an otherwise healthy folder) therefore made the export loop retry the same message every iteration until the WBXML loop guard aborted the whole request (HTTP 500), discarding all progress of the sync. Aborted requests tend to trigger further server-side rate limiting, so the next open re-ran the same doomed export from scratch. A code-15 (SYNC_ITEMOPERATIONSSTATUS_INVALIDATT) StatusException from the StatMessage/GetMessage pair is now retried once after a short backoff; if the retry fails again, the message is logged as skipped and the step advances, so the rest of the export continues and the item self-heals on the next sync pass. Any other exception code still propagates unchanged.
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.
Fixes #241
Problem
In
ExportChangesDiff::Synchronize(), a transientStatusExceptionfrom theStatMessage/GetMessagepair propagates out of the method before$this->step++runs. The sync loop inrequest/sync.phpthen callsSynchronize()again for the same step, retrying the same message until the request-loop guard (5,000 iterations) aborts the request: HTTP 500, no sync state written, full re-export from the top on the next open. One transient fetch failure could therefore livelock a large folder (each aborted pass re-trips the server rate limiter, so the immediate retry passes fail item-by-item against the cooldown too).Observed in production (multi-device ActiveSync deployment): a ~1,300-message folder produced 11 consecutive failed full exports, each dying at item position ~150–225 with an identical signature (~5,000 code-15 "message not found" log lines in ~1 s, then the guard abort, then 500).
Changes
src/lib/default/diffbackend/exportchangesdiff.php,Synchronize()only:StatusExceptionwith codeSYNC_ITEMOPERATIONSSTATUS_INVALIDATT(15) from theStatMessage/GetMessagepair is now retried once after a short backoff (the message is re-read from scratch).Why this is safe
Test evidence
Behavioral harness (attached as
harness-export-loop-retry-skip.php) driving the realExportChangesDiff::Synchronize()export loop with a scripted backend stub (realDiffState/StateObject; runs withphp -n). Captured output on the candidate branch:On unmodified
develop,T1/T2do not terminate cleanly (the step never advances past a throwing message) — the same mechanism that produced the production livelock.The harness below is self-contained —
php -n -d display_errors=1 <file> /path/to/checkout:Production note
These changes have been running in production on a multi-device ActiveSync deployment since early November 2026. Since deployment: the livelock signature (guard abort + HTTP 500 on a full-folder export) has not recurred, the affected folder completed its export and now syncs normally, and transient fetch failures log a single skip-and-continue line instead of aborting the request.
Checklist
php -lclean