From de25890e12167568eb4d7d785fe1ff9e75540632 Mon Sep 17 00:00:00 2001 From: Mijamind Date: Tue, 16 Jan 2024 19:38:24 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E8=B5=84=E6=BA=90=E6=B1=A0=E5=8C=96?= =?UTF-8?q?=E3=80=91SPQ=E4=BF=AE=E5=A4=8Dnodename=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=95=B0=E6=8D=AE=E9=87=8D=E5=A4=8D=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/pgxc_single/pool/execRemote.cpp | 15 +++++++++++++-- src/gausskernel/process/tcop/postgres.cpp | 3 +++ 2 files changed, 16 insertions(+), 2 deletions(-) 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;