Skip to content

HA: concurrent transactions on a shared follower Database handle corrupt records and lose committed writes #5503

Closed

Description

@robfrank

Split out of #5492. Found while building a reproduction for that issue; it is not attributable to materialized views (the A/B control with no view fails identically), so it is filed on its own.

Summary

On a 3-node Raft cluster, issuing concurrent single-record transactions against a follower's embedded Database handle corrupts records and loses a large fraction of committed writes. The engine logs invalid record sizes and silently deletes the affected records:

SEVER [LocalBucket] Invalid record size 570425357 for record #29:20: deleting record
SEVER [LocalBucket] Invalid record size 536870925 for record #28:27: deleting record

Typical outcome: 450 transactions all report success, and a node ends up holding 138-175 of them, with 200+ corruption log lines per run.

Scope - what does and does not fail

Three variants, same 3-node in-process harness (BaseRaftHATest, getServerCount() == 3):

Writers Target Result
3 threads, shared handle follower fails - 138-175 of 450 records, 200+ Invalid record size
1 thread follower passes - 200/200 on all three nodes, zero corruption
3 threads, shared handle leader passes - all records present, zero corruption

So it needs concurrency and a follower. Concurrency alone against the leader is fine, and a follower alone is fine.

Ruled out:

  • Not the materialized view: an identical control arm with no view over the type fails the same way.
  • Not indexes: removing the UNIQUE index on the written type changed nothing (219 corruption lines without it).

Reproduction

Attached below. Extends BaseRaftHATest, 3 nodes, 3 threads x 150 single-record transactions through getServer((leaderIndex + 1) % 3).getDatabase(...), then compares per-node counts.

Reproduction test
final int leaderIndex = findLeaderIndex();
final Database leader = getServer(leaderIndex).getDatabase(getDatabaseName());
leader.command("sql", "CREATE DOCUMENT TYPE Unviewed");
waitForAllServers();

// Writes go through a FOLLOWER, from 3 concurrent threads sharing this handle.
final Database follower = getServer((leaderIndex + 1) % getServerCount()).getDatabase(getDatabaseName());
// ... 3 threads x 150 iterations of:
//     follower.transaction(() -> follower.newDocument("Unviewed").set("value", v).save());

waitForAllServers();
for (int i = 0; i < getServerCount(); i++)
  assertThat(countType(getServer(i).getDatabase(getDatabaseName()), "Unviewed")).isEqualTo(450L);
// -> AssertionFailedError: expected 450L but was 173L

Open question

It is not established whether sharing a single embedded Database handle across threads against a follower is a supported pattern. If it is not, the defect is arguably that it corrupts data instead of rejecting the usage - committed transactions reporting success while their records are later deleted as malformed is a bad failure mode either way.

The Invalid record size values (536870925, 570425357) look like a length field read from the wrong offset rather than random garbage, which would point at the follower-side forwarding path writing or reading a record frame inconsistently under concurrency.

Activity

  1. self-assigned this
    on Jul 28, 2026
  2. added this to the 26.8.1 milestone on Aug 1, 2026
  3. added a commit that references this issue on Aug 14, 2026
  4. added a commit that references this issue on Sep 1, 2026
  5. added a commit that references this issue on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions