fix(r2dbc): avoid unnecessary rejection given deleted offsets #1293
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.
We've been seeing unnecessary rejection (and replay) of events. There can be a large enough gap between events, so that all older offsets for a pid have been deleted, while the previous timestamp is after the start timestamp (minus the backtracking window, the current accept before time). Then any later events for that pid will be rejected.
Deletion is now per slice, offsets are lazy loaded when not in-memory, and the offset table should have at least the latest offset for each slice. So we can instead accept seq numbers if the previous offset could have been deleted (it's before the delete-until timestamp for its slice).
At first, because of other tests failing when a slice was untracked, I had it fallback to the previous accept-before timestamp (start minus backtracking). But given that any slice which has been seen by a projection will have at least the latest offset for that slice, then if the slice is not tracked (no deletion window can be defined) then we should always reject. Have updated other tests for this behaviour.
This only updates for R2DBC. We can make a similar change for DynamoDB, but based on TTL settings.