Skip to content

fix: don't start counting the backup's rows when stopped while preparing the list - #65

Merged
supertj merged 1 commit into
mainfrom
feature/row-count-abort-race
Nov 7, 2026
Merged

supertj merged 1 commit into
mainfrom
feature/row-count-abort-race

Conversation

@supertj

@supertj supertj commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

What

Follow-up to #64. If the caller stops countRowsInDump while it is making the temp dir or writing the TABLE DATA list, the abort event has already fired by the time the listener is attached, so the pg_restore --data-only pass would start anyway and read the whole dump before verifyRestored could return.

countRowsInDump now checks the signal again right before spawning. That check and attaching the listener happen in the same tick, so there's no gap left.

Tests

  • test/drill-row-counts.test.js: a signal that reads as stopped as soon as the temp dir exists, with pg_restore wrapped to log every call. Returns null and the log has the --list call but no --data-only call. Without the fix this assertion fails.
  • Full suite: 452 tests, 452 pass, 0 fail (npm test on 61d7cc8).

No preview environment for the CLI; verified by the tests above. 2.11.0 isn't published yet, so no version bump.

@supertj
supertj merged commit cda459d into main Nov 7, 2026
1 check passed
@supertj
supertj deleted the feature/row-count-abort-race branch November 7, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant