Re: [HACKERS] Weaker shmem interlock w/o postmaster.pid
Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Hello. At Sun, 2 Dec 2018 16:41:06 -0800, Noah Misch <noah@leadboat.com> wrote in <20181203004106.GA2860387@rfd.leadboat.com> > On Thu, Nov 29, 2018 at 10:51:40PM -0800, Noah Misch wrote: > > On Thu, Nov 29, 2018 at 01:10:57PM +0100, Dmitry Dolgov wrote: > > > As a side note, with this patch recovery tests are failing now on 016_shm.pl > > > > > > # Failed test 'detected live backend via shared memory' > > > # at t/016_shm.pl line 87. > > > # '2018-11-28 13:08:08.504 UTC [21924] LOG: > > > listening on Unix socket "/tmp/yV2oDNcG8e/gnat/.s.PGSQL.512" > > > # 2018-11-28 13:08:08.512 UTC [21925] LOG: database system was > > > interrupted; last known up at 2018-11-28 13:08:08 UTC > > > # 2018-11-28 13:08:08.512 UTC [21925] LOG: database system was not > > > properly shut down; automatic recovery in progress > > > # 2018-11-28 13:08:08.512 UTC [21925] LOG: invalid record length at > > > 0/165FEF8: wanted 24, got 0 > > > # 2018-11-28 13:08:08.512 UTC [21925] LOG: redo is not required > > > # 2018-11-28 13:08:08.516 UTC [21924] LOG: database system is ready > > > to accept connections > > > # ' > > > # doesn't match '(?^:pre-existing shared memory block)' > > > > Thanks for the report. Since commit cfdf4dc made pg_sleep() react to > > postmaster death, the test will need a different way to stall a backend. This > > doesn't affect non-test code, and the test still passes against cfdf4dc^ and > > against REL_11_STABLE. I've queued a task to update the test code, but review > > can proceed in parallel. I found that I have 65(h) segments left alone on my environment:p At Sat, 11 Aug 2018 23:48:15 -0700, Noah Misch <noah@leadboat.com> wrote in <20180812064815.GB2301738@rfd.leadboat.com> > still doesn't detect. I could pursue a fix via the aforementioned > sysv_shmem_key file, modulo the possibility of a DBA removing it. I could > also, when postmaster.pid is missing, make sysv_shmem.c check the first N > (N=100?) keys applicable to the selected port. My gut feeling is that neither > thing is worthwhile, but I'm interested to hear other opinions. # Though I don't get the meaning of the "modulo" there.. I think the only thing we must avoid here is sharing the same shmem segment with a living-dead server. If we can do that without the pid file, it would be better than relying on it. We could remove orphaned segments automatically, but I don't think we should do that going so far as relying on a dedicated file. Also, I don't think it's worth stopping shmem id scanning at a certain number since I don't come up with an appropriate number for it. But looking "port * 1000", it might be expected that a usable segment id will found while scanning that number of ids (1000). > Here's a version fixing that test for post-cfdf4dc backends. This moves what were in PGSharedMmoeryIsInUse into a new function IpcMemoryAnalyze for reusing then adds distinction among EEXISTS/FOREIGN in not-in-use cases and ATTACHED/ANALYSIS_FAILURE in an in-use case. UNATTACHED is changed to a not-in-use case by this patch. As the result PGSharedMemoryIsInUse() is changed so that it reutrns "not-in-use" for the UNATTACHED case. It looks fine. PGSharedMemoryCreate changed to choose a usable shmem id using the IpcMemoryAnalyze(). But some of the statuses from IpcMemoryAnalyze() is concealed by failure of PGSharedMemoryAttach() and ignored silently opposed to what the code is intending to do. (By the way SHMSTATE_EEXISTS seems suggesting oppsite thing from EEXIST, which would be confusing.) PGSharedMemoryCreate() repeats shmat/shmdt twice in every iteration. It won't harm so much but it would be better if we could get rid of that. regards. -- Kyotaro Horiguchi NTT Open Source Software Center
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