From 907feb23b0c61971c3284d66836c8b8e8e602578 Mon Sep 17 00:00:00 2001 From: kailixu Date: Sun, 4 Jun 2023 07:56:46 +0800 Subject: [PATCH 1/2] chore: unbind the dependency --- include/common/tglobal.h | 2 ++ source/common/src/tglobal.c | 4 ++++ source/libs/qworker/src/qwMsg.c | 3 +-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index ced94e0f11..48c70c652b 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -82,6 +82,7 @@ extern int64_t tsVndCommitMaxIntervalMs; // mnode extern int64_t tsMndSdbWriteDelta; extern int64_t tsMndLogRetention; +extern int8_t tsExpired; // monitor extern bool tsEnableMonitor; @@ -197,6 +198,7 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite); void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal, bool rewrite); int32_t taosApplyLocalCfg(SConfig *pCfg, char *name); void taosLocalCfgForbiddenToChange(char *name, bool *forbidden); +int8_t taosExpired(); #ifdef __cplusplus } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index c5646d92d1..7befe6c656 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -14,6 +14,7 @@ */ #define _DEFAULT_SOURCE +#include "os.h" #include "tglobal.h" #include "tconfig.h" #include "tgrant.h" @@ -73,6 +74,7 @@ int64_t tsVndCommitMaxIntervalMs = 600 * 1000; // mnode int64_t tsMndSdbWriteDelta = 200; int64_t tsMndLogRetention = 2000; +int8_t tsExpired = 0; // monitor bool tsEnableMonitor = true; @@ -1522,3 +1524,5 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite) { taosSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag, rewrite); uInfo("all debug flag are set to %d", flag); } + +int8_t taosExpired() { return atomic_load_8(&tsExpired); } diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index 231e597724..753df685ad 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -8,7 +8,6 @@ #include "tcommon.h" #include "tmsg.h" #include "tname.h" -#include "tgrant.h" int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **rsp) { int32_t msgSize = sizeof(SRetrieveTableRsp) + length; @@ -366,7 +365,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg, bool chkGran QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - if (chkGrant && (!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && (grantCheck(TSDB_GRANT_TIME) != TSDB_CODE_SUCCESS)) { + if (chkGrant && (!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && taosExpired()) { QW_ELOG("query failed cause of grant expired, msgMask:%d", msg.msgMask); tFreeSSubQueryMsg(&msg); QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED); From 87a086996e3089a75166e43cd54544375d6792c3 Mon Sep 17 00:00:00 2001 From: kailixu Date: Sun, 4 Jun 2023 09:07:04 +0800 Subject: [PATCH 2/2] chore: code optimization --- include/common/tglobal.h | 4 ++-- source/common/src/tglobal.c | 4 ++-- source/libs/qworker/src/qwMsg.c | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 48c70c652b..0898d32018 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -82,7 +82,7 @@ extern int64_t tsVndCommitMaxIntervalMs; // mnode extern int64_t tsMndSdbWriteDelta; extern int64_t tsMndLogRetention; -extern int8_t tsExpired; +extern int8_t tsGrant; // monitor extern bool tsEnableMonitor; @@ -198,7 +198,7 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite); void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal, bool rewrite); int32_t taosApplyLocalCfg(SConfig *pCfg, char *name); void taosLocalCfgForbiddenToChange(char *name, bool *forbidden); -int8_t taosExpired(); +int8_t taosGranted(); #ifdef __cplusplus } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 7befe6c656..42f082ac82 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -74,7 +74,7 @@ int64_t tsVndCommitMaxIntervalMs = 600 * 1000; // mnode int64_t tsMndSdbWriteDelta = 200; int64_t tsMndLogRetention = 2000; -int8_t tsExpired = 0; +int8_t tsGrant = 1; // monitor bool tsEnableMonitor = true; @@ -1525,4 +1525,4 @@ void taosSetAllDebugFlag(int32_t flag, bool rewrite) { uInfo("all debug flag are set to %d", flag); } -int8_t taosExpired() { return atomic_load_8(&tsExpired); } +int8_t taosGranted() { return atomic_load_8(&tsGrant); } diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index 753df685ad..508e957e26 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -8,6 +8,7 @@ #include "tcommon.h" #include "tmsg.h" #include "tname.h" +#include "tgrant.h" int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **rsp) { int32_t msgSize = sizeof(SRetrieveTableRsp) + length; @@ -365,7 +366,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg, bool chkGran QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - if (chkGrant && (!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && taosExpired()) { + if (chkGrant && (!TEST_SHOW_REWRITE_MASK(msg.msgMask)) && !taosGranted()) { QW_ELOG("query failed cause of grant expired, msgMask:%d", msg.msgMask); tFreeSSubQueryMsg(&msg); QW_ERR_RET(TSDB_CODE_GRANT_EXPIRED);