Skip to content

Raft: identical keyless writes share a queue envelope; the second can fail with 422 #1931

Closed

Description

@bplatz

Problem

On a Raft cluster, sending the same write twice in quick succession without an idempotency key can fail the second with a 422:

submission poisoned: StagingFailed { error: "CAS read of request_cid failed: Not found: fluree:file://<ledger>/<branch>/txn/<hash>.json ...", attempts: 3 }

The first write commits and the second is lost. A client retrying an identical JSON-LD insert hits this, as does any other body kind. It showed up as a roughly 1-in-6 flake in a grp_raft test that re-sent an identical /sync body through a follower.

Cause

QueuedTransactor::enqueue_and_await writes the encoded QueuedRequest to CAS and uses its content hash as request_cid. The server doesn't set CommitOptsRequest.timestamp (only opts.eventTime does), so two identical keyless submissions encode to identical bytes and share one envelope blob.

A keyless entry's envelope is released when its head applies (Response::HeadApplied { released_envelope: Some(request_cid) }, released by the wrapper on each node). So the first submission's release can delete the blob after the second submission has written the same CID and before its worker reads it.

The doc comment on submit_and_await says "unique timestamps per attempt mean retries hash to distinct request_cids". That doesn't hold on this path.

Possible fix

Make every envelope unique, for example with a per-submission nonce or receipt timestamp carried in QueuedTransact and excluded from body_cid, so body-hash dedup is unaffected. Alternatively, reference-count envelope releases. A regression test can submit the same keyless body twice back to back through TestCluster and assert both succeed.

Activity

  1. added
    bug
    P2
    area:server
    on Sep 25, 2026
  2. added this to the 5.0.0 milestone on Nov 20, 2026
  3. bplatz commented on Nov 22, 2026

    @bplatz
    ContributorAuthor

    Fixed by #2275 (86ebb9f), released in v4.2.6 and later and on next (v5.0.0-alpha.3 onward). enqueue_and_await stamps each submission with a fresh ULID before it writes the envelope, so two identical keyless submissions no longer share a request_cid. The idempotency body hash leaves the stamp out. Covered by an_identical_queued_request_keeps_its_envelope and a_retry_that_joins_a_queued_entry_releases_its_own_envelope in fluree-db-consensus/tests/it_embedded_node.rs.

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

    P2area:serverbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions