pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix handling of errors in libpq pipelines 4+ messages / 1 participants [nested] [flat]
* pgsql: Fix handling of errors in libpq pipelines @ 2023-12-05 11:43 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Alvaro Herrera @ 2023-12-05 11:43 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix handling of errors in libpq pipelines The logic to keep the libpq command queue in sync with queries that have been processed had a bug when errors were returned for reasons other than problems in queries -- for example, when a connection is lost. We incorrectly consumed an element from the command queue every time, but this is wrong and can lead to the queue becoming empty ahead of time, leading to later malfunction: PQgetResult would return nothing, potentially causing the calling application to enter a busy loop. Fix by making the SYNC queue element a barrier that can only be consumed when a SYNC message is received. Backpatch to 14. Reported by: Иван Трофимов (Ivan Trofimov) <i.trofimow@yandex.ru> Discussion: https://postgr.es/m/17948-fcace7557e449957@postgresql.org Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/b8ba7344e9eb9bb505a92900b2a59257ef718135 Modified Files -------------- src/interfaces/libpq/fe-exec.c | 53 +++++++++++++++++++++++++------------ src/interfaces/libpq/fe-protocol3.c | 9 ++----- src/interfaces/libpq/libpq-int.h | 3 ++- 3 files changed, 40 insertions(+), 25 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix handling of errors in libpq pipelines @ 2023-12-05 11:43 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Alvaro Herrera @ 2023-12-05 11:43 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix handling of errors in libpq pipelines The logic to keep the libpq command queue in sync with queries that have been processed had a bug when errors were returned for reasons other than problems in queries -- for example, when a connection is lost. We incorrectly consumed an element from the command queue every time, but this is wrong and can lead to the queue becoming empty ahead of time, leading to later malfunction: PQgetResult would return nothing, potentially causing the calling application to enter a busy loop. Fix by making the SYNC queue element a barrier that can only be consumed when a SYNC message is received. Backpatch to 14. Reported by: Иван Трофимов (Ivan Trofimov) <i.trofimow@yandex.ru> Discussion: https://postgr.es/m/17948-fcace7557e449957@postgresql.org Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/878aa41f8257b1e8b36a690d62475b4e6f1ede33 Modified Files -------------- src/interfaces/libpq/fe-exec.c | 53 +++++++++++++++++++++++++------------ src/interfaces/libpq/fe-protocol3.c | 9 ++----- src/interfaces/libpq/libpq-int.h | 3 ++- 3 files changed, 40 insertions(+), 25 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix handling of errors in libpq pipelines @ 2023-12-05 11:43 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Alvaro Herrera @ 2023-12-05 11:43 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix handling of errors in libpq pipelines The logic to keep the libpq command queue in sync with queries that have been processed had a bug when errors were returned for reasons other than problems in queries -- for example, when a connection is lost. We incorrectly consumed an element from the command queue every time, but this is wrong and can lead to the queue becoming empty ahead of time, leading to later malfunction: PQgetResult would return nothing, potentially causing the calling application to enter a busy loop. Fix by making the SYNC queue element a barrier that can only be consumed when a SYNC message is received. Backpatch to 14. Reported by: Иван Трофимов (Ivan Trofimov) <i.trofimow@yandex.ru> Discussion: https://postgr.es/m/17948-fcace7557e449957@postgresql.org Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1171c6e7418564296e9023859f68225b247427a7 Modified Files -------------- src/interfaces/libpq/fe-exec.c | 61 ++++++++++++++++++++++++------------- src/interfaces/libpq/fe-protocol3.c | 9 ++---- src/interfaces/libpq/libpq-int.h | 3 +- 3 files changed, 44 insertions(+), 29 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Fix handling of errors in libpq pipelines @ 2023-12-05 11:43 Alvaro Herrera <alvherre@alvh.no-ip.org> 0 siblings, 0 replies; 4+ messages in thread From: Alvaro Herrera @ 2023-12-05 11:43 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix handling of errors in libpq pipelines The logic to keep the libpq command queue in sync with queries that have been processed had a bug when errors were returned for reasons other than problems in queries -- for example, when a connection is lost. We incorrectly consumed an element from the command queue every time, but this is wrong and can lead to the queue becoming empty ahead of time, leading to later malfunction: PQgetResult would return nothing, potentially causing the calling application to enter a busy loop. Fix by making the SYNC queue element a barrier that can only be consumed when a SYNC message is received. Backpatch to 14. Reported by: Иван Трофимов (Ivan Trofimov) <i.trofimow@yandex.ru> Discussion: https://postgr.es/m/17948-fcace7557e449957@postgresql.org Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f89681816793d79584296c58960f790e6e073459 Modified Files -------------- src/interfaces/libpq/fe-exec.c | 63 ++++++++++++++++++++++++------------- src/interfaces/libpq/fe-protocol3.c | 16 ++++------ src/interfaces/libpq/libpq-int.h | 3 +- 3 files changed, 49 insertions(+), 33 deletions(-) ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2023-12-05 11:43 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-12-05 11:43 pgsql: Fix handling of errors in libpq pipelines Alvaro Herrera <alvherre@alvh.no-ip.org> 2023-12-05 11:43 pgsql: Fix handling of errors in libpq pipelines Alvaro Herrera <alvherre@alvh.no-ip.org> 2023-12-05 11:43 pgsql: Fix handling of errors in libpq pipelines Alvaro Herrera <alvherre@alvh.no-ip.org> 2023-12-05 11:43 pgsql: Fix handling of errors in libpq pipelines Alvaro Herrera <alvherre@alvh.no-ip.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