pgpool2.git / summary / log / commit / refs

commit    5e0048e144c366bde543e181ad60e3347e5c861d
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Mon Jul 20 12:16:54 2009 +0000

    Fix bug with SimpleForwardToFrontend().  Clients using the extend
    protocol send 'H'(Flush) after each command. Problem is,
    SimpleForwardToFrontend does not immediately forward 'C'(Command
    Complete) packet to frontend. So the client sends 'H' and wait for
    'C'. On the other hand backend receives 'H' but reply back nothing
    since Command complete has nothing to be returned. Both side stuck.
    
    The fix is, forwarding 'C' packet immediately after receiving it from
    backend. To prevent similar bugs happen in the future, I put
    pool_flush(frontend) after calling SimpleForwardToFrontend in
    pool_process_query() (other places already do this).
    
    The extra pool_flush() might harm performance. So I did some tests
    using pgbench -S, and found nothing has been changed regarding
    performance after patching.
    
    Bug report from Gavin Sherry along with patches for
    SimpleForwardToFrontend().


pool_process_query.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pool_process_query.c b/pool_process_query.c index 252e559df..5c46300d7 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -383,6 +383,8 @@ POOL_STATUS pool_process_query(POOL_CONNECTION *frontend, break; default: status = SimpleForwardToFrontend(kind, frontend, backend); + if (pool_flush(frontend)) + return POOL_END; break; } } @@ -1795,6 +1797,8 @@ POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_C ret = SimpleForwardToFrontend(kind1, frontend, backend); if (ret != POOL_CONTINUE) return ret; + if (pool_flush(frontend)) + return POOL_END; } if (ret != POOL_CONTINUE) [parent: a536699c5ee4]