diff --git a/src/common/backend/pgxc_single/pool/execRemote.cpp b/src/common/backend/pgxc_single/pool/execRemote.cpp index b2fa2cb3e..43503b2e7 100755 --- a/src/common/backend/pgxc_single/pool/execRemote.cpp +++ b/src/common/backend/pgxc_single/pool/execRemote.cpp @@ -470,16 +470,27 @@ HandleDatanodeGxid(PGXCNodeHandle* conn, const char* msg_body, size_t len) static void HandleLibcommPort(PGXCNodeHandle *conn, const char *msg_body, size_t len) { Assert(msg_body != NULL); - Assert(len == sizeof(uint16) + sizeof(uint16)); errno_t rc = 0; uint16 n16; rc = memcpy_s(&n16, sizeof(uint16), msg_body, sizeof(uint16)); securec_check(rc, "\0", "\0"); conn->tcpCtlPort = ntohs(n16); - rc = memcpy_s(&n16, sizeof(uint16), msg_body + sizeof(uint16), sizeof(uint16)); + msg_body += sizeof(uint16); + rc = memcpy_s(&n16, sizeof(uint16), msg_body, sizeof(uint16)); securec_check(rc, "\0", "\0"); conn->listenPort = ntohs(n16); + msg_body += sizeof(uint16); elog(DEBUG1, "spq HandleLibcommPort get [%d:%d]", conn->tcpCtlPort, conn->listenPort); + rc = memcpy_s(&n16, sizeof(uint16), msg_body, sizeof(uint16)); + securec_check(rc, "\0", "\0"); + uint16 nodenamelen = ntohs(n16); + msg_body += sizeof(uint16); + char nodename[NAMEDATALEN]; + rc = memcpy_s(nodename, NAMEDATALEN * sizeof(char), msg_body, nodenamelen * sizeof(char)); + securec_check(rc, "\0", "\0"); + if (strcmp(conn->remoteNodeName, nodename) != 0) { + elog(ERROR, "remote name [%s] not match cluster map: [%s].", nodename, conn->remoteNodeName); + } } static void HandleDirectRead(PGXCNodeHandle *conn, const char *msg_body, size_t len) { diff --git a/src/gausskernel/process/tcop/postgres.cpp b/src/gausskernel/process/tcop/postgres.cpp index d4822c6b4..de887cdf5 100755 --- a/src/gausskernel/process/tcop/postgres.cpp +++ b/src/gausskernel/process/tcop/postgres.cpp @@ -10031,6 +10031,9 @@ int PostgresMain(int argc, char* argv[], const char* dbname, const char* usernam pq_beginmessage(&buf, 'l'); pq_sendint16(&buf, g_instance.attr.attr_network.comm_control_port); pq_sendint16(&buf, g_instance.attr.attr_network.comm_sctp_port); + uint16 len = strlen(g_instance.attr.attr_common.PGXCNodeName) + 1; + pq_sendint16(&buf, len); + pq_sendbytes(&buf, g_instance.attr.attr_common.PGXCNodeName, len); pq_endmessage(&buf); if (SS_PRIMARY_MODE && oidcount > 0) { StringInfoData bufoid;