diff options
author | Michael P | 2010-12-14 01:09:29 +0000 |
---|---|---|
committer | Pavan Deolasee | 2011-05-19 16:45:25 +0000 |
commit | 70a0cc86dc29fe971fa47718b4eba3b52d1259c3 (patch) | |
tree | d117b5d1ea1187cf6fc19a5aa16122da30a916f7 | |
parent | 688ecc154215357b1ae429dc872286d5bd1812af (diff) |
Change Protocol connection between PGXC nodes and GTM/GTM-Proxy.
This patch uses several node types to identify what is connecting on GTM
PGXC_NODE_GTM_PROXY
PGXC_NODE_GTM_PROXY_POSTMASTER
PGXC_NODE_COORDINATOR
PGXC_NODE_DATANODE
If a Postmaster gets a connection on GTM, it also identifies itself like this.
This is a prerequisite for Node and Proxy registration on GTM.
-rw-r--r-- | src/backend/access/transam/gtm.c | 23 | ||||
-rw-r--r-- | src/gtm/client/fe-connect.c | 22 | ||||
-rw-r--r-- | src/gtm/client/fe-protocol.c | 10 | ||||
-rw-r--r-- | src/gtm/client/gtm_client.c | 10 | ||||
-rw-r--r-- | src/gtm/client/test/test_seq.c | 10 | ||||
-rw-r--r-- | src/gtm/client/test/test_snap.c | 5 | ||||
-rw-r--r-- | src/gtm/client/test/test_snapperf.c | 5 | ||||
-rw-r--r-- | src/gtm/client/test/test_txn.c | 10 | ||||
-rw-r--r-- | src/gtm/client/test/test_txnperf.c | 12 | ||||
-rw-r--r-- | src/gtm/common/elog.c | 2 | ||||
-rw-r--r-- | src/gtm/main/gtm_seq.c | 34 | ||||
-rw-r--r-- | src/gtm/main/gtm_snap.c | 8 | ||||
-rw-r--r-- | src/gtm/main/gtm_txn.c | 62 | ||||
-rw-r--r-- | src/gtm/main/main.c | 23 | ||||
-rw-r--r-- | src/gtm/proxy/proxy_main.c | 36 | ||||
-rw-r--r-- | src/include/gtm/gtm.h | 4 | ||||
-rw-r--r-- | src/include/gtm/gtm_c.h | 21 | ||||
-rw-r--r-- | src/include/gtm/gtm_txn.h | 4 | ||||
-rw-r--r-- | src/include/gtm/libpq-be.h | 5 | ||||
-rw-r--r-- | src/include/gtm/libpq-int.h | 8 |
20 files changed, 181 insertions, 133 deletions
diff --git a/src/backend/access/transam/gtm.c b/src/backend/access/transam/gtm.c index fafa0b7cab..a4645780b7 100644 --- a/src/backend/access/transam/gtm.c +++ b/src/backend/access/transam/gtm.c @@ -16,6 +16,8 @@ #include "access/gtm.h" #include "access/transam.h" #include "utils/elog.h" +#include "miscadmin.h" +#include "pgxc/pgxc.h" /* Configuration variables */ char *GtmHost = "localhost"; @@ -29,7 +31,6 @@ static GTM_Conn *conn; #define CheckConnection() \ if (GTMPQstatus(conn) != CONNECTION_OK) InitGTM() - bool IsGTMConnected() { @@ -42,7 +43,21 @@ InitGTM() /* 256 bytes should be enough */ char conn_str[256]; - sprintf(conn_str, "host=%s port=%d coordinator_id=%d", GtmHost, GtmPort, PGXCNodeId); + /* If this thread is postmaster itself, it contacts gtm identifying itself */ + if (!IsUnderPostmaster) + { + GTM_PGXCNodeType remote_type = PGXC_NODE_DEFAULT; + + if (IS_PGXC_COORDINATOR) + remote_type = PGXC_NODE_COORDINATOR; + else if (IS_PGXC_DATANODE) + remote_type = PGXC_NODE_DATANODE; + + sprintf(conn_str, "host=%s port=%d pgxc_node_id=%d remote_type=%d postmaster=1", + GtmHost, GtmPort, PGXCNodeId, remote_type); + } + else + sprintf(conn_str, "host=%s port=%d pgxc_node_id=%d", GtmHost, GtmPort, PGXCNodeId); conn = PQconnectGTM(conn_str); if (GTMPQstatus(conn) != CONNECTION_OK) @@ -51,9 +66,9 @@ InitGTM() ereport(WARNING, (errcode(ERRCODE_CONNECTION_EXCEPTION), - errmsg("can not connect to GTM: %m"))); + errmsg("can not connect to GTM: %m"))); - errno = save_errno; + errno = save_errno; CloseGTM(); } diff --git a/src/gtm/client/fe-connect.c b/src/gtm/client/fe-connect.c index 29d8fe4cc5..5a2ad1d953 100644 --- a/src/gtm/client/fe-connect.c +++ b/src/gtm/client/fe-connect.c @@ -54,8 +54,9 @@ static const GTMPQconninfoOption GTMPQconninfoOptions[] = { {"host", NULL}, {"hostaddr", NULL}, {"port", NULL}, - {"coordinator_id", NULL}, - {"proxy", NULL}, + {"pgxc_node_id", NULL}, + {"remote_type", NULL}, + {"postmaster", NULL}, /* Terminating entry --- MUST BE LAST */ {NULL, NULL} }; @@ -168,10 +169,12 @@ connectOptions1(GTM_Conn *conn, const char *conninfo) conn->pgport = tmp ? strdup(tmp) : NULL; tmp = conninfo_getval(connOptions, "connect_timeout"); conn->connect_timeout = tmp ? strdup(tmp) : NULL; - tmp = conninfo_getval(connOptions, "coordinator_id"); - conn->coordinator_id = tmp ? strdup(tmp) : NULL; - tmp = conninfo_getval(connOptions, "proxy"); - conn->is_proxy = tmp ? atoi(tmp) : 0; + tmp = conninfo_getval(connOptions, "pgxc_node_id"); + conn->pgxc_node_id = tmp ? strdup(tmp) : NULL; + tmp = conninfo_getval(connOptions, "postmaster"); + conn->is_postmaster = tmp ? atoi(tmp) : 0; + tmp = conninfo_getval(connOptions, "remote_type"); + conn->remote_type = tmp ? atoi(tmp) : PGXC_NODE_DEFAULT; /* * Free the option info - all is in conn now @@ -661,14 +664,15 @@ keep_going: /* We will come back to here until there is /* * Build a startup packet. We tell the GTM server/proxy our - * coordinator ID and whether we are a proxy or not. + * PGXC Node ID and whether we are a proxy or not. * * When the connection is made from the proxy, we let the GTM * server know about it so that some special headers are * handled correctly by the server. */ - sp.sp_cid = atoi(conn->coordinator_id); - sp.sp_isproxy = conn->is_proxy; + sp.sp_cid = atoi(conn->pgxc_node_id); + sp.sp_remotetype = conn->remote_type; + sp.sp_ispostmaster = conn->is_postmaster; /* * Send the startup packet. diff --git a/src/gtm/client/fe-protocol.c b/src/gtm/client/fe-protocol.c index cb735c2b4a..117f89fa0a 100644 --- a/src/gtm/client/fe-protocol.c +++ b/src/gtm/client/fe-protocol.c @@ -57,7 +57,7 @@ pqParseInput(GTM_Conn *conn) memset(conn->result, 0, sizeof (GTM_Result)); } else - gtmpqFreeResultData(conn->result, conn->is_proxy); + gtmpqFreeResultData(conn->result, conn->remote_type); result = conn->result; @@ -186,7 +186,7 @@ gtmpqGetError(GTM_Conn *conn, GTM_Result *result) * If we are a GTM proxy, expect an additional proxy header in the incoming * message. */ - if (conn->is_proxy) + if (conn->remote_type == PGXC_NODE_GTM_PROXY) { if (gtmpqGetnchar((char *)&result->gr_proxyhdr, sizeof (GTM_ProxyMsgHeader), conn)) @@ -298,7 +298,7 @@ gtmpqParseSuccess(GTM_Conn *conn, GTM_Result *result) return 1; result->gr_msglen -= 4; - if (conn->is_proxy) + if (conn->remote_type == PGXC_NODE_GTM_PROXY) { if (gtmpqGetnchar((char *)&result->gr_proxyhdr, sizeof (GTM_ProxyMsgHeader), conn)) @@ -623,14 +623,14 @@ gtmpqReadSeqKey(GTM_SequenceKey seqkey, GTM_Conn *conn) } void -gtmpqFreeResultData(GTM_Result *result, bool is_proxy) +gtmpqFreeResultData(GTM_Result *result, GTM_PGXCNodeType remote_type) { /* * If we are running as a GTM proxy, we don't have anything to do. This may * change though as we add more message types below and some of them may * need cleanup even at the proxy level */ - if (is_proxy) + if (remote_type == PGXC_NODE_GTM_PROXY) return; switch (result->gr_type) diff --git a/src/gtm/client/gtm_client.c b/src/gtm/client/gtm_client.c index 6ff39962c2..08911d89e2 100644 --- a/src/gtm/client/gtm_client.c +++ b/src/gtm/client/gtm_client.c @@ -27,7 +27,7 @@ #include "gtm/gtm_msg.h" #include "gtm/assert.h" -void GTM_FreeResult(GTM_Result *result, bool is_proxy); +void GTM_FreeResult(GTM_Result *result, GTM_PGXCNodeType remote_type); /* * Connection Management API @@ -279,7 +279,7 @@ start_prepared_transaction(GTM_Conn *conn, GlobalTransactionId gxid, char *gid, gtmpqPutc(true, conn) || gtmpqPutnchar((char *)&gxid, sizeof (GlobalTransactionId), conn) || /* Send also GID for an explicit prepared transaction */ - gtmpqPutInt(strlen(gid), sizeof (GTM_GIDLen), conn) || + gtmpqPutInt(strlen(gid), sizeof (GTM_StrLen), conn) || gtmpqPutnchar((char *) gid, strlen(gid), conn) || gtmpqPutInt(datanodecnt, sizeof (int), conn) || gtmpqPutInt(coordcnt, sizeof (int), conn)) @@ -386,7 +386,7 @@ get_gid_data(GTM_Conn *conn, gtmpqPutInt(isolevel, sizeof (GTM_IsolationLevel), conn) || gtmpqPutc(txn_read_only, conn) || /* Send also GID for an explicit prepared transaction */ - gtmpqPutInt(strlen(gid), sizeof (GTM_GIDLen), conn) || + gtmpqPutInt(strlen(gid), sizeof (GTM_StrLen), conn) || gtmpqPutnchar((char *) gid, strlen(gid), conn)) goto send_failed; @@ -792,10 +792,10 @@ send_failed: } void -GTM_FreeResult(GTM_Result *result, bool is_proxy) +GTM_FreeResult(GTM_Result *result, GTM_PGXCNodeType remote_type) { if (result == NULL) return; - gtmpqFreeResultData(result, is_proxy); + gtmpqFreeResultData(result, remote_type); free(result); } diff --git a/src/gtm/client/test/test_seq.c b/src/gtm/client/test/test_seq.c index da0ed91ee2..ba1981e4cf 100644 --- a/src/gtm/client/test/test_seq.c +++ b/src/gtm/client/test/test_seq.c @@ -15,8 +15,12 @@ main(int argc, char *argv[]) { int ii; pid_t parent_pid; + GTM_Conn *conn = NULL; + char connect_string[100]; - GTM_Conn *conn = PQconnectGTM("host=localhost port=6666 coordinator_id=1"); + sprintf(connect_string, "host=%s port=%d pgxc_node_id=1 remote_type=%d", PGXC_NODE_COORDINATOR); + + conn = PQconnectGTM(connect_string); if (conn == NULL) { client_log(("Error in connection")); @@ -36,7 +40,7 @@ main(int argc, char *argv[]) seqkey.gsk_keylen = strlen(buf); seqkey.gsk_key = buf; if (open_sequence(conn, &seqkey, 10, 1, 10000, 100, false)) - client_log(("Open seq failed\n")); + client_log(("Open seq failed\n")); else client_log(("Opened Sequence %s\n", seqkey.gsk_key)); } @@ -55,7 +59,7 @@ main(int argc, char *argv[]) /* * Each process now opens a new connection with the GTM */ - conn = PQconnectGTM("host=localhost port=6666 coordinator_id=1"); + conn = PQconnectGTM(connect_string); /* * Try to read/increment the sequence diff --git a/src/gtm/client/test/test_snap.c b/src/gtm/client/test/test_snap.c index a2ce2f965a..718ad3c24f 100644 --- a/src/gtm/client/test/test_snap.c +++ b/src/gtm/client/test/test_snap.c @@ -16,11 +16,14 @@ main(int argc, char *argv[]) int ii; GlobalTransactionId gxid[4000]; GTM_Conn *conn; + char connect_string[100]; for (ii = 0; ii < 3; ii++) fork(); - conn = PQconnectGTM("host=localhost port=6666 coordinator_id=1"); + sprintf(connect_string, "host=localhost port=6666 pgxc_node_id=1 remote_type=%d", PGXC_NODE_COORDINATOR); + + conn = PQconnectGTM(connect_string); if (conn == NULL) { client_log(("Error in connection\n")); diff --git a/src/gtm/client/test/test_snapperf.c b/src/gtm/client/test/test_snapperf.c index bc0e511e2b..3218c2ad9e 100644 --- a/src/gtm/client/test/test_snapperf.c +++ b/src/gtm/client/test/test_snapperf.c @@ -22,8 +22,11 @@ main(int argc, char *argv[]) GlobalTransactionId gxid[TXN_COUNT]; GTM_Conn *conn; + char connect_string[100]; - conn = PQconnectGTM("host=localhost port=6666 coordinator_id=1"); + sprintf(connect_string, "host=localhost port=6666 pgxc_node_id=1 remote_type=%d", PGXC_NODE_COORDINATOR); + + conn = PQconnectGTM(connect_string); if (conn == NULL) { client_log(("Error in connection\n")); diff --git a/src/gtm/client/test/test_txn.c b/src/gtm/client/test/test_txn.c index 01ed3decbd..2c805def13 100644 --- a/src/gtm/client/test/test_txn.c +++ b/src/gtm/client/test/test_txn.c @@ -17,11 +17,15 @@ main(int argc, char *argv[]) int ii; GlobalTransactionId gxid[4000]; GTM_Conn *conn; + char connect_string[100]; + GTM_Timestamp *timestamp; for (ii = 0; ii < 3; ii++) fork(); - conn = PQconnectGTM("host=localhost port=6666 coordinator_id=1"); + sprintf(connect_string, "host=localhost port=6666 pgxc_node_id=1 remote_type=%d", PGXC_NODE_COORDINATOR); + + conn = PQconnectGTM(connect_string); if (conn == NULL) { client_log(("Error in connection\n")); @@ -30,7 +34,7 @@ main(int argc, char *argv[]) for (ii = 0; ii < 20; ii++) { - gxid[ii] = begin_transaction(conn, GTM_ISOLATION_SERIALIZABLE); + gxid[ii] = begin_transaction(conn, GTM_ISOLATION_SERIALIZABLE, timestamp); if (gxid[ii] != InvalidGlobalTransactionId) client_log(("Started a new transaction (GXID:%u)\n", gxid[ii])); else @@ -43,7 +47,7 @@ main(int argc, char *argv[]) nodes[0] = 1; nodes[1] = 1; - if (!prepare_transaction(conn, gxid[ii], 2, nodes)) + if (!prepare_transaction(conn, gxid[ii])) client_log(("PREPARE successful (GXID:%u)\n", gxid[ii])); else client_log(("PREPARE failed (GXID:%u)\n", gxid[ii])); diff --git a/src/gtm/client/test/test_txnperf.c b/src/gtm/client/test/test_txnperf.c index 174f0a8bab..04b218eeb6 100644 --- a/src/gtm/client/test/test_txnperf.c +++ b/src/gtm/client/test/test_txnperf.c @@ -56,7 +56,7 @@ main(int argc, char *argv[]) int kk; char connect_string[100]; int gtmport; - int coordinator_id; + PGXCNodeId pgxc_node_id; int nclients; int ntxns_per_cli; int nstmts_per_txn; @@ -119,10 +119,10 @@ main(int argc, char *argv[]) break; case 'i': - coordinator_id = atoi(optarg); - sprintf(test_output, "TEST_OUTPUT_%d\0", coordinator_id); - sprintf(test_end, "TEST_END_%d\0", coordinator_id); - sprintf(test_output_csv, "TEST_OUTPUT_%d.CSV\0", coordinator_id); + pgxc_node_id = atoi(optarg); + sprintf(test_output, "TEST_OUTPUT_%d\0", pgxc_node_id); + sprintf(test_end, "TEST_END_%d\0", pgxc_node_id); + sprintf(test_output_csv, "TEST_OUTPUT_%d.CSV\0", pgxc_node_id); break; default: @@ -132,7 +132,7 @@ main(int argc, char *argv[]) } } - sprintf(connect_string, "host=%s port=%d coordinator_id=%d", gtmhost, gtmport, coordinator_id); + sprintf(connect_string, "host=%s port=%d pgxc_node_id=%d remote_type=%d", gtmhost, gtmport, pgxc_node_id, PGXC_NODE_COORDINATOR); sprintf(system_cmd, "echo -------------------------------------------------------- >> %s", test_output); system(system_cmd); diff --git a/src/gtm/common/elog.c b/src/gtm/common/elog.c index 626dc36925..65f28a2448 100644 --- a/src/gtm/common/elog.c +++ b/src/gtm/common/elog.c @@ -859,7 +859,7 @@ send_message_to_frontend(Port *myport, ErrorData *edata) /* 'N' (Notice) is for nonfatal conditions, 'E' is for errors */ pq_beginmessage(&msgbuf, (edata->elevel < ERROR) ? 'N' : 'E'); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; diff --git a/src/gtm/main/gtm_seq.c b/src/gtm/main/gtm_seq.c index 6d946a901f..390d0f6668 100644 --- a/src/gtm/main/gtm_seq.c +++ b/src/gtm/main/gtm_seq.c @@ -131,7 +131,7 @@ seq_release_seqinfo(GTM_SeqInfo *seqinfo) GTM_RWLockAcquire(&seqinfo->gs_lock, GTM_LOCKMODE_WRITE); Assert(seqinfo->gs_ref_count > 0); seqinfo->gs_ref_count--; - + if ((seqinfo->gs_state == SEQ_STATE_DELETED) && (seqinfo->gs_ref_count == 0)) remove = true; @@ -880,7 +880,7 @@ ProcessSequenceInitCommand(Port *myport, StringInfo message) */ pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SEQUENCE_INIT_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -890,7 +890,7 @@ ProcessSequenceInitCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, seqkey.gsk_key, seqkey.gsk_keylen); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); } @@ -948,7 +948,7 @@ ProcessSequenceAlterCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SEQUENCE_ALTER_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -958,7 +958,7 @@ ProcessSequenceAlterCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, seqkey.gsk_key, seqkey.gsk_keylen); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); } @@ -984,7 +984,7 @@ ProcessSequenceGetCurrentCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SEQUENCE_GET_CURRENT_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -995,7 +995,7 @@ ProcessSequenceGetCurrentCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)&seqval, sizeof (GTM_Sequence)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); } @@ -1020,7 +1020,7 @@ ProcessSequenceGetNextCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SEQUENCE_GET_NEXT_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1031,7 +1031,7 @@ ProcessSequenceGetNextCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)&seqval, sizeof (GTM_Sequence)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); } @@ -1078,7 +1078,7 @@ ProcessSequenceSetValCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SEQUENCE_SET_VAL_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1088,7 +1088,7 @@ ProcessSequenceSetValCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, seqkey.gsk_key, seqkey.gsk_keylen); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); } @@ -1112,7 +1112,7 @@ ProcessSequenceResetCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SEQUENCE_RESET_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1122,7 +1122,7 @@ ProcessSequenceResetCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, seqkey.gsk_key, seqkey.gsk_keylen); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); } @@ -1148,7 +1148,7 @@ ProcessSequenceCloseCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SEQUENCE_CLOSE_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1158,7 +1158,7 @@ ProcessSequenceCloseCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, seqkey.gsk_key, seqkey.gsk_keylen); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); } @@ -1200,7 +1200,7 @@ ProcessSequenceRenameCommand(Port *myport, StringInfo message) /* Send a SUCCESS message back to the client */ pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SEQUENCE_RENAME_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1210,7 +1210,7 @@ ProcessSequenceRenameCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, newseqkey.gsk_key, newseqkey.gsk_keylen); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); } diff --git a/src/gtm/main/gtm_snap.c b/src/gtm/main/gtm_snap.c index 5c9b4b2ae5..5c0125e4ac 100644 --- a/src/gtm/main/gtm_snap.c +++ b/src/gtm/main/gtm_snap.c @@ -345,7 +345,7 @@ ProcessGetSnapshotCommand(Port *myport, StringInfo message, bool get_gxid) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, get_gxid ? SNAPSHOT_GXID_GET_RESULT : SNAPSHOT_GET_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -362,7 +362,7 @@ ProcessGetSnapshotCommand(Port *myport, StringInfo message, bool get_gxid) sizeof(GlobalTransactionId) * snapshot->sn_xcnt); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; @@ -426,7 +426,7 @@ ProcessGetSnapshotCommandMulti(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, SNAPSHOT_GET_MULTI_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -442,7 +442,7 @@ ProcessGetSnapshotCommandMulti(Port *myport, StringInfo message) sizeof(GlobalTransactionId) * snapshot->sn_xcnt); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; diff --git a/src/gtm/main/gtm_txn.c b/src/gtm/main/gtm_txn.c index f3881978c8..252fc43984 100644 --- a/src/gtm/main/gtm_txn.c +++ b/src/gtm/main/gtm_txn.c @@ -632,7 +632,7 @@ SetNextGlobalTransactionId(GlobalTransactionId gxid) /* Transaction Control */ int -GTM_BeginTransactionMulti(GTM_CoordinatorId coord_id, +GTM_BeginTransactionMulti(GTM_PGXCNodeId coord_id, GTM_IsolationLevel isolevel[], bool readonly[], GTMProxy_ConnID connid[], @@ -729,7 +729,7 @@ GTM_BeginTransactionMulti(GTM_CoordinatorId coord_id, /* Transaction Control */ GTM_TransactionHandle -GTM_BeginTransaction(GTM_CoordinatorId coord_id, +GTM_BeginTransaction(GTM_PGXCNodeId coord_id, GTM_IsolationLevel isolevel, bool readonly) { @@ -1029,7 +1029,7 @@ ProcessBeginTransactionCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_BEGIN_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1039,7 +1039,7 @@ ProcessBeginTransactionCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)×tamp, sizeof (GTM_Timestamp)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1089,7 +1089,7 @@ ProcessBeginTransactionGetGXIDCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_BEGIN_GETGXID_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1099,7 +1099,7 @@ ProcessBeginTransactionGetGXIDCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)×tamp, sizeof (GTM_Timestamp)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1150,7 +1150,7 @@ ProcessBeginTransactionGetGXIDAutovacuumCommand(Port *myport, StringInfo message pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_BEGIN_GETGXID_AUTOVACUUM_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1159,7 +1159,7 @@ ProcessBeginTransactionGetGXIDAutovacuumCommand(Port *myport, StringInfo message pq_sendbytes(&buf, (char *)&gxid, sizeof(gxid)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1227,7 +1227,7 @@ ProcessBeginTransactionGetGXIDCommandMulti(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_BEGIN_GETGXID_MULTI_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1238,7 +1238,7 @@ ProcessBeginTransactionGetGXIDCommandMulti(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)&(timestamp), sizeof (GTM_Timestamp)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1291,7 +1291,7 @@ ProcessCommitTransactionCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_COMMIT_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1301,7 +1301,7 @@ ProcessCommitTransactionCommand(Port *myport, StringInfo message) pq_sendint(&buf, status, sizeof(status)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1362,7 +1362,7 @@ ProcessCommitPreparedTransactionCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_COMMIT_PREPARED_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1372,7 +1372,7 @@ ProcessCommitPreparedTransactionCommand(Port *myport, StringInfo message) pq_sendint(&buf, status[0], 4); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1408,7 +1408,7 @@ ProcessGetGIDDataTransactionCommand(Port *myport, StringInfo message) txn_read_only = pq_getmsgbyte(message); /* receive GID */ - gidlen = pq_getmsgint(message, sizeof (GTM_GIDLen)); + gidlen = pq_getmsgint(message, sizeof (GTM_StrLen)); gid = (char *)pq_getmsgbytes(message, gidlen); pq_getmsgend(message); @@ -1451,7 +1451,7 @@ ProcessGetGIDDataTransactionCommand(Port *myport, StringInfo message) */ pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_GET_GID_DATA_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1473,7 +1473,7 @@ ProcessGetGIDDataTransactionCommand(Port *myport, StringInfo message) pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1526,7 +1526,7 @@ ProcessRollbackTransactionCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_ROLLBACK_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1536,7 +1536,7 @@ ProcessRollbackTransactionCommand(Port *myport, StringInfo message) pq_sendint(&buf, status, sizeof(status)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1598,7 +1598,7 @@ ProcessCommitTransactionCommandMulti(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_COMMIT_MULTI_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1608,7 +1608,7 @@ ProcessCommitTransactionCommandMulti(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)status, sizeof(int) * txn_count); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1669,7 +1669,7 @@ ProcessRollbackTransactionCommandMulti(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_ROLLBACK_MULTI_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1679,7 +1679,7 @@ ProcessRollbackTransactionCommandMulti(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)status, sizeof(int) * txn_count); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1695,7 +1695,7 @@ ProcessStartPreparedTransactionCommand(Port *myport, StringInfo message) GlobalTransactionId gxid; int isgxid = 0; int datanodecnt,coordcnt; - GTM_GIDLen gidlen; + GTM_StrLen gidlen; PGXC_NodeId *coordinators = NULL; PGXC_NodeId *datanodes = NULL; MemoryContext oldContext; @@ -1724,7 +1724,7 @@ ProcessStartPreparedTransactionCommand(Port *myport, StringInfo message) } /* get GID */ - gidlen = pq_getmsgint(message, sizeof (GTM_GIDLen)); + gidlen = pq_getmsgint(message, sizeof (GTM_StrLen)); gid = (char *)pq_getmsgbytes(message, gidlen); /* Get Datanode Count Data */ @@ -1768,7 +1768,7 @@ ProcessStartPreparedTransactionCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_START_PREPARED_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1777,7 +1777,7 @@ ProcessStartPreparedTransactionCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)&gxid, sizeof(GlobalTransactionId)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1830,7 +1830,7 @@ ProcessPrepareTransactionCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_PREPARE_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1839,7 +1839,7 @@ ProcessPrepareTransactionCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)&gxid, sizeof(gxid)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } @@ -1885,7 +1885,7 @@ ProcessGetGXIDTransactionCommand(Port *myport, StringInfo message) pq_beginmessage(&buf, 'S'); pq_sendint(&buf, TXN_GET_GXID_RESULT, 4); - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) { GTM_ProxyMsgHeader proxyhdr; proxyhdr.ph_conid = myport->conn_id; @@ -1895,7 +1895,7 @@ ProcessGetGXIDTransactionCommand(Port *myport, StringInfo message) pq_sendbytes(&buf, (char *)&gxid, sizeof(gxid)); pq_endmessage(myport, &buf); - if (!myport->is_proxy) + if (myport->remote_type != PGXC_NODE_GTM_PROXY) pq_flush(myport); return; } diff --git a/src/gtm/main/main.c b/src/gtm/main/main.c index 1cba1ea860..118faabd53 100644 --- a/src/gtm/main/main.c +++ b/src/gtm/main/main.c @@ -75,8 +75,8 @@ static void ProcessSnapshotCommand(Port *myport, GTM_MessageType mtype, StringIn static void ProcessSequenceCommand(Port *myport, GTM_MessageType mtype, StringInfo message); static void ProcessQueryCommand(Port *myport, GTM_MessageType mtype, StringInfo message); -static void GTM_RegisterCoordinator(Port *myport, GTM_CoordinatorId coordinator_id); -static void GTM_UnregisterCoordinator(Port *myport, GTM_CoordinatorId coordinator_id); +static void GTM_RegisterPGXCNode(Port *myport, GTM_PGXCNodeId pgxc_node_id); +static void GTM_UnregisterPGXCNode(Port *myport, GTM_PGXCNodeId pgxc_node_id); static bool CreateOptsFile(int argc, char *argv[]); static void CreateDataDirLockFile(void); @@ -608,8 +608,9 @@ GTM_ThreadMain(void *argp) sizeof (GTM_StartupPacket)); pq_getmsgend(&inBuf); - GTM_RegisterCoordinator(thrinfo->thr_conn->con_port, sp.sp_cid); - thrinfo->thr_conn->con_port->is_proxy = sp.sp_isproxy; + GTM_RegisterPGXCNode(thrinfo->thr_conn->con_port, sp.sp_cid); + thrinfo->thr_conn->con_port->remote_type = sp.sp_remotetype; + thrinfo->thr_conn->con_port->is_postmaster = sp.sp_ispostmaster; } { @@ -751,7 +752,7 @@ ProcessCommand(Port *myport, StringInfo input_message) GTM_MessageType mtype; GTM_ProxyMsgHeader proxyhdr; - if (myport->is_proxy) + if (myport->remote_type == PGXC_NODE_GTM_PROXY) pq_copymsgbytes(input_message, (char *)&proxyhdr, sizeof (GTM_ProxyMsgHeader)); else proxyhdr.ph_conid = InvalidGTMProxyConnID; @@ -918,14 +919,14 @@ ReadCommand(Port *myport, StringInfo inBuf) static void ProcessCoordinatorCommand(Port *myport, GTM_MessageType mtype, StringInfo message) { - GTM_CoordinatorId cid; + GTM_PGXCNodeId cid; - cid = pq_getmsgint(message, sizeof (GTM_CoordinatorId)); + cid = pq_getmsgint(message, sizeof (GTM_PGXCNodeId)); switch (mtype) { case MSG_UNREGISTER_COORD: - GTM_UnregisterCoordinator(myport, cid); + GTM_UnregisterPGXCNode(myport, cid); break; default: @@ -1079,15 +1080,15 @@ ProcessQueryCommand(Port *myport, GTM_MessageType mtype, StringInfo message) } static void -GTM_RegisterCoordinator(Port *myport, GTM_CoordinatorId cid) +GTM_RegisterPGXCNode(Port *myport, GTM_PGXCNodeId cid) { elog(DEBUG3, "Registering coordinator with cid %d", cid); - myport->coordinator_id = cid; + myport->pgxc_node_id = cid; } static void -GTM_UnregisterCoordinator(Port *myport, GTM_CoordinatorId cid) +GTM_UnregisterPGXCNode(Port *myport, GTM_PGXCNodeId cid) { /* * Do a clean shutdown diff --git a/src/gtm/proxy/proxy_main.c b/src/gtm/proxy/proxy_main.c index 30f1d1b383..4275d91b02 100644 --- a/src/gtm/proxy/proxy_main.c +++ b/src/gtm/proxy/proxy_main.c @@ -85,14 +85,16 @@ static void ProcessCoordinatorCommand(GTMProxy_ConnectionInfo *conninfo, static void ProcessTransactionCommand(GTMProxy_ConnectionInfo *conninfo, GTM_Conn *gtm_conn, GTM_MessageType mtype, StringInfo message); static void ProcessSnapshotCommand(GTMProxy_ConnectionInfo *conninfo, - GTM_Conn *gtm_conn, GTM_MessageType mtype, StringInfo message); + GTM_Conn *gtm_conn, GTM_MessageType mtype, StringInfo message); static void ProcessSequenceCommand(GTMProxy_ConnectionInfo *conninfo, - GTM_Conn *gtm_conn, GTM_MessageType mtype, StringInfo message); + GTM_Conn *gtm_conn, GTM_MessageType mtype, StringInfo message); -static void GTMProxy_RegisterCoordinator(GTMProxy_ConnectionInfo *conninfo, - GTM_CoordinatorId coordinator_id); -static void GTMProxy_UnregisterCoordinator(GTMProxy_ConnectionInfo *conninfo, - GTM_CoordinatorId coordinator_id); +static void GTMProxy_RegisterPGXCNode(GTMProxy_ConnectionInfo *conninfo, + GTM_PGXCNodeId cid, + GTM_PGXCNodeType remote_type, + bool is_postmaster); +static void GTMProxy_UnregisterPGXCNode(GTMProxy_ConnectionInfo *conninfo, + GTM_PGXCNodeId pgxc_node_id); static void ProcessResponse(GTMProxy_ThreadInfo *thrinfo, GTMProxy_CommandInfo *cmdinfo, GTM_Result *res); @@ -598,8 +600,8 @@ GTMProxy_ThreadMain(void *argp) /* * Set up connection with the GTM server */ - sprintf(gtm_connect_string, "host=%s port=%d coordinator_id=1 proxy=1", - GTMServerHost, GTMServerPortNumber); + sprintf(gtm_connect_string, "host=%s port=%d pgxc_node_id=1 remote_type=%d", + GTMServerHost, GTMServerPortNumber, PGXC_NODE_GTM_PROXY); thrinfo->thr_gtm_conn = PQconnectGTM(gtm_connect_string); @@ -1244,14 +1246,14 @@ static void ProcessCoordinatorCommand(GTMProxy_ConnectionInfo *conninfo, GTM_Conn *gtm_conn, GTM_MessageType mtype, StringInfo message) { - GTM_CoordinatorId cid; + GTM_PGXCNodeId cid; - cid = pq_getmsgint(message, sizeof (GTM_CoordinatorId)); + cid = pq_getmsgint(message, sizeof (GTM_PGXCNodeId)); switch (mtype) { case MSG_UNREGISTER_COORD: - GTMProxy_UnregisterCoordinator(conninfo, cid); + GTMProxy_UnregisterPGXCNode(conninfo, cid); break; default: @@ -1448,15 +1450,17 @@ GTMProxy_CommandPending(GTMProxy_ConnectionInfo *conninfo, GTM_MessageType mtype return; } static void -GTMProxy_RegisterCoordinator(GTMProxy_ConnectionInfo *conninfo, GTM_CoordinatorId cid) +GTMProxy_RegisterPGXCNode(GTMProxy_ConnectionInfo *conninfo, GTM_PGXCNodeId cid, GTM_PGXCNodeType remote_type, bool is_postmaster) { - elog(DEBUG3, "Registering coordinator with cid %d", cid); - conninfo->con_port->coordinator_id = cid; + elog(DEBUG3, "Registering PGXC Node with cid %d", cid); + conninfo->con_port->pgxc_node_id = cid; + conninfo->con_port->remote_type = remote_type; + conninfo->con_port->is_postmaster = is_postmaster; } static void -GTMProxy_UnregisterCoordinator(GTMProxy_ConnectionInfo *conninfo, GTM_CoordinatorId cid) +GTMProxy_UnregisterPGXCNode(GTMProxy_ConnectionInfo *conninfo, GTM_PGXCNodeId cid) { /* * Do a clean shutdown @@ -1502,7 +1506,7 @@ GTMProxy_HandshakeConnection(GTMProxy_ConnectionInfo *conninfo) sizeof (GTM_StartupPacket)); pq_getmsgend(&inBuf); - GTMProxy_RegisterCoordinator(conninfo, sp.sp_cid); + GTMProxy_RegisterPGXCNode(conninfo, sp.sp_cid, sp.sp_remotetype, sp.sp_ispostmaster); /* * Send a dummy authentication request message 'R' as the client diff --git a/src/include/gtm/gtm.h b/src/include/gtm/gtm.h index 37e23a7ffa..77522b249a 100644 --- a/src/include/gtm/gtm.h +++ b/src/include/gtm/gtm.h @@ -131,10 +131,6 @@ extern MemoryContext TopMostMemoryContext; #if 0 -/* Coordinator registration */ -int GTM_RegisterCoordinator(GTM_CoordInfo *cinfo); -int GTM_UnregisterCoordinator(GTM_CoordinatorId cid); - #endif #endif diff --git a/src/include/gtm/gtm_c.h b/src/include/gtm/gtm_c.h index e8b9984721..f918592101 100644 --- a/src/include/gtm/gtm_c.h +++ b/src/include/gtm/gtm_c.h @@ -36,14 +36,26 @@ typedef uint32 GlobalTransactionId; /* 32-bit global transaction ids */ typedef uint32 PGXC_NodeId; -typedef uint32 GTM_CoordinatorId; typedef int16 GTMProxy_ConnID; -typedef uint32 GTM_GIDLen; +typedef uint32 GTM_StrLen; #define InvalidGTMProxyConnID -1 typedef pthread_t GTM_ThreadID; +typedef uint32 GTM_PGXCNodeId; +typedef uint32 GTM_PGXCNodePort; + +/* Possible type of nodes for registration */ +typedef enum GTM_PGXCNodeType +{ + PGXC_NODE_GTM_PROXY, + PGXC_NODE_GTM_PROXY_POSTMASTER, /* Used by Proxy to communicate with GTM and not use Proxy headers */ + PGXC_NODE_COORDINATOR, + PGXC_NODE_DATANODE, + PGXC_NODE_DEFAULT /* In case nothing is associated to connection */ +} GTM_PGXCNodeType; + /* * A unique handle to identify transaction at the GTM. It could just be * an index in an array or a pointer to the structure @@ -105,8 +117,9 @@ typedef struct GTM_SnapshotData typedef GTM_SnapshotData *GTM_Snapshot; typedef struct GTM_StartupPacket { - GTM_CoordinatorId sp_cid; - bool sp_isproxy; + GTM_PGXCNodeId sp_cid; + GTM_PGXCNodeType sp_remotetype; + bool sp_ispostmaster; } GTM_StartupPacket; #define InvalidGlobalTransactionId ((GlobalTransactionId) 0) diff --git a/src/include/gtm/gtm_txn.h b/src/include/gtm/gtm_txn.h index c883612e64..47444c6d4c 100644 --- a/src/include/gtm/gtm_txn.h +++ b/src/include/gtm/gtm_txn.h @@ -183,10 +183,10 @@ GTM_TransactionHandle GTM_GIDToHandle(char *gid); /* Transaction Control */ void GTM_InitTxnManager(void); -GTM_TransactionHandle GTM_BeginTransaction(GTM_CoordinatorId coord_id, +GTM_TransactionHandle GTM_BeginTransaction(GTM_PGXCNodeId pgxc_node_id, GTM_IsolationLevel isolevel, bool readonly); -int GTM_BeginTransactionMulti(GTM_CoordinatorId coord_id, +int GTM_BeginTransactionMulti(GTM_PGXCNodeId pgxc_node_id, GTM_IsolationLevel isolevel[], bool readonly[], GTMProxy_ConnID connid[], diff --git a/src/include/gtm/libpq-be.h b/src/include/gtm/libpq-be.h index 0a795def67..f8036fe7bc 100644 --- a/src/include/gtm/libpq-be.h +++ b/src/include/gtm/libpq-be.h @@ -47,8 +47,9 @@ typedef struct Port GTMProxy_ConnID conn_id; /* RequestID of this command */ - GTM_CoordinatorId coordinator_id; /* Coordinator ID */ - bool is_proxy; /* Is this a connection from GTM proxy ? */ + GTM_PGXCNodeType remote_type; /* Type of remote connection */ + GTM_PGXCNodeId pgxc_node_id; /* Coordinator ID */ + bool is_postmaster; /* Is remote a node postmaster? */ #define PQ_BUFFER_SIZE 8192 char PqSendBuffer[PQ_BUFFER_SIZE]; diff --git a/src/include/gtm/libpq-int.h b/src/include/gtm/libpq-int.h index 5956de8ff2..557a441d0f 100644 --- a/src/include/gtm/libpq-int.h +++ b/src/include/gtm/libpq-int.h @@ -42,9 +42,9 @@ struct gtm_conn * over above. */ char *pgport; /* the server's communication port */ char *connect_timeout; /* connection timeout (numeric string) */ - char *coordinator_id; /* coordinator id */ - int is_proxy; /* is this a connection to/from a proxy ? */ - + char *pgxc_node_id; /* PGXC Node id */ + int remote_type; /* is this a connection to/from a proxy ? */ + int is_postmaster; /* is this connection to/from a postmaster instance */ /* Optional file to write trace info to */ FILE *Pfdebug; @@ -121,7 +121,7 @@ extern int gtmpqWriteReady(GTM_Conn *conn); */ GTM_Result * GTMPQgetResult(GTM_Conn *conn); extern int gtmpqGetError(GTM_Conn *conn, GTM_Result *result); -void gtmpqFreeResultData(GTM_Result *result, bool is_proxy); +void gtmpqFreeResultData(GTM_Result *result, GTM_PGXCNodeType remote_type); #define SOCK_ERRNO errno #define SOCK_ERRNO_SET(e) (errno = (e)) |