pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Detect the deadlocks between backends and the startup process. 6+ messages / 1 participants [nested] [flat]
* pgsql: Detect the deadlocks between backends and the startup process. @ 2021-01-06 03:35 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2021-01-06 03:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Detect the deadlocks between backends and the startup process. The deadlocks that the recovery conflict on lock is involved in can happen between hot-standby backends and the startup process. If a backend takes an access exclusive lock on the table and which finally triggers the deadlock, that deadlock can be detected as expected. On the other hand, previously, if the startup process took an access exclusive lock and which finally triggered the deadlock, that deadlock could not be detected and could remain even after deadlock_timeout passed. This is a bug. The cause of this bug was that the code for handling the recovery conflict on lock didn't take care of deadlock case at all. It assumed that deadlocks involving the startup process and backends were able to be detected by the deadlock detector invoked within backends. But this assumption was incorrect. The startup process also should have invoked the deadlock detector if necessary. To fix this bug, this commit makes the startup process invoke the deadlock detector if deadlock_timeout is reached while handling the recovery conflict on lock. Specifically, in that case, the startup process requests all the backends holding the conflicting locks to check themselves for deadlocks. Back-patch to v9.6. v9.5 has also this bug, but per discussion we decided not to back-patch the fix to v9.5. Because v9.5 doesn't have some infrastructure codes (e.g., 37c54863cf) that this bug fix patch depends on. We can apply those codes for the back-patch, but since the next minor version release is the final one for v9.5, it's risky to do that. If we unexpectedly introduce new bug to v9.5 by the back-patch, there is no chance to fix that. We determined that the back-patch to v9.5 would give more risk than gain. Author: Fujii Masao Reviewed-by: Bertrand Drouvot, Masahiko Sawada, Kyotaro Horiguchi Discussion: https://postgr.es/m/4041d6b6-cf24-a120-36fa-1294220f8243@oss.nttdata.com Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0307b98d8f5f464de622853be77a28ab6a8e1038 Modified Files -------------- src/backend/storage/ipc/procarray.c | 9 ++- src/backend/storage/ipc/standby.c | 143 ++++++++++++++++++++++++++++-------- src/backend/storage/lmgr/proc.c | 3 + src/backend/tcop/postgres.c | 16 +++- src/include/storage/procarray.h | 2 + 5 files changed, 141 insertions(+), 32 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Detect the deadlocks between backends and the startup process. @ 2021-01-06 03:35 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2021-01-06 03:35 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Detect the deadlocks between backends and the startup process. The deadlocks that the recovery conflict on lock is involved in can happen between hot-standby backends and the startup process. If a backend takes an access exclusive lock on the table and which finally triggers the deadlock, that deadlock can be detected as expected. On the other hand, previously, if the startup process took an access exclusive lock and which finally triggered the deadlock, that deadlock could not be detected and could remain even after deadlock_timeout passed. This is a bug. The cause of this bug was that the code for handling the recovery conflict on lock didn't take care of deadlock case at all. It assumed that deadlocks involving the startup process and backends were able to be detected by the deadlock detector invoked within backends. But this assumption was incorrect. The startup process also should have invoked the deadlock detector if necessary. To fix this bug, this commit makes the startup process invoke the deadlock detector if deadlock_timeout is reached while handling the recovery conflict on lock. Specifically, in that case, the startup process requests all the backends holding the conflicting locks to check themselves for deadlocks. Back-patch to v9.6. v9.5 has also this bug, but per discussion we decided not to back-patch the fix to v9.5. Because v9.5 doesn't have some infrastructure codes (e.g., 37c54863cf) that this bug fix patch depends on. We can apply those codes for the back-patch, but since the next minor version release is the final one for v9.5, it's risky to do that. If we unexpectedly introduce new bug to v9.5 by the back-patch, there is no chance to fix that. We determined that the back-patch to v9.5 would give more risk than gain. Author: Fujii Masao Reviewed-by: Bertrand Drouvot, Masahiko Sawada, Kyotaro Horiguchi Discussion: https://postgr.es/m/4041d6b6-cf24-a120-36fa-1294220f8243@oss.nttdata.com Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4c20e78f1f154ded6a6a45bf2b6514a1930c17b0 Modified Files -------------- src/backend/storage/ipc/procarray.c | 9 ++- src/backend/storage/ipc/standby.c | 143 ++++++++++++++++++++++++++++-------- src/backend/storage/lmgr/proc.c | 3 + src/backend/tcop/postgres.c | 16 +++- src/include/storage/procarray.h | 2 + 5 files changed, 141 insertions(+), 32 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Detect the deadlocks between backends and the startup process. @ 2021-01-06 03:36 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2021-01-06 03:36 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Detect the deadlocks between backends and the startup process. The deadlocks that the recovery conflict on lock is involved in can happen between hot-standby backends and the startup process. If a backend takes an access exclusive lock on the table and which finally triggers the deadlock, that deadlock can be detected as expected. On the other hand, previously, if the startup process took an access exclusive lock and which finally triggered the deadlock, that deadlock could not be detected and could remain even after deadlock_timeout passed. This is a bug. The cause of this bug was that the code for handling the recovery conflict on lock didn't take care of deadlock case at all. It assumed that deadlocks involving the startup process and backends were able to be detected by the deadlock detector invoked within backends. But this assumption was incorrect. The startup process also should have invoked the deadlock detector if necessary. To fix this bug, this commit makes the startup process invoke the deadlock detector if deadlock_timeout is reached while handling the recovery conflict on lock. Specifically, in that case, the startup process requests all the backends holding the conflicting locks to check themselves for deadlocks. Back-patch to v9.6. v9.5 has also this bug, but per discussion we decided not to back-patch the fix to v9.5. Because v9.5 doesn't have some infrastructure codes (e.g., 37c54863cf) that this bug fix patch depends on. We can apply those codes for the back-patch, but since the next minor version release is the final one for v9.5, it's risky to do that. If we unexpectedly introduce new bug to v9.5 by the back-patch, there is no chance to fix that. We determined that the back-patch to v9.5 would give more risk than gain. Author: Fujii Masao Reviewed-by: Bertrand Drouvot, Masahiko Sawada, Kyotaro Horiguchi Discussion: https://postgr.es/m/4041d6b6-cf24-a120-36fa-1294220f8243@oss.nttdata.com Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/e83771880402f9b2b0feefa10ae842ad8ef82b03 Modified Files -------------- src/backend/storage/ipc/procarray.c | 9 ++- src/backend/storage/ipc/standby.c | 143 ++++++++++++++++++++++++++++-------- src/backend/storage/lmgr/proc.c | 3 + src/backend/tcop/postgres.c | 16 +++- src/include/storage/procarray.h | 2 + 5 files changed, 141 insertions(+), 32 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Detect the deadlocks between backends and the startup process. @ 2021-01-06 03:36 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2021-01-06 03:36 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Detect the deadlocks between backends and the startup process. The deadlocks that the recovery conflict on lock is involved in can happen between hot-standby backends and the startup process. If a backend takes an access exclusive lock on the table and which finally triggers the deadlock, that deadlock can be detected as expected. On the other hand, previously, if the startup process took an access exclusive lock and which finally triggered the deadlock, that deadlock could not be detected and could remain even after deadlock_timeout passed. This is a bug. The cause of this bug was that the code for handling the recovery conflict on lock didn't take care of deadlock case at all. It assumed that deadlocks involving the startup process and backends were able to be detected by the deadlock detector invoked within backends. But this assumption was incorrect. The startup process also should have invoked the deadlock detector if necessary. To fix this bug, this commit makes the startup process invoke the deadlock detector if deadlock_timeout is reached while handling the recovery conflict on lock. Specifically, in that case, the startup process requests all the backends holding the conflicting locks to check themselves for deadlocks. Back-patch to v9.6. v9.5 has also this bug, but per discussion we decided not to back-patch the fix to v9.5. Because v9.5 doesn't have some infrastructure codes (e.g., 37c54863cf) that this bug fix patch depends on. We can apply those codes for the back-patch, but since the next minor version release is the final one for v9.5, it's risky to do that. If we unexpectedly introduce new bug to v9.5 by the back-patch, there is no chance to fix that. We determined that the back-patch to v9.5 would give more risk than gain. Author: Fujii Masao Reviewed-by: Bertrand Drouvot, Masahiko Sawada, Kyotaro Horiguchi Discussion: https://postgr.es/m/4041d6b6-cf24-a120-36fa-1294220f8243@oss.nttdata.com Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9f540f840665936132dd30bd8e58e9a67e648f22 Modified Files -------------- src/backend/storage/ipc/procarray.c | 9 ++- src/backend/storage/ipc/standby.c | 143 ++++++++++++++++++++++++++++-------- src/backend/storage/lmgr/proc.c | 3 + src/backend/tcop/postgres.c | 16 +++- src/include/storage/procarray.h | 2 + 5 files changed, 141 insertions(+), 32 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Detect the deadlocks between backends and the startup process. @ 2021-01-06 03:37 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2021-01-06 03:37 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Detect the deadlocks between backends and the startup process. The deadlocks that the recovery conflict on lock is involved in can happen between hot-standby backends and the startup process. If a backend takes an access exclusive lock on the table and which finally triggers the deadlock, that deadlock can be detected as expected. On the other hand, previously, if the startup process took an access exclusive lock and which finally triggered the deadlock, that deadlock could not be detected and could remain even after deadlock_timeout passed. This is a bug. The cause of this bug was that the code for handling the recovery conflict on lock didn't take care of deadlock case at all. It assumed that deadlocks involving the startup process and backends were able to be detected by the deadlock detector invoked within backends. But this assumption was incorrect. The startup process also should have invoked the deadlock detector if necessary. To fix this bug, this commit makes the startup process invoke the deadlock detector if deadlock_timeout is reached while handling the recovery conflict on lock. Specifically, in that case, the startup process requests all the backends holding the conflicting locks to check themselves for deadlocks. Back-patch to v9.6. v9.5 has also this bug, but per discussion we decided not to back-patch the fix to v9.5. Because v9.5 doesn't have some infrastructure codes (e.g., 37c54863cf) that this bug fix patch depends on. We can apply those codes for the back-patch, but since the next minor version release is the final one for v9.5, it's risky to do that. If we unexpectedly introduce new bug to v9.5 by the back-patch, there is no chance to fix that. We determined that the back-patch to v9.5 would give more risk than gain. Author: Fujii Masao Reviewed-by: Bertrand Drouvot, Masahiko Sawada, Kyotaro Horiguchi Discussion: https://postgr.es/m/4041d6b6-cf24-a120-36fa-1294220f8243@oss.nttdata.com Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/0f8977b3f2536c91a0a97e2395c297d3acf1f491 Modified Files -------------- src/backend/storage/ipc/procarray.c | 9 ++- src/backend/storage/ipc/standby.c | 143 ++++++++++++++++++++++++++++-------- src/backend/storage/lmgr/proc.c | 3 + src/backend/tcop/postgres.c | 16 +++- src/include/storage/procarray.h | 2 + 5 files changed, 141 insertions(+), 32 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Detect the deadlocks between backends and the startup process. @ 2021-01-06 03:39 Fujii Masao <fujii@postgresql.org> 0 siblings, 0 replies; 6+ messages in thread From: Fujii Masao @ 2021-01-06 03:39 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Detect the deadlocks between backends and the startup process. The deadlocks that the recovery conflict on lock is involved in can happen between hot-standby backends and the startup process. If a backend takes an access exclusive lock on the table and which finally triggers the deadlock, that deadlock can be detected as expected. On the other hand, previously, if the startup process took an access exclusive lock and which finally triggered the deadlock, that deadlock could not be detected and could remain even after deadlock_timeout passed. This is a bug. The cause of this bug was that the code for handling the recovery conflict on lock didn't take care of deadlock case at all. It assumed that deadlocks involving the startup process and backends were able to be detected by the deadlock detector invoked within backends. But this assumption was incorrect. The startup process also should have invoked the deadlock detector if necessary. To fix this bug, this commit makes the startup process invoke the deadlock detector if deadlock_timeout is reached while handling the recovery conflict on lock. Specifically, in that case, the startup process requests all the backends holding the conflicting locks to check themselves for deadlocks. Back-patch to v9.6. v9.5 has also this bug, but per discussion we decided not to back-patch the fix to v9.5. Because v9.5 doesn't have some infrastructure codes (e.g., 37c54863cf) that this bug fix patch depends on. We can apply those codes for the back-patch, but since the next minor version release is the final one for v9.5, it's risky to do that. If we unexpectedly introduce new bug to v9.5 by the back-patch, there is no chance to fix that. We determined that the back-patch to v9.5 would give more risk than gain. Author: Fujii Masao Reviewed-by: Bertrand Drouvot, Masahiko Sawada, Kyotaro Horiguchi Discussion: https://postgr.es/m/4041d6b6-cf24-a120-36fa-1294220f8243@oss.nttdata.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/8900b5a9d59a645b3485f5b046c4c7871b2c4026 Modified Files -------------- src/backend/storage/ipc/procarray.c | 9 ++- src/backend/storage/ipc/standby.c | 143 ++++++++++++++++++++++++++++-------- src/backend/storage/lmgr/proc.c | 3 + src/backend/tcop/postgres.c | 16 +++- src/include/storage/procarray.h | 2 + 5 files changed, 141 insertions(+), 32 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2021-01-06 03:39 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-01-06 03:35 pgsql: Detect the deadlocks between backends and the startup process. Fujii Masao <fujii@postgresql.org> 2021-01-06 03:35 pgsql: Detect the deadlocks between backends and the startup process. Fujii Masao <fujii@postgresql.org> 2021-01-06 03:36 pgsql: Detect the deadlocks between backends and the startup process. Fujii Masao <fujii@postgresql.org> 2021-01-06 03:36 pgsql: Detect the deadlocks between backends and the startup process. Fujii Masao <fujii@postgresql.org> 2021-01-06 03:37 pgsql: Detect the deadlocks between backends and the startup process. Fujii Masao <fujii@postgresql.org> 2021-01-06 03:39 pgsql: Detect the deadlocks between backends and the startup process. Fujii Masao <fujii@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox