Skip to content
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

fix(r2dbc): avoid unnecessary rejection given deleted offsets #1293

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

pvlugter
Copy link
Contributor

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.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good, makes much more sense than the startTimestamp

timestampOf(pid, seqNr - 1).map {
case Some(previousTimestamp) =>
val acceptBefore = currentState.startTimestamp.minus(settings.backtrackingWindow)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The startTimestamp can now be removed. It's only used by some logging, but that is now obsolete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, removed.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please make the same changes to DynamoDB

@pvlugter pvlugter changed the title fix: avoid unnecessary rejection given deleted offsets fix(r2dbc): avoid unnecessary rejection given deleted offsets Jan 13, 2025
@pvlugter pvlugter merged commit b366cc6 into main Jan 13, 2025
22 checks passed
@pvlugter pvlugter deleted the timestamp-validation branch January 13, 2025 22:42
@patriknw patriknw added this to the 1.6.6 milestone Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants