pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Marina Polyakova <m.polyakova@postgrespro.ru>
To: pgsql-bugs@lists.postgresql.org
Subject: Bug in pg_upgrade live check right after starting the old server on Windows
Date: Sat, 17 Sep 2022 15:12:03 +0300
Message-ID: <c578ccfcf0691d87cae3aef86ec81e2b@postgrespro.ru> (raw)

Hello!

I got a problem on a Windows machine on master [1] when running 
pg_upgrade live check right after starting the old server (note that 
instead of the expected banner 'Performing Consistency Checks on Old 
Live Server' there's a banner 'Performing Consistency Checks'):

> bin\initdb.exe -D data_old
> bin\initdb.exe -D data_new
> bin\pg_ctl.exe -D data_old -l logfile_old start && bin\pg_upgrade.exe 
> -d C:\postgrespro\inst\data_old -D C:\postgrespro\inst\data_new -b 
> C:\postgrespro\inst\bin -B C:\postgrespro\inst\bin -p 5432 --check 
> --retain && bin\pg_ctl.exe -D data_old stop
waiting for server to start.... done
server started
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
...
*Clusters are compatible*
pg_ctl: PID file "data_old/postmaster.pid" does not exist
Is server running?

 From pg_upgrade_server_start.log with debug output (see 
diff_debug_pg_ctl_start.patch):

command: "C:/postgrespro/inst/bin/pg_ctl" -w -l 
"C:/postgrespro/inst/data_new/pg_upgrade_output.d/20220917T044300.887/log/pg_upgrade_server.log" 
-D "C:/postgrespro/inst/data_old" -o "-p 5432 -b " start >> 
"C:/postgrespro/inst/data_new/pg_upgrade_output.d/20220917T044300.887/log/pg_upgrade_server_start.log" 
2>&1
pg_ctl: another server might be running; trying to start server anyway
pg_ctl: do_start old_pid 6100
waiting for server to start...pg_ctl: wait_for_postmaster_start pmpid 
6100
pg_ctl: wait_for_postmaster_start pmstart 1663414980
pg_ctl: wait_for_postmaster_start start_time 1663414982
  done
server started

And adding a sufficient pause between the old server start and 
pg_upgrade solves the problem:

> bin\pg_ctl.exe -D data_old -l logfile_old start && sleep 2 && 
> bin\pg_upgrade.exe -d C:\postgrespro\inst\data_old -D 
> C:\postgrespro\inst\data_new -b C:\postgrespro\inst\bin -B 
> C:\postgrespro\inst\bin -p 5432 --check --retain && bin\pg_ctl.exe -D 
> data_old stop
waiting for server to start.... done
server started
Performing Consistency Checks on Old Live Server
------------------------------------------------
Checking cluster versions                                   ok
...
*Clusters are compatible*
waiting for server to shut down.... done
server stopped

The patch to check the previous postmaster pid when running pg_ctl start 
[2] works for me, but it was reverted [3]...

[1] 
https://github.com/postgres/postgres/commit/fdd8937c071e85e2b7606939fb28284f008e15d1
[2] 
https://github.com/postgres/postgres/commit/6a5084eed49552bfc8859c438c8d74ad09fc5d3f
[3] 
https://github.com/postgres/postgres/commit/f38291e927fa8c04eb772e6a17a3dd44da2b69e8

-- 
Marina Polyakova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachments:

diff_debug_pg_ctl_start.patch (text/x-diff, 937B) download diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 9291c61d000feeb2443b49f8739809a433a7781d..554dfbd2f847c830eb3ca6fc6677b95711f32ef9 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -622,6 +622,11 @@ wait_for_postmaster_start(pgpid_t pm_pid, bool do_checkpoint) */ pmpid = atol(optlines[LOCK_FILE_LINE_PID - 1]); pmstart = atol(optlines[LOCK_FILE_LINE_START_TIME - 1]); + + pg_log_info("wait_for_postmaster_start pmpid %ld", pmpid); + pg_log_info("wait_for_postmaster_start pmstart %lu", pmstart); + pg_log_info("wait_for_postmaster_start start_time %lu", start_time); + if (pmstart >= start_time - 2 && #ifndef WIN32 pmpid == pm_pid @@ -936,6 +941,7 @@ do_start(void) write_stderr(_("%s: another server might be running; " "trying to start server anyway\n"), progname); + pg_log_info("do_start old_pid %ld", old_pid); } read_post_opts();

Message-ID: <c578ccfcf0691d87cae3aef86ec81e2b@postgrespro.ru>
Permalink:  ../c578ccfcf0691d87cae3aef86ec81e2b@postgrespro.ru/
Also on:    postgresql.org/message-id/c578ccfcf0691d87cae3aef86ec81e2b@postgrespro.ru

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: m.polyakova@postgrespro.ru, pgsql-bugs@lists.postgresql.org
  Subject: Re: Bug in pg_upgrade live check right after starting the old server on Windows
  In-Reply-To: <c578ccfcf0691d87cae3aef86ec81e2b@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox