From f8e282644e8178fd61251b8186e661c4252c0f61 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 21 Jun 2022 16:44:49 +0800 Subject: [PATCH 1/3] test: minor changes --- source/dnode/mgmt/test/sut/src/server.cpp | 2 +- source/dnode/mnode/impl/test/user/user.cpp | 509 ++++++++++++++++++++- 2 files changed, 509 insertions(+), 2 deletions(-) diff --git a/source/dnode/mgmt/test/sut/src/server.cpp b/source/dnode/mgmt/test/sut/src/server.cpp index 2d874f3df5..de35b06b05 100644 --- a/source/dnode/mgmt/test/sut/src/server.cpp +++ b/source/dnode/mgmt/test/sut/src/server.cpp @@ -28,7 +28,7 @@ bool TestServer::Start() { taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE); taosThreadCreate(&threadId, &thAttr, serverLoop, NULL); taosThreadAttrDestroy(&thAttr); - taosMsleep(3100); + taosMsleep(2100); return true; } diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index 9002dcca5f..6aa28a9007 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -26,7 +26,514 @@ class MndTestUser : public ::testing::Test { Testbase MndTestUser::test; TEST_F(MndTestUser, 01_Show_User) { - uInfo("show users"); test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); EXPECT_EQ(test.GetShowRows(), 1); } + +TEST_F(MndTestUser, 02_Create_User) { + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, ""); + strcpy(createReq.pass, "p1"); + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT); + } + + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, "u1"); + strcpy(createReq.pass, ""); + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_PASS_FORMAT); + } + + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, "root"); + strcpy(createReq.pass, "1"); + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_ALREADY_EXIST); + } + + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, "u1"); + strcpy(createReq.pass, "p1"); + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 2); + } + + { + SDropUserReq dropReq = {0}; + strcpy(dropReq.user, "u1"); + + int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSDropUserReq(pReq, contLen, &dropReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 1); + } + + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, "u2"); + strcpy(createReq.pass, "p1"); + createReq.superUser = 1; + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 2); + } + + { + SDropUserReq dropReq = {0}; + strcpy(dropReq.user, "u2"); + + int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSDropUserReq(pReq, contLen, &dropReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 1); + } +} + +TEST_F(MndTestUser, 03_Alter_User) { + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, "u3"); + strcpy(createReq.pass, "p1"); + createReq.superUser = 1; + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 2); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_PASSWD; + strcpy(alterReq.user, ""); + strcpy(alterReq.pass, "p1"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_PASSWD; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, ""); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_PASS_FORMAT); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_PASSWD; + strcpy(alterReq.user, "u4"); + strcpy(alterReq.pass, "1"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_NOT_EXIST); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_PASSWD; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, "1"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_SUPERUSER; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, "1"); + alterReq.superUser = 1; + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, "1"); + strcpy(alterReq.dbname, "1.*"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_REMOVE_ALL_DB; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, "1"); + strcpy(alterReq.dbname, "1.*"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_ADD_READ_DB; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, "1"); + strcpy(alterReq.dbname, "d1"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_DB_NOT_EXIST); + } + + { + SCreateDbReq createReq = {0}; + strcpy(createReq.db, "1.d2"); + createReq.numOfVgroups = 2; + createReq.buffer = -1; + createReq.pageSize = -1; + createReq.pages = -1; + createReq.daysPerFile = 10 * 1440; + createReq.daysToKeep0 = 3650 * 1440; + createReq.daysToKeep1 = 3650 * 1440; + createReq.daysToKeep2 = 3650 * 1440; + createReq.minRows = 100; + createReq.maxRows = 4096; + createReq.fsyncPeriod = 3000; + createReq.walLevel = 1; + createReq.precision = 0; + createReq.compression = 2; + createReq.replications = 1; + createReq.strict = 1; + createReq.cacheLastRow = 0; + createReq.ignoreExist = 1; + + int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateDbReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DB, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_ADD_READ_DB; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, "1"); + strcpy(alterReq.dbname, "1.d2"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_ADD_READ_DB; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, "1"); + strcpy(alterReq.dbname, "1.d2"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SGetUserAuthReq authReq = {0}; + strcpy(authReq.user, "u3"); + int32_t contLen = tSerializeSGetUserAuthReq(NULL, 0, &authReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSGetUserAuthReq(pReq, contLen, &authReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_GET_USER_AUTH, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + SGetUserAuthRsp authRsp = {0}; + tDeserializeSGetUserAuthRsp(pRsp->pCont, pRsp->contLen, &authRsp); + EXPECT_STREQ(authRsp.user, "u3"); + EXPECT_EQ(authRsp.superAuth, 1); + int32_t numOfReadDbs = taosHashGetSize(authRsp.readDbs); + int32_t numOfWriteDbs = taosHashGetSize(authRsp.writeDbs); + EXPECT_EQ(numOfReadDbs, 1); + EXPECT_EQ(numOfWriteDbs, 0); + + char* dbname = (char*)taosHashGet(authRsp.readDbs, "1.d2", 4); + EXPECT_TRUE(dbname != NULL); + + taosHashCleanup(authRsp.readDbs); + taosHashCleanup(authRsp.writeDbs); + } + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_REMOVE_READ_DB; + strcpy(alterReq.user, "u3"); + strcpy(alterReq.pass, "1"); + strcpy(alterReq.dbname, "1.d2"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SDropUserReq dropReq = {0}; + strcpy(dropReq.user, "u3"); + + int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSDropUserReq(pReq, contLen, &dropReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 1); + } +} + +TEST_F(MndTestUser, 05_Drop_User) { + { + SDropUserReq dropReq = {0}; + strcpy(dropReq.user, ""); + + int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSDropUserReq(pReq, contLen, &dropReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_INVALID_USER_FORMAT); + } + + { + SDropUserReq dropReq = {0}; + strcpy(dropReq.user, "u4"); + + int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSDropUserReq(pReq, contLen, &dropReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, TSDB_CODE_MND_USER_NOT_EXIST); + } + + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, "u1"); + strcpy(createReq.pass, "p1"); + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SDropUserReq dropReq = {0}; + strcpy(dropReq.user, "u1"); + + int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSDropUserReq(pReq, contLen, &dropReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 1); +} + +TEST_F(MndTestUser, 06_Create_Drop_Alter_User) { + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, "u1"); + strcpy(createReq.pass, "p1"); + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + { + SCreateUserReq createReq = {0}; + strcpy(createReq.user, "u2"); + strcpy(createReq.pass, "p2"); + + int32_t contLen = tSerializeSCreateUserReq(NULL, 0, &createReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSCreateUserReq(pReq, contLen, &createReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 3); + + { + SAlterUserReq alterReq = {0}; + alterReq.alterType = TSDB_ALTER_USER_PASSWD; + strcpy(alterReq.user, "u1"); + strcpy(alterReq.pass, "p2"); + + int32_t contLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSAlterUserReq(pReq, contLen, &alterReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 3); + { + SDropUserReq dropReq = {0}; + strcpy(dropReq.user, "u1"); + + int32_t contLen = tSerializeSDropUserReq(NULL, 0, &dropReq); + void* pReq = rpcMallocCont(contLen); + tSerializeSDropUserReq(pReq, contLen, &dropReq); + + SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_USER, pReq, contLen); + ASSERT_NE(pRsp, nullptr); + ASSERT_EQ(pRsp->code, 0); + } + + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 2); + + // restart + test.Restart(); + + taosMsleep(1000); + test.SendShowReq(TSDB_MGMT_TABLE_USER, "user_users", ""); + EXPECT_EQ(test.GetShowRows(), 2); +} From 49bc330c099784cef18b3149027ede7e6fa0d3ed Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 21 Jun 2022 16:47:28 +0800 Subject: [PATCH 2/3] refactor: adjut gtid logs --- source/libs/transport/inc/transLog.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/libs/transport/inc/transLog.h b/source/libs/transport/inc/transLog.h index caca842c6d..81099941c6 100644 --- a/source/libs/transport/inc/transLog.h +++ b/source/libs/transport/inc/transLog.h @@ -24,16 +24,16 @@ extern "C" { #include "tlog.h" #include "ttrace.h" -#define tFatal(...) do {if (rpcDebugFlag & DEBUG_FATAL){ taosPrintLog("RPC FATAL ", DEBUG_FATAL, rpcDebugFlag, __VA_ARGS__); }} while (0) -#define tError(...)do { if (rpcDebugFlag & DEBUG_ERROR){ taosPrintLog("RPC ERROR ", DEBUG_ERROR, rpcDebugFlag, __VA_ARGS__); } } while(0) -#define tWarn(...) do { if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("RPC WARN ", DEBUG_WARN, rpcDebugFlag, __VA_ARGS__); }} while(0) -#define tInfo(...) do { if (rpcDebugFlag & DEBUG_INFO) { taosPrintLog("RPC ", DEBUG_INFO, rpcDebugFlag, __VA_ARGS__); }} while(0) -#define tDebug(...) do {if (rpcDebugFlag & DEBUG_DEBUG){ taosPrintLog("RPC ", DEBUG_DEBUG, rpcDebugFlag, __VA_ARGS__); }} while(0) -#define tTrace(...) do {if (rpcDebugFlag & DEBUG_TRACE){ taosPrintLog("RPC ", DEBUG_TRACE, rpcDebugFlag, __VA_ARGS__); }} while(0) -#define tDump(x, y) do {if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); } } while(0) +#define tFatal(...) { if (rpcDebugFlag & DEBUG_FATAL) { taosPrintLog("RPC FATAL ", DEBUG_FATAL, rpcDebugFlag, __VA_ARGS__); }} +#define tError(...) { if (rpcDebugFlag & DEBUG_ERROR ){ taosPrintLog("RPC ERROR ", DEBUG_ERROR, rpcDebugFlag, __VA_ARGS__); }} +#define tWarn(...) { if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("RPC WARN ", DEBUG_WARN, rpcDebugFlag, __VA_ARGS__); }} +#define tInfo(...) { if (rpcDebugFlag & DEBUG_INFO) { taosPrintLog("RPC ", DEBUG_INFO, rpcDebugFlag, __VA_ARGS__); }} +#define tDebug(...) { if (rpcDebugFlag & DEBUG_DEBUG) { taosPrintLog("RPC ", DEBUG_DEBUG, rpcDebugFlag, __VA_ARGS__); }} +#define tTrace(...) { if (rpcDebugFlag & DEBUG_TRACE) { taosPrintLog("RPC ", DEBUG_TRACE, rpcDebugFlag, __VA_ARGS__); }} +#define tDump(x, y) { if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); } } //#define tTR(param, ...) do { char buf[40] = {0};TRACE_TO_STR(trace, buf);tTrace("TRID: %s "param, buf, __VA_ARGS__);} while(0) -#define tGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ", gtid:%s", __VA_ARGS__, buf);} while(0) +#define tGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ", gtid:%s", __VA_ARGS__, buf);} // clang-format on #ifdef __cplusplus From 23e921d41b5f3f4a8486313333c237dace17b4dd Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 21 Jun 2022 18:03:54 +0800 Subject: [PATCH 3/3] fix: invalid write while encode password --- source/common/src/tmsg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 7e9ce34f9f..de1a61567f 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -127,7 +127,7 @@ int32_t tEncodeSEpSet(SEncoder *pEncoder, const SEpSet *pEp) { if (tEncodeI8(pEncoder, pEp->numOfEps) < 0) return -1; for (int32_t i = 0; i < TSDB_MAX_REPLICA; i++) { if (tEncodeU16(pEncoder, pEp->eps[i].port) < 0) return -1; - if (tEncodeCStr(pEncoder, pEp->eps[i].fqdn) < 0) return -1; + if (tEncodeCStrWithLen(pEncoder, pEp->eps[i].fqdn, TSDB_FQDN_LEN) < 0) return -1; } return 0; } @@ -3054,7 +3054,7 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) { if (tEncodeCStr(&encoder, pReq->app) < 0) return -1; if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; if (tEncodeCStr(&encoder, pReq->user) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->passwd) < 0) return -1; + if (tEncodeCStrWithLen(&encoder, pReq->passwd, TSDB_PASSWORD_LEN) < 0) return -1; if (tEncodeI64(&encoder, pReq->startTime) < 0) return -1; tEndEncode(&encoder);