public inbox for [email protected]help / color / mirror / Atom feed
pgpool: Prevent pcp_node_info from hanging. 6+ messages / 1 participants [nested] [flat]
* pgpool: Prevent pcp_node_info from hanging. @ 2026-06-07 03:12 Tatsuo Ishii <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Tatsuo Ishii @ 2026-06-07 03:12 UTC (permalink / raw) To: [email protected] Prevent pcp_node_info from hanging. The problem: In inform_node_info() (src/pcp_con/pcp_worker.c), the PCP reply packet reads bi->replication_state and bi->replication_sync_state directly from shared memory twice: once via strlen() to compute the packet length, and once via pcp_write() to write the payload. The streaming-replication check worker rewrites those same shared-memory strings without a lock (it clears them to "" then repopulates them every check cycle and on state transitions, src/streaming_replication/pool_worker_child.c). If the string's length changes between the two reads, the declared wsize no longer matches the bytes actually written, so the PCP byte stream desynchronises. The client then blocks forever in pcp_read() waiting for bytes the server never sends. The fix: Snapshot the two strings into local buffers once, right after bi = pool_get_node_info(i), and use the locals for both the length and the payload — so a single packet is always internally consistent. This matches how every other field in the packet is already handled. Author: Emond Papegaaij <[email protected]> Reviewed-by: Tatsuo Ishii <[email protected]> Discussion: https://www.postgresql.org/message-id/CAGXsc%2BZhGjwm%2BF42Xmt8Qn1qP_h7woipiV0WsY-e-P7W3ZG2OA%40mail... Backpatch-through: v4.3 Branch ------ V4_3_STABLE Details ------- https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=fb0a3ff94efef2e07bcbafd87928f7a00f97c... Modified Files -------------- src/pcp_con/pcp_worker.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgpool: Prevent pcp_node_info from hanging. @ 2026-06-07 03:12 Tatsuo Ishii <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Tatsuo Ishii @ 2026-06-07 03:12 UTC (permalink / raw) To: [email protected] Prevent pcp_node_info from hanging. The problem: In inform_node_info() (src/pcp_con/pcp_worker.c), the PCP reply packet reads bi->replication_state and bi->replication_sync_state directly from shared memory twice: once via strlen() to compute the packet length, and once via pcp_write() to write the payload. The streaming-replication check worker rewrites those same shared-memory strings without a lock (it clears them to "" then repopulates them every check cycle and on state transitions, src/streaming_replication/pool_worker_child.c). If the string's length changes between the two reads, the declared wsize no longer matches the bytes actually written, so the PCP byte stream desynchronises. The client then blocks forever in pcp_read() waiting for bytes the server never sends. The fix: Snapshot the two strings into local buffers once, right after bi = pool_get_node_info(i), and use the locals for both the length and the payload — so a single packet is always internally consistent. This matches how every other field in the packet is already handled. Author: Emond Papegaaij <[email protected]> Reviewed-by: Tatsuo Ishii <[email protected]> Discussion: https://www.postgresql.org/message-id/CAGXsc%2BZhGjwm%2BF42Xmt8Qn1qP_h7woipiV0WsY-e-P7W3ZG2OA%40mail... Backpatch-through: v4.3 Branch ------ V4_4_STABLE Details ------- https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=1fcbdfdf1894167b68dbdcebfd29ce968a448... Modified Files -------------- src/pcp_con/pcp_worker.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgpool: Prevent pcp_node_info from hanging. @ 2026-06-07 03:12 Tatsuo Ishii <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Tatsuo Ishii @ 2026-06-07 03:12 UTC (permalink / raw) To: [email protected] Prevent pcp_node_info from hanging. The problem: In inform_node_info() (src/pcp_con/pcp_worker.c), the PCP reply packet reads bi->replication_state and bi->replication_sync_state directly from shared memory twice: once via strlen() to compute the packet length, and once via pcp_write() to write the payload. The streaming-replication check worker rewrites those same shared-memory strings without a lock (it clears them to "" then repopulates them every check cycle and on state transitions, src/streaming_replication/pool_worker_child.c). If the string's length changes between the two reads, the declared wsize no longer matches the bytes actually written, so the PCP byte stream desynchronises. The client then blocks forever in pcp_read() waiting for bytes the server never sends. The fix: Snapshot the two strings into local buffers once, right after bi = pool_get_node_info(i), and use the locals for both the length and the payload — so a single packet is always internally consistent. This matches how every other field in the packet is already handled. Author: Emond Papegaaij <[email protected]> Reviewed-by: Tatsuo Ishii <[email protected]> Discussion: https://www.postgresql.org/message-id/CAGXsc%2BZhGjwm%2BF42Xmt8Qn1qP_h7woipiV0WsY-e-P7W3ZG2OA%40mail... Backpatch-through: v4.3 Branch ------ V4_5_STABLE Details ------- https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=aa8be806792046a68eac364263b883f95508f... Modified Files -------------- src/pcp_con/pcp_worker.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgpool: Prevent pcp_node_info from hanging. @ 2026-06-07 03:12 Tatsuo Ishii <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Tatsuo Ishii @ 2026-06-07 03:12 UTC (permalink / raw) To: [email protected] Prevent pcp_node_info from hanging. The problem: In inform_node_info() (src/pcp_con/pcp_worker.c), the PCP reply packet reads bi->replication_state and bi->replication_sync_state directly from shared memory twice: once via strlen() to compute the packet length, and once via pcp_write() to write the payload. The streaming-replication check worker rewrites those same shared-memory strings without a lock (it clears them to "" then repopulates them every check cycle and on state transitions, src/streaming_replication/pool_worker_child.c). If the string's length changes between the two reads, the declared wsize no longer matches the bytes actually written, so the PCP byte stream desynchronises. The client then blocks forever in pcp_read() waiting for bytes the server never sends. The fix: Snapshot the two strings into local buffers once, right after bi = pool_get_node_info(i), and use the locals for both the length and the payload — so a single packet is always internally consistent. This matches how every other field in the packet is already handled. Author: Emond Papegaaij <[email protected]> Reviewed-by: Tatsuo Ishii <[email protected]> Discussion: https://www.postgresql.org/message-id/CAGXsc%2BZhGjwm%2BF42Xmt8Qn1qP_h7woipiV0WsY-e-P7W3ZG2OA%40mail... Backpatch-through: v4.3 Branch ------ V4_6_STABLE Details ------- https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=2c63ab1d650c6b209b1bb1948aad993fd791c... Modified Files -------------- src/pcp_con/pcp_worker.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgpool: Prevent pcp_node_info from hanging. @ 2026-06-07 03:12 Tatsuo Ishii <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Tatsuo Ishii @ 2026-06-07 03:12 UTC (permalink / raw) To: [email protected] Prevent pcp_node_info from hanging. The problem: In inform_node_info() (src/pcp_con/pcp_worker.c), the PCP reply packet reads bi->replication_state and bi->replication_sync_state directly from shared memory twice: once via strlen() to compute the packet length, and once via pcp_write() to write the payload. The streaming-replication check worker rewrites those same shared-memory strings without a lock (it clears them to "" then repopulates them every check cycle and on state transitions, src/streaming_replication/pool_worker_child.c). If the string's length changes between the two reads, the declared wsize no longer matches the bytes actually written, so the PCP byte stream desynchronises. The client then blocks forever in pcp_read() waiting for bytes the server never sends. The fix: Snapshot the two strings into local buffers once, right after bi = pool_get_node_info(i), and use the locals for both the length and the payload — so a single packet is always internally consistent. This matches how every other field in the packet is already handled. Author: Emond Papegaaij <[email protected]> Reviewed-by: Tatsuo Ishii <[email protected]> Discussion: https://www.postgresql.org/message-id/CAGXsc%2BZhGjwm%2BF42Xmt8Qn1qP_h7woipiV0WsY-e-P7W3ZG2OA%40mail... Backpatch-through: v4.3 Branch ------ V4_7_STABLE Details ------- https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=4ad45f625d64c3cf5a6a2c899dd047e6bd2ca... Modified Files -------------- src/pcp_con/pcp_worker.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgpool: Prevent pcp_node_info from hanging. @ 2026-06-07 03:12 Tatsuo Ishii <[email protected]> 0 siblings, 0 replies; 6+ messages in thread From: Tatsuo Ishii @ 2026-06-07 03:12 UTC (permalink / raw) To: [email protected] Prevent pcp_node_info from hanging. The problem: In inform_node_info() (src/pcp_con/pcp_worker.c), the PCP reply packet reads bi->replication_state and bi->replication_sync_state directly from shared memory twice: once via strlen() to compute the packet length, and once via pcp_write() to write the payload. The streaming-replication check worker rewrites those same shared-memory strings without a lock (it clears them to "" then repopulates them every check cycle and on state transitions, src/streaming_replication/pool_worker_child.c). If the string's length changes between the two reads, the declared wsize no longer matches the bytes actually written, so the PCP byte stream desynchronises. The client then blocks forever in pcp_read() waiting for bytes the server never sends. The fix: Snapshot the two strings into local buffers once, right after bi = pool_get_node_info(i), and use the locals for both the length and the payload — so a single packet is always internally consistent. This matches how every other field in the packet is already handled. Author: Emond Papegaaij <[email protected]> Reviewed-by: Tatsuo Ishii <[email protected]> Discussion: https://www.postgresql.org/message-id/CAGXsc%2BZhGjwm%2BF42Xmt8Qn1qP_h7woipiV0WsY-e-P7W3ZG2OA%40mail... Backpatch-through: v4.3 Branch ------ master Details ------- https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=7c918dc247613d16d590a9f30ecc747da6871... Modified Files -------------- src/pcp_con/pcp_worker.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2026-06-07 03:12 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-06-07 03:12 pgpool: Prevent pcp_node_info from hanging. Tatsuo Ishii <[email protected]> 2026-06-07 03:12 pgpool: Prevent pcp_node_info from hanging. Tatsuo Ishii <[email protected]> 2026-06-07 03:12 pgpool: Prevent pcp_node_info from hanging. Tatsuo Ishii <[email protected]> 2026-06-07 03:12 pgpool: Prevent pcp_node_info from hanging. Tatsuo Ishii <[email protected]> 2026-06-07 03:12 pgpool: Prevent pcp_node_info from hanging. Tatsuo Ishii <[email protected]> 2026-06-07 03:12 pgpool: Prevent pcp_node_info from hanging. Tatsuo Ishii <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox