Repository navigation
fix(events): jitter a Retry-After wait up, and pin a log's on-disk bytes - #426
Open
abelonogov-ld wants to merge 2 commits into
Open
abelonogov-ld wants to merge 2 commits into
abelonogov-ld wants to merge 2 commits into
Conversation
A Retry-After wait was jittered down by up to half, so an instance could post before the service asked. Jitter it up by up to half instead, stopping at the hour a server-directed wait is capped at. A wait asked for of an hour or more has no room above the cap, so it is still jittered down from the hour. Matches the iOS change. Co-authored-by: Cursor <cursoragent@cursor.com>
The format tests were structural round trips, so a drift in the header or the framing still passed. Assert the page-cache spec's Appendix A log as a hex literal: the header, what the store writes for its two events, what the reader makes of it, and that a next run delivers it. The iOS suite asserts the same bytes. Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
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.
Two changes, stacked on #425 (the RETRY 1.5.6 extended initial delay), which is stacked on #408 (tier 3).
A
Retry-Afterwait is jittered up, never below what the service asked. It was jittered down by up to half, so an instance could post before the time the response asked for.DeliveryRetryState.directedWaitMillisnow waits between the asked duration and 1.5 times it, stopping at the one-hour cap on a server-directed wait (RETRY 1.11.4).recordFailureDuringWait), where aRetry-Aftercan still only lengthen the wait.Retry-Afterstays unjittered, as RETRY 1.4.3 allows.aRetryAfterSetsTheWaitBeforeTheNextPostasks for 3 s instead of 4, so the retry still lands well inside its timeout.The on-disk bytes of a log are pinned to the spec's worked example. The format tests were structural round trips, so a drift in the header or the framing still passed. The page-cache persistence spec's Appendix A log (two events, 108 bytes, checksums verified independently with zlib) is now a hex literal,
EventLogFormatTest.WORKED_EXAMPLE, asserted for:EventLogFormatand the store write for its two events;The iOS suite asserts the same bytes. Setting the format version to 2 fails all four new tests; the existing
EventStoreTesttests all still pass with it.Tested:
:launchdarkly-android-client-sdk:testDebugUnitTest, 1264 tests, 0 failures.Note
Overview
Event delivery:
Retry-Afterhandling now waits at least the server’s requested duration (jittered upward by up to half, capped at one hour) instead of jittering down, so clients do not retry early. Requests of an hour or more still jitter downward from the one-hour cap so fleets do not realign. Logic lives in newdirectedWaitMillisand is shared byrecordFailureandrecordFailureDuringWait.Event log format: Tests pin on-disk bytes to the page-cache persistence spec’s Appendix A worked example (aligned with iOS), covering header, write/read, assembly, and store recovery—not just structural round-trips.
Reviewed by Cursor Bugbot for commit 96f97d6. Bugbot is set up for automated code reviews on this repo. Configure here.