Skip to content

fix: gap-fill every requested number the store cannot resend - #358

Open
fraVlaca wants to merge 1 commit into
Validus-Risk-Management:mainfrom
fraVlaca:fix/resend-gap-fill-missing-sequence-numbers
Open

fraVlaca wants to merge 1 commit into
Validus-Risk-Management:mainfrom
fraVlaca:fix/resend-gap-fill-missing-sequence-numbers

Conversation

@fraVlaca

Copy link
Copy Markdown

Problem

Two issues when answering a ResendRequest:

  1. Numbers the store does not return are skipped silently. The store may not hold every number in the requested range (messages that were never persisted, or a store that prunes old messages). The engine resends what it has and says nothing about the rest, so the counterparty keeps waiting for those numbers and cannot resynchronise.
  2. The final SequenceReset-GapFill after trailing admin messages uses the last skipped number as its NewSeqNo. For a store holding 1 (application), 2 and 3 (heartbeats) and a request for 1..3, the engine resends 1 and then sends a GapFill with MsgSeqNum 2 and NewSeqNo 3. NewSeqNo should be 4, the number after the gap, so the counterparty is told to expect a number it has just been told to skip.

Change

In resend_messages:

  • The function tracks the next number the counterparty is owed. A stored message whose number is above it opens a gap-fill, exactly as an admin message does, so missing numbers are filled together with any adjacent admin messages.
  • The final GapFill covers trailing admin messages and any requested numbers the store did not return. Its NewSeqNo is the number after the requested range: the end of the request, which on_resend_request already clamps to the last sent number, plus one.

Resent application messages and gap fills between them are unchanged.

Tests

Unit tests in session/outbound.rs, using the existing FakeMessageStore:

  • resend_gap_fills_numbers_missing_from_the_store: a store holding 2 and 4 of a 1..5 request produces GapFill 1→2, resend 2, GapFill 3→4, resend 4, GapFill 5→6.
  • resend_trailing_gap_fill_points_past_the_requested_range: application 1, then heartbeats 2 and 3, produces resend 1 and GapFill 2→4.
  • resend_with_nothing_stored_gap_fills_the_whole_range: an empty store answers 1..3 with GapFill 1→4.

The existing integration test for admin gap fills keeps its expectations.

I could not build this workspace locally, so I am relying on CI for the compile, clippy and test run.

This contribution is offered under the project's MIT licence.

When answering a ResendRequest, numbers the store does not return (never
stored, or pruned) were skipped silently: the counterparty kept waiting for
them and could not resynchronise. They are now gap-filled like admin
messages.

The final SequenceReset-GapFill after trailing admin messages also named
the last skipped number as NewSeqNo instead of the number after it, so the
counterparty was told to expect a number it had just been told to skip. It
now points past the requested range.
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.

1 participant