-
Notifications
You must be signed in to change notification settings - Fork 33
[FSSDK-12153] chore: update event retry strategy #618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
Implemented synchronous blocking retry strategy with exponential backoff for both DefaultEventDispatcher and OdpEventManager: - Per-batch retry: Each batch gets up to 3 attempts with exponential backoff delays (200ms, 400ms, 800ms) - Global failure counter: Tracks consecutive batch failures across all batches in a flush - Blocking approach: Uses Thread.sleep() for delays and notify.wait() for synchronous operations - Reachability fix: Moved updateNumContiguousFails() outside retry loop to prevent premature network blocking - ODP error handling: Differentiates recoverable errors (retry) vs non-recoverable errors (discard) - JSON determinism: Added .sortedKeys to JSONEncoder for consistent test assertions - OdpConfig fix: Made update() synchronous to prevent race conditions Added comprehensive test suites: - OdpEventManagerRetryTests: 13 tests covering retry scenarios, error handling, and timing - EventDispatcherRetryTests: Tests for DefaultEventDispatcher retry logic - RetryStrategyTests: Unit tests for exponential backoff calculation - Updated existing tests to match new retry behavior expectations All tests passing: OdpEventManagerRetryTests (13/13), EventDispatcherTests_Batch (27/27) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
… and update tests
219f4ef to
83b0c5d
Compare
jaeopt
previously approved these changes
Jan 16, 2026
Contributor
jaeopt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a major rewrite and I hope it's fully tested with network failure cases against deadlock/livelock.
Other than that, all looks good to me! A couple of nits to clean up.
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
Key Changes
Removed DispatchGroup.wait(): Replaced the blocking synchronization used during network requests with non-blocking asynchronous completion handlers. This ensures that the serial queue threads are not held idle while waiting for I/O.
Non-Blocking close(): Updated DefaultEventDispatcher.close() to use a timed wait on a DispatchGroup. This ensures a graceful shutdown by waiting for pending flushes without risk of hanging the application indefinitely (includes a 10-second safety timeout).
Exponential Backoff: Introduced a formal retry strategy using DispatchQueue.asyncAfter. This replaces the previous "tight-loop" retry behavior (where failed batches were retried immediately) with a non-blocking delay sequence (200ms, 400ms, 800ms).
RetryStrategy Utility: Added a centralized RetryStrategy class to ensure consistent backoff logic across the SDK.
isFlushing Flag: Added state tracking to prevent multiple concurrent flush operations from running on the same dispatcher instance, improving thread safety and resource management.
Test plan
Issues