fix(BufferedConsumer): don't resend delivered batches after a partial flush failure - #191
Open
ckarnell wants to merge 1 commit into
Open
fix(BufferedConsumer): don't resend delivered batches after a partial flush failure#191ckarnell wants to merge 1 commit into
ckarnell wants to merge 1 commit into
Conversation
…flush does not resend delivered events
Confidence Score: 5/5The PR appears safe to merge. The buffer is advanced only after each successful send, while a failed batch and all remaining events stay available for retry.
|
| Filename | Overview |
|---|---|
| mixpanel/init.py | Moves buffer advancement into the successful-send loop, preventing delivered batches from being retried after a partial failure. |
| test_mixpanel.py | Adds focused regression coverage confirming that only undelivered events remain buffered after a partial flush failure. |
Reviews (1): Last reviewed commit: "fix(BufferedConsumer): persist drained b..." | Re-trigger Greptile
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.
BufferedConsumer._flush_endpointonly writes the trimmed buffer back after the loop finishes, so when a later batch fails the earlier ones stay in the buffer even though the server already took them. The next flush sends them a second time.It needs more than
max_sizemessages queued to bite, which is what you get after any failed flush, sincesend()keeps appending to a buffer it couldn't drain.With
max_size=2and a network that drops the first and third attempts:The API receives
["a","b"], then["a","b"]again, then["c","d"]. Same events, twice. Moving the write inside the loop keeps anything already delivered out of the buffer.The new test fails on master with
['"a"', '"b"', '"c"', '"d"'] == ['"c"', '"d"']and passes with the change. Full suite is 57 passing.#16 and #54 both touched this code, but they were about concurrent flushes from
mixpanel-python-asyncand were closed as belonging in that wrapper. This one doesn't involve threads.