| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Two fixes for parallel query cleanup: DSM detach order and a stray statement timeout |
| Date: | 2026-11-27 01:23:50 |
| Message-ID: | awjbpi7bLXtbzmjV@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Sep 29, 2026 at 10:12:15PM -0600, shihao zhong wrote:
> 0001 moves dsm_detach() in DestroyParallelContext() after
> WaitForParallelWorkersToExit(). Today a worker that is still starting up
> when the leader detaches fails to map the segment, or to attach to the
> DSA or the SharedFileSet, and logs an error. Cancelling a 4 worker
> parallel hash join 1200 times on master logged 407 such errors, with the
> patch none. The error queues are still detached before the wait, so a
> worker stuck in error reporting cannot block the leader. Cancelling
> workers blocked on full tuple queues, parallel CREATE INDEX and parallel
> VACUUM showed no hang and no leftover temp files.
Hmm. Nice catch. You fix of fastening the check for all the workers
to exit looks sound. The comment may perhaps be improved. Just to
say that the basic fix sounds fine. Thanks for the reproducer!
> 0002 fixes something worse. A parallel hash join that spilled deletes
> its temp files in dsm_detach() at the end of the query, with interrupts
> held since 637668fb1d1. If statement_timeout fires in those few
> milliseconds, disable_statement_timeout() skips the timer because it is
> no longer active (22f6f2c1ccb) and the fired indicator stays set. The
> next statement fails on its first CHECK_FOR_INTERRUPTS(). Master,
> default settings, a 3M row self join (2 workers, 32 batches, about 560
> ms), statement_timeout within 15% of that:
>
> SELECT count(*) FROM big a JOIN big b USING (id); -- succeeds
> SELECT 'marker';
> ERROR: canceling statement due to statement timeout
>
> The marker failed 5 times in 120 tries. In a BEGIN, INSERT, join, COMMIT
> sequence the COMMIT failed 4 times in 242 tries and left the session in
> an aborted transaction block. Tom described this case in [2]. 0002
> clears the fired indicator when the timer is not active, as the code did
> before 22f6f2c1ccb, and both counts drop to zero. Reproducer attached.
Hmm. The problem is here, but I am not sure that the fix is the right
thing to do. I will study that a bit more first before getting back
to it.
> The patches are independent. 0002 is a regression in 13 and later, 0001
> is only log noise.
Perhaps create two threads, one for each problem, each one with its
own patch and/or test cases, then. There is no point in doing that
now that both patches are published, so no worries, but splitting
issues helps in usually attracting the right attention for them. ;)
--
Michael
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-11-27 01:27:48 | Re: Infinite loop in XLogPageRead() on standby |
| Previous Message | Noboru Saito | 2026-11-27 00:11:34 | Re: [DOC][PATCH] Improving the HTML layout of release notes |