Re: [HACKERS] Weaker shmem interlock w/o postmaster.pid
Noah Misch <noah@leadboat.com>
Attachments
- PGSharedMemoryCreate-safety-v4.patch (text/plain) patch v4
- PGSharedMemoryCreate-safety-v4-incr.patch (text/plain) patch v4
On Thu, Apr 04, 2019 at 07:53:19AM -0700, Noah Misch wrote:
> On Wed, Apr 03, 2019 at 07:05:43PM -0700, Noah Misch wrote:
> > Pushed, but that broke two buildfarm members:
> > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=idiacanthus&dt=2019-04-04%2000%3A33%3A14
> > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=komodoensis&dt=2019-04-04%2000%3A33%3A13
> >
> > I think the problem arose because these animals run on the same machine, and
> > their test execution was synchronized to the second. Two copies of the new
> > test ran concurrently. It doesn't tolerate that, owing to expectations about
> > which shared memory keys are in use. My initial thought is to fix this by
> > having a third postmaster that runs throughout the test and represents
> > ownership of a given port. If that postmaster gets something other than the
> > first shm key pertaining to its port, switch ports and try again.
> >
> > I'll also include fixes for the warnings Andres reported on the
> > pgsql-committers thread.
>
> This thread's 2019-04-03 patches still break buildfarm members in multiple
> ways. I plan to revert them. I'll wait a day or two before doing that, in
> case more failure types show up.
Notable classes of buildfarm failure:
- AIX animals failed two ways. First, I missed a "use" statement such that
poll_start() would fail if it needed more than one attempt. Second, I
assumed $pid would be gone as soon as kill(9, $pid) returned[1].
- komodoensis and idiacanthus failed due to 16ee6ea not fully resolving the
problems with concurrent execution. I reproduced the various concurrency
bugs by setting up four vpath build trees and looping the one test in each:
for dir in 0 1 2 3; do (until [ -f /tmp/stopprove ]; do make -C $dir/src/test/recovery installcheck PROVE_TESTS=t/017_shm.pl; done) & done; wait; rm /tmp/stopprove
- elver failed due to semaphore exhaustion. I'm reducing max_connections.
- lorikeet's FailedAssertion("!(vmq->mq_sender == ((void *)0))" looked
suspicious, but this happened six other times in the past year[2], always on
v10 lorikeet.
- Commit 0aa0ccf, a wrong back-patch, saw 100% failure of the new test.
While it didn't cause a buildfarm failure, I'm changing the non-test code to
treat shmat() EACCESS as SHMSTATE_FOREIGN, so we ignore that key and move to
another. In the previous version, I treated it as SHMSTATE_ANALYSIS_FAILURE
and blocked startup. In HEAD today, shmat() failure blocks startup if and
only if we got the shmid from postmaster.pid; there's no distinction between
EACCES and other causes.
Attached v4 fixes all the above. I've also attached the incremental diff
versus the code I reverted.
[1] POSIX says "sig or at least one pending unblocked signal shall be
delivered to the sending thread before kill() returns." I doubt the
postmaster had another signal pending often enough to explain the failures, so
AIX probably doesn't follow POSIX in this respect.
[2] All examples in the last year:
sysname │ stage │ branch │ snapshot │ url
──────────┼────────────────┼───────────────┼─────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────
lorikeet │ InstallCheck-C │ REL_10_STABLE │ 2018-05-04 09:49:55 │ https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=lorikeet&dt=2018-05-04%2009:49:55
lorikeet │ InstallCheck-C │ REL_10_STABLE │ 2018-05-05 13:15:24 │ https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=lorikeet&dt=2018-05-05%2013:15:24
lorikeet │ InstallCheck-C │ REL_10_STABLE │ 2018-05-06 09:33:35 │ https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=lorikeet&dt=2018-05-06%2009:33:35
lorikeet │ InstallCheck-C │ REL_10_STABLE │ 2018-05-15 20:52:36 │ https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=lorikeet&dt=2018-05-15%2020:52:36
lorikeet │ Check │ REL_10_STABLE │ 2019-02-20 10:40:40 │ https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=lorikeet&dt=2019-02-20%2010:40:40
lorikeet │ InstallCheck-C │ REL_10_STABLE │ 2019-03-06 09:31:24 │ https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=lorikeet&dt=2019-03-06%2009:31:24
lorikeet │ Check │ REL_10_STABLE │ 2019-04-04 09:47:02 │ https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=lorikeet&dt=2019-04-04%2009:47:02
Commits
-
Probe only 127.0.0.1 when looking for ports on Unix.
- 1ed42e50e963 9.6.14 landed
- 8c7a8e19bb17 10.9 landed
- 1f3bcb497200 11.4 landed
- 8efe710d9c84 12.0 landed
-
Don't write to stdin of a test process that could have already exited.
- e12a4726127b 12.0 cited
-
Test both 0.0.0.0 and 127.0.0.x addresses to find a usable port.
- 9f65081cf74b 9.6.13 landed
- 4543ef36f0ef 10.8 landed
- 0bdf6d635e42 11.3 landed
- 4ab02e815627 12.0 landed
-
MSYS: Translate REGRESS_SHLIB to a Windows file name.
- 31e2caaceea9 11.3 landed
- 9daefff12260 12.0 landed
-
MSYS: Skip src/test/recovery/t/017_shm.pl.
- 6b7906e1d9e7 9.6.13 landed
- 2bc0474792e3 10.8 landed
-
When Perl "kill(9, ...)" fails, try "pg_ctl kill".
- de262941fc9c 11.3 landed
- 61c0962d90d5 10.8 landed
- 55926b0a0917 9.6.13 landed
- 947a35014fdc 12.0 landed
-
Consistently test for in-use shared memory.
- 3ef5e16c6181 9.4.22 landed
- c565de643167 9.5.17 landed
- 808e1e75fb37 9.6.13 landed
- 7ef2b313e649 11.3 landed
- 6d81e3c6526b 10.8 landed
- c098509927f9 12.0 landed
- e7f89a5dec0f 9.5.17 landed
- b2307f8e3184 11.3 landed
- 891e9e0aee53 9.6.13 landed
- 7c414cdc39a3 10.8 landed
- 3a70b66e6257 9.4.22 landed
- 2f932f71d9f2 12.0 landed
-
Revert "Consistently test for in-use shared memory."
- ae98c24fda4b 9.6.13 landed
- 9ec582b64d69 9.5.17 landed
- 7d18a55c90eb 10.8 landed
- 392ea22e9b32 11.3 landed
- 0777696fe346 9.4.22 landed
- 82150a05be0d 12.0 landed
-
Silence -Wimplicit-fallthrough in sysv_shmem.c.
- 0aa0ccfdd653 9.6.13 cited
-
Make src/test/recovery/t/017_shm.pl safe for concurrent execution.
- 0e0d449fb02a 9.6.13 landed
- 3186d5fac55b 10.8 landed
- 1106438c37db 11.3 landed
- 16ee6eaf80a4 12.0 landed
-
Update HINT for pre-existing shared memory block.
- f3461cb8f5b5 9.4.22 landed
- 52e7e4d1dfe6 9.5.17 landed
- e49dc9ab14b2 9.6.13 landed
- ab7590e9197c 11.3 landed
- 327399412d03 10.8 landed
- 5a907404b527 12.0 landed
-
Add WL_EXIT_ON_PM_DEATH pseudo-event.
- cfdf4dc4fc96 12.0 cited
-
The default values for shared_buffers and max_connections are now 1000
- de98a7e23a19 7.4.1 cited
-
XLOG (and related) changes:
- 4d14fe0048cf 7.1.1 cited
-
Significant cleanups in SysV IPC handling (shared mem and semaphores).
- c715fdea2678 7.1.1 cited