From: Tatsuo Ishii Date: Tue, 28 Feb 2017 01:42:37 +0000 (+0900) Subject: Fix CommandComplete. X-Git-Url: http://git.postgresql.org/gitweb/static/developers.postgresql.org?a=commitdiff_plain;h=3e6b4e931279e98c5eb097bca77591bda9630b1f;p=pgpool2.git Fix CommandComplete. It still used sync map, now which is obsoleted. This gives strange errors upon receiving command complete message. Fix do_query(). It did not popd up saved messages in certain cases. I guess this was one of the cause of occasional regression failures. --- diff --git a/src/protocol/CommandComplete.c b/src/protocol/CommandComplete.c index c7543a780..d05033653 100644 --- a/src/protocol/CommandComplete.c +++ b/src/protocol/CommandComplete.c @@ -47,9 +47,9 @@ POOL_STATUS CommandComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac { int len, len1; char *p, *p1; + int i; POOL_SESSION_CONTEXT *session_context; POOL_CONNECTION *con; - int slot_id; /* Get session context */ session_context = pool_get_session_context(false); @@ -61,60 +61,51 @@ POOL_STATUS CommandComplete(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *bac handle_query_context(backend); /* - * Read backend data from the first valid node using sync map if operated - * in streaming replication mode with extended protocol. + * If operated in streaming replication mode and doing an extended query, + * read backend message according to the query context. */ - if (STREAM && pool_is_doing_extended_query_message()) + if (STREAM && pool_is_doing_extended_query_message()) { - slot_id = pool_get_nth_sync_map(0); - if (slot_id < 0) - return POOL_END; /* this should not happen */ + for (i=0;islots[slot_id]->con; + p = pool_read2(con, len); + if (p == NULL) + return POOL_END; + p1 = palloc(len); + memcpy(p1, p, len); + } + } } /* - * Oterwise read from "MASTER" node. + * Otherwise just read from master node. */ else { con = MASTER(backend); - } - - if (pool_read(con, &len, sizeof(len)) < 0) - return POOL_END; - - len = ntohl(len); - len -= 4; - len1 = len; - - p = pool_read2(con, len); - if (p == NULL) - return POOL_END; - p1 = palloc(len); - memcpy(p1, p, len); - /* - * If operated in streaming replication mode and extended query mode, we - * may need to read data from other node if any (SET or transaction - * statements). - */ - if (STREAM && pool_is_doing_extended_query_message()) - { - slot_id = pool_get_nth_sync_map(1); - if (slot_id >= 0) - { - con = backend->slots[slot_id]->con; + if (pool_read(con, &len, sizeof(len)) < 0) + return POOL_END; - if (pool_read(con, &len, sizeof(len)) < 0) - return POOL_END; + len = ntohl(len); + len -= 4; + len1 = len; - len = ntohl(len); - len -= 4; - - p = pool_read2(con, len); - if (p == NULL) - return POOL_END; - } + p = pool_read2(con, len); + if (p == NULL) + return POOL_END; + p1 = palloc(len); + memcpy(p1, p, len); } /* diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c index aac4a672c..2191bb640 100644 --- a/src/protocol/pool_process_query.c +++ b/src/protocol/pool_process_query.c @@ -2438,19 +2438,18 @@ void do_query(POOL_CONNECTION *backend, char *query, POOL_SELECT_RESULT **result { ereport(DEBUG1, (errmsg("do_query: all state completed. returning"))); - - if (data_pushed) - { - int poplen; - - pool_pop(backend, &poplen); - ereport(DEBUG1, - (errmsg("do_query: popped data len:%d", poplen))); - } - break; } } + + if (data_pushed) + { + int poplen; + + pool_pop(backend, &poplen); + ereport(DEBUG1, + (errmsg("do_query: popped data len:%d", poplen))); + } } /*