I'm running an sql script on a Amazon Aurora Postgresql 13.4 cluster. I expect it to take ~8 hours to run, so I'm running this on a Kubernetes cluster, so if my laptop falls asleep it doesn't interrupt the script.
After about three hours I see in the logs:
Cancel request sent
psql:migration-script.sql:18: ERROR: canceling statement due to user request
Who or what is cancelling this script? This script shouldn't be cancelled.
I'm running via:
kubectl run psqlrun --restart=Never --image=<migration-script-docker-image> \
--env="PGPASSWORD=$POSTGRES_PASSWORD" \
-- psql -h $POSTGRES_HOST -U $POSTGRES_USER -d <db-name> -a -f migration-script.sql
The Docker image I'm using is built with this simpler Dockerfile:
FROM postgres:13-alpine
COPY migration-script.sql .
CodePudding user response:
The psql
process was sent a SIGINT signal. It received it and then sent a special cancel message to the database server (by opening a side connection just for that purpose).
Usually receiving a SIGINT (in Linux) means you pressed ctrl-C while in a terminal window with that process being the foreground process. But you can also deliver SIGINT to a process in other ways, like using the kill
command with the process id and specifying SIGINT as the signal to send (it is not the default signal). Normally you can't signal processes other than your own, other than by being root.
Maybe docker/kubectl arranges to send SIGINT to processes under its auspices under some circumstances. In any event, this is being driven by something on the machine where psql is running, not on the database server side.