Skip to content

TransactionalStream fails with PartialReorgError when resuming after a reorg inside its last watermark #36

Open

Description

@benface

With #35, ProtocolStream detects reorgs that happened while a stream was stopped. But when TransactionalStream resumes after a reorg that starts inside its last watermark's range, it fails with PartialReorgError instead of recovering.

Versions: amp-typescript ca6978e (the #35 branch), ampd v0.0.42 over an Anvil chain.

To reproduce:

  1. Stream a dataset with TransactionalStream until it commits a multi-block watermark. For me, [0-50] and [51-53].
  2. Stop the stream, reorg the chain 2 blocks back with anvil_reorg, and mine a block.
  3. Resume with the same state store. Amp re-sends from block 52, the first reorged block, and the stream fails with PartialReorgError.

A 3-block reorg works, because it starts at the watermark's first block.

Within a session this doesn't happen, because Amp re-sends the whole microbatch from the start of the affected range. On resume it starts at the first reorged block, so any reorg that starts inside a multi-block last watermark hits this. Wide watermarks are common after a catch-up, or when several blocks land at once.

The check that fails:

const partialNetwork = checkPartialReorg(recoveryRanges, invalidation)
if (partialNetwork !== undefined) {
return yield* new PartialReorgError({
reason: "Recovery point doesn't align with reorg boundary",
network: partialNetwork
})
}

I'd expect it to do what Amp's docs say (step 4): invalidate everything after an earlier cursor and reconnect from it with amp-resume: https://github.com/edgeandnode/amp/blob/e0d7a394c00a4fd5a113b3cb95fc8166fae45a58/docs/reorgs.md?plain=1#L62

Amp's Rust client has the same check and doesn't reconnect either: https://github.com/edgeandnode/amp/blob/e0d7a394c00a4fd5a113b3cb95fc8166fae45a58/crates/client-flight/src/transactional.rs#L505

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions