Repository navigation
feat: Retry event delivery and flush on close #74
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
Open
flagsmithsmith
wants to merge
4
commits into
main
Choose a base branch
from
openhands/sdk-spec-v0.9.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
82d3b93
deps: update dependency flagsmith/sdk-spec to v0.9.0
renovate[bot] f2c693b
ci: Run the SDK spec for this SDK's capabilities
flagsmith-engineering[bot] b6b19ed
feat: Retry event delivery and flush on close
flagsmithsmith[bot] f81d3f2
fix(Events): Kill the events processor when closing the client times out
flagsmithsmith[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
If
close/2times out while a flush is retrying, that flush keeps sending for up to ~12 s. Kill the processor on timeout, or run sends in a cancellable task.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.
Fixed in f81d3f2. I went with killing the processor on timeout.
{:close, deadline}call times out,close/2kills the processor and waits for its:DOWNbefore returning{:error, :timeout}. It has to be:killbecause the processor traps exits, so a:shutdownwould just sit in its mailbox behind the running flush. The kill also takes down the request task thatTesla.Middleware.Timeoutlinks to it, so no further attempt or backoff runs.restart: :temporary(it was:transient), so the supervisor doesn't bring a killed processor back.track/2already starts a processor when none is registered, so tracking after a close or a crash still works. The only difference is that a crashed processor's flush timer now restarts with the next tracked event. The crashed processor's buffer was lost either way, so nothing that could be sent is left waiting.DynamicSupervisorlogs a:killedchild termination report when this happens, next to our own "Gave up sending events after … while closing" warning. It only happens when a close times out.New test: "closing the client stops a flush still sending when its timeout expires". It starts a flush that the mocked events API keeps failing slowly, then calls
close(config, 50)mid-retry. It asserts{:error, :timeout}, that the processor is dead and unregistered, and that no further attempt is made in the next 500 ms. It passed 10 out of 10 runs.I left out the cancellable-task alternative. It would keep the processor alive, but flush callers would then need deferred replies, and events tracked during a send would need queueing behind the batch in flight. That's much more code for the same result here, since a closed processor isn't reused.