summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Deolasee2015-07-09 05:27:47 +0000
committerPavan Deolasee2015-07-09 05:27:47 +0000
commitfbb248f9d70de66b556971285826eb338d687f9b (patch)
tree40ac928c7431056f0d17cc2506271ccc6829ad1e
parentf5d6c24e0464e6137a035b1c55f419a82d412460 (diff)
Fix broken protocol between clients and GTM for snapshot messages
We'd recently changed handling of MSG_SNAPSHOT_GET and MSG_SNAPSHOT_MULTI_GET messages on GTM and GTM proxy. But that broke the case when the setup does not include any proxies. This patch fixes that case. Report by Stas Kelvich. Patch by me
-rw-r--r--src/gtm/client/gtm_client.c6
-rw-r--r--src/gtm/main/gtm_snap.c5
-rw-r--r--src/gtm/proxy/proxy_main.c4
3 files changed, 11 insertions, 4 deletions
diff --git a/src/gtm/client/gtm_client.c b/src/gtm/client/gtm_client.c
index d4cc9d6324..db45dbe39e 100644
--- a/src/gtm/client/gtm_client.c
+++ b/src/gtm/client/gtm_client.c
@@ -968,10 +968,14 @@ get_snapshot(GTM_Conn *conn, GlobalTransactionId gxid, bool canbe_grouped)
{
GTM_Result *res = NULL;
time_t finish_time;
+ GTM_ResultType res_type;
+
+ res_type = canbe_grouped ? SNAPSHOT_GET_MULTI_RESULT : SNAPSHOT_GET_RESULT;
/* Start the message. */
if (gtmpqPutMsgStart('C', true, conn) ||
gtmpqPutInt(canbe_grouped ? MSG_SNAPSHOT_GET_MULTI : MSG_SNAPSHOT_GET, sizeof (GTM_MessageType), conn) ||
+ gtmpqPutInt(1, sizeof (int), conn) ||
gtmpqPutnchar((char *)&gxid, sizeof (GlobalTransactionId), conn))
goto send_failed;
@@ -993,7 +997,7 @@ get_snapshot(GTM_Conn *conn, GlobalTransactionId gxid, bool canbe_grouped)
if (res->gr_status == GTM_RESULT_OK)
{
- Assert(res->gr_type == SNAPSHOT_GET_RESULT);
+ Assert(res->gr_type == res_type);
/*
* !!FIXME - The following assertion fails when snapshots are requested
* in non-grouping mode. We did some investigations and it appears that
diff --git a/src/gtm/main/gtm_snap.c b/src/gtm/main/gtm_snap.c
index 24651c8d56..9a9a78bfd0 100644
--- a/src/gtm/main/gtm_snap.c
+++ b/src/gtm/main/gtm_snap.c
@@ -287,9 +287,12 @@ ProcessGetSnapshotCommand(Port *myport, StringInfo message, bool get_gxid)
GTM_Snapshot snapshot;
MemoryContext oldContext;
int status;
- int txn_count = 1;
+ int txn_count;
const char *data = NULL;
+ txn_count = pq_getmsgint(message, sizeof (int));
+ Assert(txn_count == 1);
+
data = pq_getmsgbytes(message, sizeof (gxid));
if (data == NULL)
ereport(ERROR,
diff --git a/src/gtm/proxy/proxy_main.c b/src/gtm/proxy/proxy_main.c
index fbb6cfa8c4..2ea1b1025a 100644
--- a/src/gtm/proxy/proxy_main.c
+++ b/src/gtm/proxy/proxy_main.c
@@ -1911,8 +1911,7 @@ ProcessResponse(GTMProxy_ThreadInfo *thrinfo, GTMProxy_CommandInfo *cmdinfo,
int status = STATUS_OK;
pq_beginmessage(&buf, 'S');
- pq_sendint(&buf, SNAPSHOT_GET_RESULT, 4);
- pq_sendbytes(&buf, (char *)&cmdinfo->ci_data.cd_snap.gxid, sizeof (GlobalTransactionId));
+ pq_sendint(&buf, SNAPSHOT_GET_MULTI_RESULT, 4);
pq_sendbytes(&buf, (char *)&txn_count, sizeof (txn_count));
pq_sendbytes(&buf, (char *)&status, sizeof (status));
pq_sendbytes(&buf, (char *)&res->gr_snapshot.sn_xmin, sizeof (GlobalTransactionId));
@@ -2331,6 +2330,7 @@ ProcessSnapshotCommand(GTMProxy_ConnectionInfo *conninfo, GTM_Conn *gtm_conn,
case MSG_SNAPSHOT_GET_MULTI:
{
{
+ int txn_count = pq_getmsgint(message, sizeof (int));
const char *data = pq_getmsgbytes(message,
sizeof (GlobalTransactionId));
if (data == NULL)