Skip to content

add emergency-stop.sh to halt a running migration#66

Open
DmitriiAn wants to merge 1 commit into
mainfrom
feat/emergency-stop
Open

add emergency-stop.sh to halt a running migration#66
DmitriiAn wants to merge 1 commit into
mainfrom
feat/emergency-stop

Conversation

@DmitriiAn

Copy link
Copy Markdown
Contributor

What

Adds pgcopydb-helpers/emergency-stop.sh — a one-shot emergency halt for a
running migration

Why

There was no safe, single command to stop a migration in an emergency (e.g. the
source DB is overloaded during the initial copy). Users had to find PIDs and
kill them by hand under pressure.

Behavior

  • Confirms first, printing the consequences and live progress/phase read
    straight from the pgcopydb SQLite catalog.
  • Stops the whole process tree: SIGTERM the process group (pgcopydb is its own
    group leader via setpgrp), then escalate automatically to repeated SIGKILL.
  • Never leaves pgcopydb running silently: if anything survives SIGTERM + repeated
    SIGKILL, it prints a loud warning with the surviving PIDs and manual
    remediation, and exits 1.
  • Stop-only: does not drop the replication slot or touch the target, so the
    migration stays resumable (resume-cdc.sh if the initial COPY finished, else
    resume-migration.sh). Prints next-steps for resume vs. abandon.
Screenshot 2026-06-22 at 12 41 56 Screenshot 2026-06-22 at 12 42 43

Safety

  • Matches pgcopydb by exact process name (pgrep -x); never prints command lines
    (avoids leaking PGURI passwords); requires no ~/.env.
  • Guard ensures it never signals its own process group.

@DmitriiAn DmitriiAn requested a review from teknogeek0 June 22, 2026 11:48
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