Skip to content

fix(macos): end a COPY at once on Stop and move the SQL import bar with the bytes read - #4263

Merged
datlechin merged 2 commits into
mainfrom
fix/d-copyin2
Nov 13, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/d-copyin2

Conversation

@datlechin

@datlechin datlechin commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • D-14, Stop: a PostgreSQL copy-in (SQL import and the editor) now ends at once on Stop. The copy runs libpq nonblocking from its statement to its result, waiting in 100 ms slices, so Stop is seen while the server takes no data. Stop sends CopyFail ("canceled by user"); when the server has not answered a slice later (a row lock wait, or rows a proxy still holds), the copy sends one cancel request and waits for it to reach the server, so it cannot stop the statement after the COPY. A Stop while the COPY waits to start sends the cancel request at once. The results are read to the end and the session takes the next statement.
  • cancelCurrentQuery no longer sends its own queued cancel request while a copy-in runs, for the same reason.
  • SQL import: Stop during a COPY ends the COPY and stops the run with a rollback, as a failed statement would. No Stop Import? question: the block cannot be resumed, and an owned transaction can only roll back. A COPY in the user's own transaction leaves it aborted; the session tracker reads that after the turn, and the stop result says to roll it back.
  • SQL import progress: the bar follows the bytes read from the file (at most 99% while statements still run); the count beside it still counts statements. Row imports are unchanged.
  • Probe apple/scripts/probes/check-postgresql-copy-in.sh: Stop cases added. libpq 17.4 against PostgreSQL 17.11 and 18.6: a Stop mid-stream ends in 30 to 300 ms (CopyFail alone took up to 1.4 s with rows in buffers); during a row lock wait CopyFail alone stays unanswered, and one cancel request ends it in about 300 ms; the session runs the next statement, an open block is left aborted, no row stays.
  • Rust core (feat(core): load imported COPY rows through copy-in on a fixed tokio-postgres #4258): no change. Its import already races Stop against the piece wait and the send, waits for its cancel request before the ROLLBACK, and its bar is file bytes read.
  • Docs: docs(features): Stop ends a COPY at once, SQL import bar follows bytes read docs#234

Test plan

  • New: LibPQCopyInTests stopReachesAServerThatTakesNoData (scripted server that reads nothing until a cancel request; the old blocking loop never ends the copy) and stopBeforeTheCopyStarts; stopEndsTheCopy now stops through cancelCurrentQuery and checks that no cancel request was sent. ImportRunTests (Stop during, before and after a COPY, teardown), ImportDataSinkAdapterCopyTests.stopCancelsTheCopy, SQLFileParserBytesReadTests, ImportStateTransferProgressTests, TransferProgressTests.fileFractionDrivesTheBar.
  • verify.sh test on the 13 suites around import and copy-in: 163 passed. Build, plugins and lint pass.
  • Probe run against PostgreSQL 17.11 and 18.6 in Docker: 32 checks pass on each.

@datlechin
datlechin enabled auto-merge (squash) November 13, 2026 09:24
@datlechin
datlechin merged commit 6208d4b into main Nov 13, 2026
11 checks passed
@datlechin
datlechin deleted the fix/d-copyin2 branch November 14, 2026 21:29
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