Repository navigation
fix(buffer): Hold filtered offsets while messages are buffered - #603
Open
muhammad-musa-ml wants to merge 1 commit into
Open
muhammad-musa-ml wants to merge 1 commit into
muhammad-musa-ml wants to merge 1 commit into
Conversation
Buffer passed a filtered message straight to the next step, even when earlier messages were still waiting in the buffer. With a FilterStep that has a commit policy in front of a Reduce, CommitOffsets then committed an offset past messages that had not been flushed yet. Snuba does this when a prefilter is set (strategy_factory.py) and sentry's last_seen_updater.py always does. A crash after that commit could lose the buffered messages, and the later batch commit moved the offset backwards. The offsets of filtered messages are now merged into the batch and go out with it. When nothing is waiting for a flush, the message is still forwarded at once. The check uses the offsets the Buffer holds and not the buffer's is_empty, because a buffer whose compute_batch_size returns 0 reports empty while it holds a message. All three new tests fail without the change.
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.
Fixes #602.
Bufferpassed a filtered message to the next step even while earlier messages were still waiting in the buffer, soCommitOffsetscould commit past messages that had not been flushed. The issue has the Snuba and Sentry chains and the broker's commit calls.The offsets of a filtered message are now merged into the batch and go out with it. When
Bufferholds no offsets, the message is forwarded at once, as before. The check uses the offsetsBufferholds and not the buffer'sis_empty, because a buffer whosecompute_batch_sizereturns 0 reports empty while it holds a message.Three new tests in
tests/processing/strategies/test_reduce.py; all three fail on main and pass here:FilterStep->Reduce->RunTask->CommitOffsetscommits nothing before the batch is writtenRun on Windows with Python 3.13.5 and confluent-kafka 2.16.1:
mypy . --strict: only the threesignal.SIGCHLDerrors that main also gives on Windows.flush_reasonline inbuffer.pyon main; I left it.With
BatchStepfollowed byUnbatchStep, the held offset of a filtered message at the end of a batch is not forwarded, becauseUnfolduses the batch's committable only when the last message has none. The last commit is then the last accepted message, and the filtered tail is read again after a restart.