Skip to content

fix replication requests exceeding maxRoundWindow + splitting resends#431

Open
jadalsmail wants to merge 11 commits into
mainfrom
fix-replication-request-splitting
Open

fix replication requests exceeding maxRoundWindow + splitting resends#431
jadalsmail wants to merge 11 commits into
mainfrom
fix-replication-request-splitting

Conversation

@jadalsmail

@jadalsmail jadalsmail commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Motivation:
In resendReplicationRequests, timed-out sequences were compressed into contiguous segments and each segment was sent whole to a single node, which can be larger than maxRoundWindow. Thus, nodes drop such requests without responding, so a lagging node would resend the same oversized request forever and never catch up.

initial requests and timed-out retries now share a single send path. A new function, BatchSequences, which distributes seqs as evenly as possible among nodes, returning one batch per node share. Every batch contains at most maxSize sequences.

We also introduce a new variable, MaxRoundRequests, which is the max number of rounds or sequences that fit in one replication request. Every batch is capped at this size by construction. It is set to 10 to match DefaultMaxRoundWindow

Removed: CompressSequences, DistributeSequenceRequests, and the Segment type (plus their tests). the segment/range model they implemented is replaced by batching, and requests may now contain non-contiguous sequences (responders sort incoming requests).

Also, unit test + table tests (for BatchSequences) for testing this functionality were added.

@jadalsmail jadalsmail force-pushed the fix-replication-request-splitting branch from 7261a83 to a70872d Compare July 6, 2026 21:41
Comment thread simplex/util.go Outdated
Comment thread simplex/util.go Outdated
Comment thread simplex/util.go Outdated
Comment thread simplex/util_test.go Outdated
Comment thread simplex/requestor.go Outdated
Comment thread simplex/epoch.go Outdated
Comment thread simplex/requestor.go Outdated
Comment thread simplex/requestor.go
Comment thread simplex/requestor.go
Comment thread simplex/util.go Outdated
Comment thread simplex/util.go Outdated
Comment thread simplex/util.go Outdated
Comment thread simplex/util.go Outdated
Comment thread simplex/util_test.go

@yacovm yacovm left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I also want to review this change before it gets merged so please don't merge it yet

@yacovm

yacovm commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

This PR fixes the following bug:

  • in resendReplicationRequests, we aggregate continuous sequences which can be larger than maxRoundWindow

Also, unit tests testing this functionality were added.

Can we please have a more descriptive and elaborate PR description?

Comment thread .gitignore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lets undo this diff

@jadalsmail jadalsmail force-pushed the fix-replication-request-splitting branch 2 times, most recently from b3fa884 to 043ac1e Compare July 10, 2026 15:28
Comment thread simplex/epoch.go Outdated
Comment thread simplex/requestor.go
Comment thread simplex/replication_timeout_test.go Outdated
Comment thread simplex/replication_timeout_test.go
ReplicationEnabled: true,
// twice the responder's window: the timed-out sequences span more
// than a responder is willing to server in a single request
MaxRoundWindow: startSeq,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ideally we would reproduce the problem without specifying unique configuration such as modifying the max round window.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree, but here's the thing, the bug was reproducible with default config before #432, but that fix removed its trigger (outstanding requests can no longer exceed the responder limit when windows match). Since this PR merges both send paths into one function, the aggregation half can't fire on its own anymore. The window override recreates the same trigger condition #432 eliminated, so the test actually exercises the drop-and-wedge path and proves the new code survives it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree, but here's the thing, the bug was reproducible with default config before #432, but that fix removed its trigger (outstanding requests can no longer exceed the responder limit when windows match). Since this PR merges both send paths into one function, the aggregation half can't fire on its own anymore. The window override recreates the same trigger condition #432 eliminated, so the test actually exercises the drop-and-wedge path and proves the new code survives it.

Can you explain what you mean by:

drop-and-wedge

?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Drop the requests that are coming from the peer nodes.
wedge: keeping the node behind (lagging forever)

@yacovm yacovm Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this PR merges both send paths into one function, the aggregation half can't fire on its own anymore.

I do not expect to create a scenario that is influenced by existing production code changes from this PR.

Is it not possible to create a test with two epochs or more that if I completely revert all production code changes and leave the test intact, the test will fail because of the reason the PR claims to be the issue?

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.

3 participants