Skip to content

Problem: apps can't read from a node while it takes a snapshot #1494

Description

@MicBun

When a node takes its scheduled state-sync snapshot, I want it to keep committing blocks and answering reads, so it does not fall 20 minutes behind the chain and out of service every time.

What happens

  1. The snapshot runs inside the block commit. Commit holds the block processor's lock for the whole call and calls snapshotDB, which runs pg_dump to the end before it returns. The node commits no block until the dump is done.
  2. Every read that needs the node's status waits with it. user.call, user.health and /api/v1/health go through Status, which reads the network parameters under the block processor's read lock.
  3. snapshotDB already hands pg_dump its own database snapshot, so the dump does not need the lock to see a consistent state.

On the mainnet sentry that makes the snapshots, on 24 Nov 2026 (UTC):

  • 04:32:41.706: committed block 3227967.
  • 04:32:42.767: pg_dump started for block 3227968.
  • 04:53:39.718: pg_dump finished, 212 chunks and 3.38 GB.
  • 04:53:39.856: four RPC handlers that the dump had blocked could finally answer, and each failed with Write error: http: Handler timeout, because their callers had already been sent an RPC timeout error after 10 s.
  • 04:53:39.865: committed block 3227968, 20 min 58 s after the block before it.
  • 04:54:51.403: back at the tip, after block syncing 3227969 to 3228145 in 10.5 s.

The leader and the other sentry committed every block in that window, and the mainnet gateway returned no 5xx. The same happens on every snapshot, once every 14,400 blocks. The snapshots at block 3199168 (17 Nov, 03:59 to 04:20 UTC) and block 3213568 (21 Nov, 21:20 to 21:41 UTC) took the same 21 minutes. Since 6 Nov the node's stall alert has fired at ten snapshots, each time reporting a height less than 80 blocks below the snapshot's.

Scope

  • Take the snapshot off the commit path: keep the database snapshot that snapshotDB opens, release the lock, and run pg_dump in the background, one dump at a time.
  • Until that ships, weigh moving the snapshots to a node that serves no reads, or a larger recurring_height, against the catch-up length that a snapshot's age sets.
  • Answering Status without the lock is covered by the related read-lock issue.
  • The change itself goes in trufnetwork/kwil-db.

Acceptance criteria

  • On a node with mainnet-sized data and snapshots on, the snapshot block commits in its usual time, and the next blocks commit while pg_dump runs.
  • During the dump, user.health and GET /api/v1/health answer in their usual time.
  • A node restored from the new snapshot by state sync reaches the same app hash as one restored from a snapshot made today.

Related

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions