From be3438fc5bb1983b943e63381f7887f785f93df1 Mon Sep 17 00:00:00 2001 From: kailixu Date: Thu, 21 Sep 2023 16:12:46 +0800 Subject: [PATCH] enh: erase dup notification --- source/client/inc/clientInt.h | 1 + source/client/src/clientHb.c | 13 ++++++++++++- tests/script/api/passwdTest.c | 16 +++++++++------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index e09b5670d3..e524a95565 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -151,6 +151,7 @@ typedef struct STscObj { char sDetailVer[128]; int8_t sysInfo; int8_t connType; + int8_t dropped; int32_t acctId; uint32_t connId; int64_t id; // ref ID returned by taosAddRef diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 41c26d9375..9d24bd3753 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -96,7 +96,8 @@ static int32_t hbUpdateUserAuthInfo(SAppHbMgr *pAppHbMgr, SUserAuthBatchRsp *bat } } - if (pRsp->dropped == 1) { + if (pRsp->dropped == 1 && pTscObj->dropped == 0) { + pTscObj->dropped = 1; if (pTscObj->userDroppedInfo.fp) { SPassInfo *dropInfo = &pTscObj->userDroppedInfo; if (dropInfo->fp) { @@ -779,6 +780,16 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req SHbParam *hbParam = (SHbParam *)param; SCatalog *pCatalog = NULL; + STscObj *pTscObj = (STscObj *)acquireTscObj(connKey->tscRid); + if (!pTscObj) { + tscWarn("tscObj rid %" PRIx64 " not exist", connKey->tscRid); + return TSDB_CODE_APP_ERROR; + } else if (pTscObj->dropped) { + tscDebug("tscObj rid %" PRIx64 " user:%s dropped", connKey->tscRid, pTscObj->user); + releaseTscObj(connKey->tscRid); + return TSDB_CODE_SUCCESS; + } + if (hbParam->reqCnt == 0) { code = catalogGetHandle(hbParam->clusterId, &pCatalog); if (code != TSDB_CODE_SUCCESS) { diff --git a/tests/script/api/passwdTest.c b/tests/script/api/passwdTest.c index 4a5d76e60c..24059bd35d 100644 --- a/tests/script/api/passwdTest.c +++ b/tests/script/api/passwdTest.c @@ -298,11 +298,12 @@ void passVerTestMulti(const char *host, char *qstr) { } fprintf(stderr, "######## %s #########\n", __func__); - if (nPassVerNotified >= nConn) { - fprintf(stderr, ">>> succeed to get passVer notification since nNotify %d >= nConn %d\n", nPassVerNotified, + if (nPassVerNotified == nConn) { + fprintf(stderr, ">>> succeed to get passVer notification since nNotify %d == nConn %d\n", nPassVerNotified, nConn); } else { - fprintf(stderr, ">>> failed to get passVer notification since nNotify %d < nConn %d\n", nPassVerNotified, nConn); + fprintf(stderr, ">>> failed to get passVer notification since nNotify %d != nConn %d\n", nPassVerNotified, nConn); + exit(1); } fprintf(stderr, "######## %s #########\n", __func__); // sleep(300); @@ -416,7 +417,7 @@ void userDroppedTest(TAOS *taos, const char *host, char *qstr) { int nConn = nTestUsers; for (int i = 0; i < 15; ++i) { - printf("%s:%d [%d] second(s) elasped, passVer notification received:%d, total:%d\n", __func__, __LINE__, i, + printf("%s:%d [%d] second(s) elasped, user dropped notification received:%d, total:%d\n", __func__, __LINE__, i, nUserDropped, nConn); if (nUserDropped >= nConn) break; sleep(1); @@ -429,10 +430,11 @@ void userDroppedTest(TAOS *taos, const char *host, char *qstr) { } fprintf(stderr, "######## %s #########\n", __func__); - if (nUserDropped >= nConn) { - fprintf(stderr, ">>> succeed to get user dropped notification since nNotify %d >= nConn %d\n", nUserDropped, nConn); + if (nUserDropped == nConn) { + fprintf(stderr, ">>> succeed to get user dropped notification since nNotify %d == nConn %d\n", nUserDropped, nConn); } else { - fprintf(stderr, ">>> failed to get user dropped notification since nNotify %d < nConn %d\n", nUserDropped, nConn); + fprintf(stderr, ">>> failed to get user dropped notification since nNotify %d != nConn %d\n", nUserDropped, nConn); + exit(1); } fprintf(stderr, "######## %s #########\n", __func__); // sleep(300);