pgpool2.git / summary / log / commit / refs

commit    38091cf9c7366f4a87d59830a19fa17b37dcd653
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Sun Dec 10 12:04:15 2017 +0000

    Fix returning transaction state when "ready for query" message received.
    
    We return primary or master node state of ready for query message to
    frontend. In most cases this is good. However if other than primary
    node or master node returns an error state (this could happen if load
    balance node is other than primary or master node and the query is an
    errornous SELECT), this should be returned to frontend, because the
    frontend already received an error.
    
    How much this affects to applications is not clear. However this
    behavior has been there for long time, probably applications do not
    care the state returned by ready for query message.


src/protocol/pool_proto_modules.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c index 25b7b3635..ecedfdfd3 100644 --- a/src/protocol/pool_proto_modules.c +++ b/src/protocol/pool_proto_modules.c @@ -1660,6 +1660,7 @@ POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, POOL_SESSION_CONTEXT *session_context; Node *node = NULL; char *query = NULL; + bool got_estate = false; /* * It is possible that the "ignore until sync is received" flag was set if @@ -1830,6 +1831,13 @@ POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, { state = kind; } + /* + * However, if the state is 'E', then frontend should had been + * already reported an ERROR. So, to match with that, let be the + * state to be returned to frontend. + */ + if (kind == 'E') + got_estate = true; } } @@ -1841,6 +1849,8 @@ POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, { len = htonl(len); pool_write(frontend, &len, sizeof(len)); + if (got_estate) + state = 'E'; pool_write(frontend, &state, 1); } pool_flush(frontend); [parent: 33920145b3f4]