pgpool2.git / summary / log / commit / refs

commit    cbb414b93a319824c20fcd228af5c1c280ec8a9f
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Wed Jul 15 06:09:09 2009 +0000

    Fix bug with prepared statement deallocation:
    
    Subject: [Pgpool-general] Pgpool probelms
    From: Nimesh Satam <nimesh.satam@gmail.com>
    To: pgpool-general@pgfoundry.org
    Cc: Nimesh Satam <nimesh.zedo@gmail.com>
    Date: Wed, 17 Jun 2009 11:31:37 +0530
    
    This was caused a bug in reset_backend().
    
    if (qcnt >= qn + prepared_list.cnt)
    {
        reset_prepared_list(&prepared_list);
        return 2;
    }
    send_deallocate(backend, &prepared_list, qcnt - qn);
    return 1;
    
    Problem is, send_deallocate -> SimpleQuery("DEALLOCATE") calls
    del_prepared_list, which will decrement prepared_list.cnt. In short,
    incrementing of qcnt *and* decrementing of prepared_list.cnt happen at
    the same time. So deallocate is only called 1/2 times than it should
    be.
    
    Bug analysis and fix provided by Akio Ishida.


pool_process_query.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pool_process_query.c b/pool_process_query.c index b41764d83..d8ef5f12b 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -1671,12 +1671,14 @@ POOL_STATUS SimpleForwardToFrontend(char kind, POOL_CONNECTION *frontend, POOL_C free(p1); if (status) return POOL_END; - +#ifdef NOT_USED if (kind == 'A') /* notification response */ { pool_flush(frontend); /* we need to immediately notice to frontend */ } else if (kind == 'E') /* error response? */ +#endif + if (kind == 'E') /* error response? */ { int i; int res1; @@ -2051,13 +2053,13 @@ static int reset_backend(POOL_CONNECTION_POOL *backend, int qcnt) if (qcnt >= qn) { - if (qcnt >= qn + prepared_list.cnt) + if (prepared_list.cnt == 0) { reset_prepared_list(&prepared_list); return 2; } - send_deallocate(backend, &prepared_list, qcnt - qn); + send_deallocate(backend, &prepared_list, 0); return 1; } [parent: 6dc01c3b2294]