Re: pg_upgrade test failure
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Justin Pryzby <pryzby@telsasoft.com>,
Michael Paquier <michael@paquier.xyz>, pgsql-hackers@lists.postgresql.org, Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: 2023-02-01T01:44:53Z
Lists: pgsql-hackers
On Wed, Feb 1, 2023 at 10:08 AM Thomas Munro <thomas.munro@gmail.com> wrote: > On Wed, Feb 1, 2023 at 10:04 AM Andres Freund <andres@anarazel.de> wrote: > > Maybe we should just handle it by sleeping and retrying, if on windows? Sad to even propose... > > Yeah, that's what that code I posted would do automatically, though > it's a bit hidden. The second attempt to unlink() would see delete > already pending, and activate its secret internal sleep/retry loop. OK, I pushed that. Third time lucky? I tracked down the discussion of that existing comment about pg_ctl, which comes from the 9.2 days: https://www.postgresql.org/message-id/flat/5044DE59.5020500%40dunslane.net I guess maybe back then fopen() was Windows' own fopen() that wouldn't allow two handles to a file at the same time? These days we redirect it to a wrapper with the magic "shared" flags, so the kluge installed by commit f8c81c5dde2 may not even be needed anymore. It does demonstrate that there are long standing timing races around log files, process exit and wait-for-shutdown logic, though. Someone who develops for Windows could probably chase this right down, and make sure that we do certain things in the right order, and/or find better kernel facilities; at a wild guess, something like OpenProcess() before you initiate shutdown, so you can then wait on its handle, for example. The docs for ExitProcess() make it clear that handles are synchronously closed, so I think it's probably just that our tests for when processes have exited are too fuzzy.
Commits
-
ci: freebsd: stop postgres instance on failure, to prevent log upload failures
- 209f0f0e8516 16.0 landed
-
Try to fix pg_upgrade test on Windows, again.
- c28911750527 16.0 landed
-
Refactor rmtree() to use get_dirent_type().
- 54e72b66ed1a 16.0 landed
-
Fix unlink() for STATUS_DELETE_PENDING on Windows.
- e109e43921d2 16.0 landed
-
Move any remaining files generated by pg_upgrade into an internal subdir
- ee5353abb612 16.0 cited
-
Make unlink() work for junction points on Windows.
- f357233c9db8 16.0 cited
-
pg_upgrade: Move all the files generated internally to a subdirectory
- 38bfae365266 15.0 cited
-
In pg_upgrade, try a few times to open a log file.
- f8c81c5dde23 9.3.0 cited