Re: EINTR in ftruncate()
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2022-07-01T20:29:44Z
Lists: pgsql-hackers
Hi, On 2022-07-01 19:55:16 +0200, Alvaro Herrera wrote: > On 2022-Jul-01, Andres Freund wrote: > > > On 2022-07-01 17:41:05 +0200, Alvaro Herrera wrote: > > > Nicola Contu reported two years ago to pgsql-general[1] that they were > > > having sporadic query failures, because EINTR is reported on some system > > > call. I have been told that the problem persists, though it is very > > > infrequent. I propose the attached patch. Kyotaro proposed a slightly > > > different patch which also protects write(), but I think that's not > > > necessary. > > > > What is the reason for the || ProcDiePending || QueryCancelPending bit? What > > if there's dsm operations intentionally done while QueryCancelPending? > > That mirrors the test for the other block in that function, which was > added by 63efab4ca139, whose commit message explains: > > Allow DSM allocation to be interrupted. > > Chris Travers reported that the startup process can repeatedly try to > cancel a backend that is in a posix_fallocate()/EINTR loop and cause it > to loop forever. Teach the retry loop to give up if an interrupt is > pending. Don't actually check for interrupts in that loop though, > because a non-local exit would skip some clean-up code in the caller. That whole approach seems quite wrong to me. At the absolute very least the code needs to check if interrupts are being processed in the current context before just giving up due to ProcDiePending || QueryCancelPending. I'm very unconvinced this ought to be fixed in dsm_impl_posix_resize(), rather than the startup process signalling. There is an argument for allowing more things to be cancelled, but we'd need a retry loop for the !INTERRUPTS_CAN_BE_PROCESSED() case. Greetings, Andres Freund
Commits
-
Provide sigaction() for Windows.
- b28ac1d24db4 16.0 landed
-
Emulate sigprocmask(), not sigsetmask(), on Windows.
- c94ae9d827a3 16.0 landed
-
Make dsm_impl_posix_resize more future-proof.
- d3b0884c0708 10.22 landed
- 3f2344d4aee1 11.17 landed
- 1661c40b9deb 12.12 landed
- c75b6b454ea1 13.8 landed
- c412c60b91ac 14.5 landed
- 91377a4559d8 15.0 landed
- 3b8d23a3e14f 16.0 landed
-
Don't clobber postmaster sigmask in dsm_impl_resize.
- e26024bea9e9 10.22 landed
- 74a9ee034829 11.17 landed
- a05f40ef874b 12.12 landed
- 17aa39da50c5 13.8 landed
- 8383645592de 14.5 landed
- a715c20043c1 15.0 landed
- 80845b7c0b2c 16.0 landed
-
Create a distinct wait event for POSIX DSM allocation.
- 7bae3bbf62d6 16.0 landed
-
Remove redundant ftruncate() for POSIX DSM memory.
- 712704d3539e 16.0 landed
-
Block signals while allocating DSM memory.
- 4518c798b2b9 16.0 landed
- c4a617ea117e 15.0 landed
- 2019e6ecfa26 14.5 landed
- e73fe6e828d1 13.8 landed
- ff78bf796d80 12.12 landed
- 39683c69a03e 11.17 landed
- 53cfe403c9d2 10.22 landed
-
Remove dsm_resize() and dsm_remap().
- 3c60d0fa231f 12.0 cited
-
XLOG (also known as WAL -:)) Bootstrap/Startup/Shutdown.
- 47937403676d 7.1.1 cited