pgpool2.git / summary / log / commit / refs

commit    160c14fabbb714cfefb08a2d9bbf6d4a5384e56b
Author:   Tatsuo Ishii <ishii@sraoss.co.jp>
Date:     Tue Dec 11 22:42:31 2018 +0000

    Fix occasional extended query hang.
    
    If a client sends a extended query message such as close after sync
    message but before next simple query, Pgpool-II could hang.
    
    :
    <= BE ParseComplete
    <= BE BindComplete
    <= BE CommandComplete(COMMIT)
    <= BE ReadyForQuery(I)
    FE=> Close(stmt="S2")
    FE=> Close(stmt="S1")
    FE=> Query (query="BEGIN") [0]
    <= BE CloseComplete [1]
    <= BE CloseComplete [1]
    <= BE CommandComplete(BEGIN) [2]
    
    Because of [1], query in progress flag was reset, then [2] hangs
    trying to read from backend which did not receive message from
    Pgpool-II because it does not refer to the query context set by [0].
    
    Sending close after sync is not recommended according to the official
    document but some sloppy drivers seem to do it. To deal with the
    problem, check the doing extended query message flag before resetting
    the query in progress flag.
    
    Problem reported by Muhammad Usama.
    Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2018-December/003164.html


src/protocol/pool_proto_modules.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c index 42f5c63cf..01336ce5b 100644 --- a/src/protocol/pool_proto_modules.c +++ b/src/protocol/pool_proto_modules.c @@ -2759,7 +2759,8 @@ ProcessBackendResponse(POOL_CONNECTION * frontend, pmsg = pool_pending_message_pull_out(); pool_pending_message_free_pending_message(pmsg); - pool_unset_query_in_progress(); + if (pool_is_doing_extended_query_message()) + pool_unset_query_in_progress(); pool_set_command_success(); status = POOL_CONTINUE; break; @@ -2768,7 +2769,8 @@ ProcessBackendResponse(POOL_CONNECTION * frontend, status = CloseComplete(frontend, backend); pool_set_command_success(); - pool_unset_query_in_progress(); + if (pool_is_doing_extended_query_message()) + pool_unset_query_in_progress(); break; case 'E': /* ErrorResponse */ [parent: 9ad425a59035]