!4753 【资源池化】SPQ修复nodename配置错误数据重复问题

Merge pull request !4753 from 阙鸣健/spq_0110
This commit is contained in:
opengauss_bot
2024-01-17 08:06:35 +00:00
committed by Gitee
2 changed files with 16 additions and 2 deletions

View File

@ -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)
{

View File

@ -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;