Skip to content

tx_check: avoid nested read tx when loading freelist during Check#1189

Open
VedantMadane wants to merge 1 commit intoetcd-io:mainfrom
VedantMadane:fix-877-check-freelist-deadlock
Open

tx_check: avoid nested read tx when loading freelist during Check#1189
VedantMadane wants to merge 1 commit intoetcd-io:mainfrom
VedantMadane:fix-877-check-freelist-deadlock

Conversation

@VedantMadane
Copy link
Copy Markdown

@VedantMadane VedantMadane commented Apr 12, 2026

Summary

Rebuilding an unsynced freelist from Tx.check used freepages(), which opened a nested read-only transaction via beginTx. That interacted badly with callers such as etcd snapshot Status, which runs tx.Check() inside db.View on one goroutine while the check goroutine tried to start another read transaction (issue #877).

Change

  • Add freepagesWithTx(*Tx) and use the active check transaction for the scan instead of opening a nested transaction.
  • Extend loadFreelist(sharedReadTx *Tx); Tx.check passes tx, Open preload passes nil.

Testing

go test ./... in the root module (core packages pass; failpoint package needs gofail build tags in this environment).

Fixes #877

@k8s-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: VedantMadane
Once this PR has been reviewed and has the lgtm label, please assign spzala for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Check already runs on a read transaction (often from View on another
goroutine). Rebuilding an unsynced freelist called beginTx from freepages,
which could block when combined with the outer View transaction.

Pass the active Tx into loadFreelist so reconstruction uses freepagesWithTx
and skips opening a nested read transaction (fixes etcd-io#877).

Signed-off-by: Vedant Madane <6527493+VedantMadane@users.noreply.github.com>
@VedantMadane VedantMadane force-pushed the fix-877-check-freelist-deadlock branch from da20b77 to 574b87e Compare April 12, 2026 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Check of corrupted file deadlocks

2 participants