Re: A new function to wait for the backend exit after termination
Fujii Masao <masao.fujii@oss.nttdata.com>
From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>,
bharath.rupireddyforpostgres@gmail.com
Cc: magnus@hagander.net, houzj.fnst@cn.fujitsu.com,
pgsql-hackers@lists.postgresql.org, m.usama@gmail.com
Date: 2021-03-18T07:16:54Z
Lists: pgsql-hackers
On 2021/03/17 11:58, Kyotaro Horiguchi wrote:
> The first suggested signature for pg_terminate_backend() with timeout
> was pg_terminate_backend(pid, timeout). The current signature (pid,
> wait?, timeout) looks redundant. Maybe the reason for rejecting 0
> astimeout is pg_terminate_backend(pid, true, 0) looks odd but it we
> can wait forever in that case (as other features does).
I'm afraid that "waiting forever" can cause something like deadlock situation,
as follows. We have no mechanism to detect this for now.
1. backend 1 took the lock on the relation A.
2. backend 2 took the lock on the relation B.
3. backend 1 tries to take the lock on the relation B and is waiting for
the lock to be released.
4. backend 2 accidentally executes pg_wait_for_backend_termination() with
the pid of backend 1, and then is waiting for backend 1 to be terminated.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Commits
-
Copy-edit text for the pg_terminate_backend() "timeout" parameter.
- 0aac73e6a260 14.0 landed
-
Remove pg_wait_for_backend_termination().
- 5f1df62a459b 14.0 landed
-
Add functions to wait for backend termination
- aaf043257205 14.0 landed
-
Fix typo in comment.
- 6742e14959a3 14.0 cited