postgresql 10 – Cancelling an upgrade/migration from Postgre 10 to 12

I’m using these command to upgrade, it runs well until 9GB it became really slow:

# sudo pg_dropcluster 12 main --stop
# sudo pg_upgradecluster 10 main
Restarting old cluster with restricted connections...
Notice: extra pg_ctl/postgres options given, bypassing systemctl for start operation
Creating new PostgreSQL cluster 12/main ...
/usr/lib/postgresql/12/bin/initdb -D /var/lib/postgresql/12/main --auth-local peer --auth-host md5 --encoding UTF8 --lc-collate en_CA.UTF-8 --lc-ctype en_CA.UTF-8
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locales
  CTYPE:    en_CA.UTF-8
  TIME:     C.UTF-8
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/12/main ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Jakarta
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctlcluster 12 main start

Ver Cluster Port Status Owner    Data directory              Log file
12  main    5434 down   postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log

Starting new cluster...
Notice: extra pg_ctl/postgres options given, bypassing systemctl for start operation
Roles, databases, schemas, ACLs...
(1 row)

(1 row)

(1 row)

(1 row)

Fixing hardcoded library paths for stored procedures...
Upgrading database postgres...
Analyzing database postgres...
Fixing hardcoded library paths for stored procedures...
Upgrading database template1...
Analyzing database template1...
Fixing hardcoded library paths for stored procedures...
Upgrading database geo...

The watch:

Every 2.0s: df -t ext4 -h ; du -s /var/lib/postgresql/10 /var/lib/postgresql/12/                                    data: Fri Jan  1 02:21:03 2021

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        56G   32G   22G  60% /
/dev/vdb1        98G   73G   21G  78% /mnt/vdb1
11376348        /var/lib/postgresql/10
9466976 /var/lib/postgresql/12/
# ps -e -o pcpu,pmem,rss,comm,args --sort=pcpu | grep postgres
 0.0  0.0  3404 postgres        postgres: 10/main: logger process   
 0.0  0.5 23684 postgres        postgres: 10/main: checkpointer process   
 0.0  0.2 12044 postgres        postgres: 10/main: writer process   
 0.0  0.5 20260 postgres        postgres: 10/main: wal writer process   
 0.0  0.1  5608 postgres        postgres: 10/main: autovacuum launcher process   
 0.0  0.0  3812 postgres        postgres: 10/main: stats collector process   
 0.0  0.0  4004 postgres        postgres: 10/main: bgworker: logical replication launcher   
 0.0  0.5 23976 postgres        /usr/lib/postgresql/12/bin/postgres -D /var/lib/postgresql/12/main -c config_file=/etc/postgresql/12/main/postgresql.conf -c hba_file=/tmp/pg_hba.LVD6EB.conf
 0.0  0.3 12348 postgres        postgres: 12/main: autovacuum launcher   
 0.0  0.1  6732 postgres        postgres: 12/main: logical replication launcher   
 0.0  0.0   672 grep            grep --color=auto postgres
 0.1  1.3 52672 postgres        /usr/lib/postgresql/10/bin/postgres -D /var/lib/postgresql/10/main -c config_file=/etc/postgresql/10/main/postgresql.conf -c hba_file=/tmp/pg_hba.LVD6EB.conf
 0.1  0.1  5716 postgres        postgres: 12/main: stats collector   
 0.2  0.0  3848 watch           watch -dc df -t ext4 -h ; du -s /var/lib/postgresql/10 /var/lib/postgresql/12/
 0.4  3.5 144416 postgres       postgres: 12/main: checkpointer   
 1.1  3.5 141528 postgres       postgres: 12/main: background writer   
 2.2  0.2  8392 pg_restore      /usr/lib/postgresql/12/bin/pg_restore -h /var/run/postgresql -p 5434 --data-only -d geo --disable-triggers --no-data-for-failed-tables
 2.3  0.2  9884 postgres        postgres: 12/main: walwriter   
11.4  0.3 14160 pg_dump         /usr/lib/postgresql/12/bin/pg_dump -h /var/run/postgresql -p 5432 -Fc --quote-all-identifiers geo
19.1 27.0 1089624 postgres      postgres: 10/main: postgres geo (local) COPY
55.9  3.8 155360 postgres       postgres: 12/main: postgres geo (local) COPY

The question is.. if I cancel the upgrade (Ctrl+C) since it’s already take too much time unlike when I upgrade postgresql 9.6 to 10 that only less than an hour with similar dataset (and not sure when it will end, there’s 2 hours of data loss/not inserted because of upgrading), what would be happened? (I have 1GB xz-ed backup from 2 hours ago)


apparently it’s migrating on another folder too (I put some other tablespace on different directory back then because of running out of main partition space), so it’s progressing well and doesn’t stuck:

# du -s /mnt/vdb1/pgdata2/*/
41035516        /mnt/vdb1/pgdata2/PG_10_201707211/
26548836        /mnt/vdb1/pgdata2/PG_12_201909212/


it’s completed around 3 hours for 39 GB of data ‘__’)