fix:[TS-4921] errors in test
This commit is contained in:
parent
c35f947e70
commit
d4b31cfd8e
|
@ -277,6 +277,7 @@ void taosSetGlobalDebugFlag(int32_t flag);
|
|||
void taosSetDebugFlag(int32_t *pFlagPtr, const char *flagName, int32_t flagVal);
|
||||
void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
|
||||
int8_t taosGranted(int8_t type);
|
||||
int32_t taosSetSlowLogScope(char *pScope);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -31,9 +31,7 @@ typedef enum SQL_RESULT_CODE {
|
|||
SQL_RESULT_CANCEL = 2,
|
||||
} SQL_RESULT_CODE;
|
||||
|
||||
#define SLOW_LOG_SEND_SIZE 1024*1024
|
||||
extern tsem2_t monitorSem;
|
||||
extern STaosQueue* monitorQueue;
|
||||
#define SLOW_LOG_SEND_SIZE 8*1024
|
||||
|
||||
typedef struct {
|
||||
int64_t clusterId;
|
||||
|
@ -55,18 +53,14 @@ typedef struct {
|
|||
|
||||
void monitorClose();
|
||||
void monitorInit();
|
||||
void monitorSendAllSlowLogFromTempDir(void* pInst);
|
||||
|
||||
void monitorClientSQLReqInit(int64_t clusterKey);
|
||||
void monitorClientSlowQueryInit(int64_t clusterId);
|
||||
void monitorCreateClient(int64_t clusterId);
|
||||
void monitorCreateClientCounter(int64_t clusterId, const char* name, const char* help, size_t label_key_count, const char** label_keys);
|
||||
void monitorCounterInc(int64_t clusterId, const char* counterName, const char** label_values);
|
||||
void* monitorThreadFunc(void *param);
|
||||
void monitorFreeSlowLogData(MonitorSlowLogData* pData);
|
||||
const char* monitorResultStr(SQL_RESULT_CODE code);
|
||||
void monitorReadSendSlowLog(TdFilePtr pFile, void* pTransporter, SEpSet *epSet);
|
||||
|
||||
int32_t monitorPutData2MonitorQueue(int64_t clusterId, char* value);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -107,17 +107,17 @@ static void generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_
|
|||
}
|
||||
char clusterId[32] = {0};
|
||||
if (snprintf(clusterId, sizeof(clusterId), "%" PRId64, pTscObj->pAppInfo->clusterId) < 0){
|
||||
uError("failed to generate clusterId:%" PRId64, pTscObj->pAppInfo->clusterId);
|
||||
tscError("failed to generate clusterId:%" PRId64, pTscObj->pAppInfo->clusterId);
|
||||
}
|
||||
|
||||
char startTs[32] = {0};
|
||||
if (snprintf(startTs, sizeof(startTs), "%" PRId64, pRequest->metric.start/1000) < 0){
|
||||
uError("failed to generate startTs:%" PRId64, pRequest->metric.start/1000);
|
||||
tscError("failed to generate startTs:%" PRId64, pRequest->metric.start/1000);
|
||||
}
|
||||
|
||||
char requestId[32] = {0};
|
||||
if (snprintf(requestId, sizeof(requestId), "%" PRIu64, pRequest->requestId) < 0){
|
||||
uError("failed to generate requestId:%" PRIu64, pRequest->requestId);
|
||||
tscError("failed to generate requestId:%" PRIu64, pRequest->requestId);
|
||||
}
|
||||
cJSON_AddItemToObject(json, "cluster_id", cJSON_CreateString(clusterId));
|
||||
cJSON_AddItemToObject(json, "start_ts", cJSON_CreateString(startTs));
|
||||
|
@ -142,7 +142,7 @@ static void generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_
|
|||
|
||||
char pid[32] = {0};
|
||||
if (snprintf(pid, sizeof(pid), "%d", appInfo.pid) < 0){
|
||||
uError("failed to generate pid:%d", appInfo.pid);
|
||||
tscError("failed to generate pid:%d", appInfo.pid);
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(json, "process_id", cJSON_CreateString(pid));
|
||||
|
@ -153,25 +153,14 @@ static void generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_
|
|||
}else if(pRequest->pDb != NULL){
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString(pRequest->pDb));
|
||||
}else{
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString("unknown"));
|
||||
cJSON_AddItemToObject(json, "db", cJSON_CreateString(""));
|
||||
}
|
||||
|
||||
char* value = cJSON_PrintUnformatted(json);
|
||||
if(monitorPutData2MonitorQueue(pTscObj->pAppInfo->clusterId, value) < 0){
|
||||
taosMemoryFree(value);
|
||||
}
|
||||
|
||||
MonitorSlowLogData* slowLogData = taosAllocateQitem(sizeof(MonitorSlowLogData), DEF_QITEM, 0);
|
||||
if (slowLogData == NULL) {
|
||||
cJSON_Delete(json);
|
||||
tscError("[monitor] failed to allocate slow log data");
|
||||
return;
|
||||
}
|
||||
slowLogData->clusterId = pTscObj->pAppInfo->clusterId;
|
||||
slowLogData->value = cJSON_PrintUnformatted(json);
|
||||
tscDebug("[monitor] write slow log to queue, clusterId:%"PRIx64 " value:%s", slowLogData->clusterId, slowLogData->value);
|
||||
if (taosWriteQitem(monitorQueue, slowLogData) == 0){
|
||||
tsem2_post(&monitorSem);
|
||||
}else{
|
||||
monitorFreeSlowLogData(slowLogData);
|
||||
taosFreeQitem(slowLogData);
|
||||
}
|
||||
cJSON_Delete(json);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,31 +85,6 @@ static SAppInstInfo* getAppInstByClusterId(int64_t clusterId) {
|
|||
return *(SAppInstInfo**)p;
|
||||
}
|
||||
|
||||
static int32_t tscMonitortInit() {
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
TdThread monitorThread;
|
||||
if (taosThreadCreate(&monitorThread, &thAttr, monitorThreadFunc, NULL) != 0) {
|
||||
uError("failed to create monitor thread since %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tscMonitorStop() {
|
||||
if (atomic_val_compare_exchange_32(&slowLogFlag, 0, 1)) {
|
||||
uDebug("monitor thread already stopped");
|
||||
return;
|
||||
}
|
||||
|
||||
while (atomic_load_32(&slowLogFlag) > 0) {
|
||||
taosMsleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t monitorReportAsyncCB(void* param, SDataBuf* pMsg, int32_t code) {
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
uError("found error in monitorReport send callback, code:%d, please check the network.", code);
|
||||
|
@ -161,7 +136,7 @@ static int32_t sendReport(void* pTransporter, SEpSet *epSet, char* pCont, MONITO
|
|||
return code;
|
||||
}
|
||||
|
||||
void monitorReadSendSlowLog(TdFilePtr pFile, void* pTransporter, SEpSet *epSet){
|
||||
static void monitorReadSendSlowLog(TdFilePtr pFile, void* pTransporter, SEpSet *epSet){
|
||||
char buf[SLOW_LOG_SEND_SIZE + 1] = {0}; // +1 for \0, for print log
|
||||
char pCont[SLOW_LOG_SEND_SIZE + 1] = {0}; // +1 for \0, for print log
|
||||
int32_t offset = 0;
|
||||
|
@ -268,8 +243,9 @@ static void sendAllSlowLog(){
|
|||
uDebug("[monitor] sendAllSlowLog when client close");
|
||||
}
|
||||
|
||||
void monitorSendAllSlowLogFromTempDir(void* inst){
|
||||
SAppInstInfo* pInst = (SAppInstInfo*)inst;
|
||||
static void monitorSendAllSlowLogFromTempDir(int64_t clusterId){
|
||||
SAppInstInfo* pInst = getAppInstByClusterId((int64_t)clusterId);
|
||||
|
||||
if(pInst == NULL || !pInst->monitorParas.tsEnableMonitor){
|
||||
uInfo("[monitor] monitor is disabled, skip send slow log");
|
||||
return;
|
||||
|
@ -350,45 +326,6 @@ static void sendAllCounter(){
|
|||
}
|
||||
}
|
||||
|
||||
void monitorInit() {
|
||||
uInfo("[monitor] tscMonitor init");
|
||||
monitorCounterHash = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (monitorCounterHash == NULL) {
|
||||
uError("failed to create monitorCounterHash");
|
||||
}
|
||||
taosHashSetFreeFp(monitorCounterHash, destroyMonitorClient);
|
||||
|
||||
monitorSlowLogHash = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (monitorSlowLogHash == NULL) {
|
||||
uError("failed to create monitorSlowLogHash");
|
||||
}
|
||||
taosHashSetFreeFp(monitorSlowLogHash, destroySlowLogClient);
|
||||
|
||||
monitorTimer = taosTmrInit(0, 0, 0, "MONITOR");
|
||||
if (monitorTimer == NULL) {
|
||||
uError("failed to create monitor timer");
|
||||
}
|
||||
|
||||
taosInitRWLatch(&monitorLock);
|
||||
tscMonitortInit();
|
||||
}
|
||||
|
||||
void monitorClose() {
|
||||
uInfo("[monitor] tscMonitor close");
|
||||
taosRLockLatch(&monitorLock);
|
||||
|
||||
if (atomic_val_compare_exchange_32(&monitorFlag, 0, 1)) {
|
||||
uDebug("[monitor] monitorFlag is not 0");
|
||||
}
|
||||
tscMonitorStop();
|
||||
sendAllSlowLog();
|
||||
sendAllCounter();
|
||||
taosHashCleanup(monitorCounterHash);
|
||||
taosHashCleanup(monitorSlowLogHash);
|
||||
taosTmrCleanUp(monitorTimer);
|
||||
taosRUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
void monitorCreateClient(int64_t clusterId) {
|
||||
MonitorClient* pMonitor = NULL;
|
||||
taosWLockLatch(&monitorLock);
|
||||
|
@ -477,7 +414,7 @@ end:
|
|||
}
|
||||
|
||||
void monitorCounterInc(int64_t clusterId, const char* counterName, const char** label_values) {
|
||||
taosRLockLatch(&monitorLock);
|
||||
taosWLockLatch(&monitorLock);
|
||||
MonitorClient** ppMonitor = (MonitorClient**)taosHashGet(monitorCounterHash, &clusterId, LONG_BYTES);
|
||||
if (ppMonitor == NULL || *ppMonitor == NULL) {
|
||||
uError("monitorCounterInc not found pMonitor %"PRId64, clusterId);
|
||||
|
@ -494,7 +431,7 @@ void monitorCounterInc(int64_t clusterId, const char* counterName, const char**
|
|||
uInfo("[monitor] monitorCounterInc %"PRIx64"(%p):%s", pMonitor->clusterId, pMonitor, counterName);
|
||||
|
||||
end:
|
||||
taosRUnLockLatch(&monitorLock);
|
||||
taosWUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
const char* monitorResultStr(SQL_RESULT_CODE code) {
|
||||
|
@ -502,16 +439,16 @@ const char* monitorResultStr(SQL_RESULT_CODE code) {
|
|||
return result_state[code];
|
||||
}
|
||||
|
||||
void monitorFreeSlowLogData(MonitorSlowLogData* pData) {
|
||||
static void monitorFreeSlowLogData(MonitorSlowLogData* pData) {
|
||||
if (pData == NULL) {
|
||||
return;
|
||||
}
|
||||
taosMemoryFree(pData->value);
|
||||
}
|
||||
|
||||
void monitorThreadFuncUnexpectedStopped(void) { atomic_store_32(&slowLogFlag, -1); }
|
||||
static void monitorThreadFuncUnexpectedStopped(void) { atomic_store_32(&slowLogFlag, -1); }
|
||||
|
||||
void reportSlowLog(void* param, void* tmrId) {
|
||||
static void reportSlowLog(void* param, void* tmrId) {
|
||||
taosRLockLatch(&monitorLock);
|
||||
if (atomic_load_32(&monitorFlag) == 1) {
|
||||
taosRUnLockLatch(&monitorLock);
|
||||
|
@ -538,8 +475,8 @@ void reportSlowLog(void* param, void* tmrId) {
|
|||
taosTmrReset(reportSlowLog, pInst->monitorParas.tsMonitorInterval * 1000, param, monitorTimer, &tmrId);
|
||||
}
|
||||
|
||||
void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpPath){
|
||||
taosRLockLatch(&monitorLock);
|
||||
static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpPath){
|
||||
taosWLockLatch(&monitorLock);
|
||||
TdFilePtr pFile = NULL;
|
||||
void* tmp = taosHashGet(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES);
|
||||
if (tmp == NULL){
|
||||
|
@ -594,10 +531,10 @@ void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpPath){
|
|||
uDebug("[monitor] write slow log to file:%p, clusterId:%"PRIx64, pFile, slowLogData->clusterId);
|
||||
|
||||
FAILED:
|
||||
taosRUnLockLatch(&monitorLock);
|
||||
taosWUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
void* monitorThreadFunc(void *param){
|
||||
static void* monitorThreadFunc(void *param){
|
||||
setThreadName("client-monitor-slowlog");
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
@ -638,7 +575,11 @@ void* monitorThreadFunc(void *param){
|
|||
taosReadQitem(monitorQueue, (void**)&slowLogData);
|
||||
if (slowLogData != NULL) {
|
||||
uDebug("[monitor] read slow log data from queue, clusterId:%" PRIx64 " value:%s", slowLogData->clusterId, slowLogData->value);
|
||||
monitorWriteSlowLog2File(slowLogData, tmpPath);
|
||||
if (slowLogData->value == NULL){
|
||||
monitorSendAllSlowLogFromTempDir(slowLogData->clusterId);
|
||||
}else{
|
||||
monitorWriteSlowLog2File(slowLogData, tmpPath);
|
||||
}
|
||||
}
|
||||
monitorFreeSlowLogData(slowLogData);
|
||||
taosFreeQitem(slowLogData);
|
||||
|
@ -649,4 +590,86 @@ void* monitorThreadFunc(void *param){
|
|||
tsem2_destroy(&monitorSem);
|
||||
slowLogFlag = -2;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int32_t tscMonitortInit() {
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
TdThread monitorThread;
|
||||
if (taosThreadCreate(&monitorThread, &thAttr, monitorThreadFunc, NULL) != 0) {
|
||||
uError("failed to create monitor thread since %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tscMonitorStop() {
|
||||
if (atomic_val_compare_exchange_32(&slowLogFlag, 0, 1)) {
|
||||
uDebug("monitor thread already stopped");
|
||||
return;
|
||||
}
|
||||
|
||||
while (atomic_load_32(&slowLogFlag) > 0) {
|
||||
taosMsleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
void monitorInit() {
|
||||
uInfo("[monitor] tscMonitor init");
|
||||
monitorCounterHash = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (monitorCounterHash == NULL) {
|
||||
uError("failed to create monitorCounterHash");
|
||||
}
|
||||
taosHashSetFreeFp(monitorCounterHash, destroyMonitorClient);
|
||||
|
||||
monitorSlowLogHash = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (monitorSlowLogHash == NULL) {
|
||||
uError("failed to create monitorSlowLogHash");
|
||||
}
|
||||
taosHashSetFreeFp(monitorSlowLogHash, destroySlowLogClient);
|
||||
|
||||
monitorTimer = taosTmrInit(0, 0, 0, "MONITOR");
|
||||
if (monitorTimer == NULL) {
|
||||
uError("failed to create monitor timer");
|
||||
}
|
||||
|
||||
taosInitRWLatch(&monitorLock);
|
||||
tscMonitortInit();
|
||||
}
|
||||
|
||||
void monitorClose() {
|
||||
uInfo("[monitor] tscMonitor close");
|
||||
taosWLockLatch(&monitorLock);
|
||||
|
||||
if (atomic_val_compare_exchange_32(&monitorFlag, 0, 1)) {
|
||||
uDebug("[monitor] monitorFlag is not 0");
|
||||
}
|
||||
tscMonitorStop();
|
||||
sendAllSlowLog();
|
||||
sendAllCounter();
|
||||
taosHashCleanup(monitorCounterHash);
|
||||
taosHashCleanup(monitorSlowLogHash);
|
||||
taosTmrCleanUp(monitorTimer);
|
||||
taosWUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
int32_t monitorPutData2MonitorQueue(int64_t clusterId, char* value){
|
||||
MonitorSlowLogData* slowLogData = taosAllocateQitem(sizeof(MonitorSlowLogData), DEF_QITEM, 0);
|
||||
if (slowLogData == NULL) {
|
||||
uError("[monitor] failed to allocate slow log data");
|
||||
return -1;
|
||||
}
|
||||
slowLogData->clusterId = clusterId;
|
||||
slowLogData->value = value;
|
||||
uDebug("[monitor] write slow log to queue, clusterId:%"PRIx64 " value:%s", slowLogData->clusterId, slowLogData->value);
|
||||
if (taosWriteQitem(monitorQueue, slowLogData) == 0){
|
||||
tsem2_post(&monitorSem);
|
||||
}else{
|
||||
monitorFreeSlowLogData(slowLogData);
|
||||
taosFreeQitem(slowLogData);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -155,7 +155,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
if(taosHashPut(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES, &pTscObj->pAppInfo, POINTER_BYTES) != 0){
|
||||
tscError("failed to put appInfo into appInfo.pInstMapByClusterId");
|
||||
}
|
||||
monitorSendAllSlowLogFromTempDir(pTscObj->pAppInfo);
|
||||
monitorPutData2MonitorQueue(pTscObj->pAppInfo->clusterId, NULL);
|
||||
monitorClientSlowQueryInit(connectRsp.clusterId);
|
||||
monitorClientSQLReqInit(connectRsp.clusterId);
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ TEST(clientMonitorTest, ReadOneFile) {
|
|||
SEpSet* epSet = NULL;
|
||||
|
||||
// Call the function to be tested
|
||||
monitorReadSendSlowLog(pFile, pTransporter, epSet);
|
||||
// monitorReadSendSlowLog(pFile, (int64_t)pTransporter, epSet);
|
||||
|
||||
char value[size] = {0};
|
||||
memset(value, '0', size - 1);
|
||||
|
@ -115,7 +115,7 @@ TEST(clientMonitorTest, ReadOneFile) {
|
|||
uError("failed to write len to file:%p since %s", pFile, terrstr());
|
||||
}
|
||||
|
||||
monitorReadSendSlowLog(pFile, pTransporter, epSet);
|
||||
// monitorReadSendSlowLog(pFile, (int64_t)pTransporter, epSet);
|
||||
|
||||
// Clean up any resources created for testing
|
||||
taosCloseFile(&pFile);
|
||||
|
@ -164,6 +164,6 @@ TEST(clientMonitorTest, ReadTwoFile) {
|
|||
pAppInfo.clusterId = 2;
|
||||
pAppInfo.monitorParas.tsEnableMonitor = 1;
|
||||
strcpy(tsTempDir,"/tmp");
|
||||
monitorSendAllSlowLogFromTempDir(&pAppInfo);
|
||||
// monitorSendAllSlowLogFromTempDir(&pAppInfo);
|
||||
|
||||
}
|
|
@ -180,7 +180,7 @@ int32_t tsMaxRetryWaitTime = 10000;
|
|||
bool tsUseAdapter = false;
|
||||
int32_t tsMetaCacheMaxSize = -1; // MB
|
||||
int32_t tsSlowLogThreshold = 10; // seconds
|
||||
int32_t tsSlowLogThresholdTest = 10; // seconds
|
||||
int32_t tsSlowLogThresholdTest = INT32_MAX; // seconds
|
||||
char tsSlowLogExceptDb[TSDB_DB_NAME_LEN] = ""; // seconds
|
||||
int32_t tsSlowLogScope = SLOW_LOG_TYPE_QUERY;
|
||||
char* tsSlowLogScopeString = "query";
|
||||
|
@ -973,7 +973,7 @@ static void taosSetServerLogCfg(SConfig *pCfg) {
|
|||
sndDebugFlag = cfgGetItem(pCfg, "sndDebugFlag")->i32;
|
||||
}
|
||||
|
||||
static int32_t taosSetSlowLogScope(char *pScope) {
|
||||
int32_t taosSetSlowLogScope(char *pScope) {
|
||||
if (NULL == pScope || 0 == strlen(pScope)) {
|
||||
return SLOW_LOG_TYPE_QUERY;
|
||||
}
|
||||
|
@ -984,7 +984,7 @@ static int32_t taosSetSlowLogScope(char *pScope) {
|
|||
char *tmp = NULL;
|
||||
while((scope = strsep(&pScope, "|")) != NULL){
|
||||
taosMemoryFreeClear(tmp);
|
||||
tmp = strdup(scope);
|
||||
tmp = taosStrdup(scope);
|
||||
strtrim(tmp);
|
||||
if (0 == strcasecmp(tmp, "all")) {
|
||||
slowScope |= SLOW_LOG_TYPE_ALL;
|
||||
|
|
|
@ -743,7 +743,7 @@ static int32_t taosSetSlowLogScope(char *pScope) {
|
|||
char *tmp = NULL;
|
||||
while((scope = strsep(&pScope, "|")) != NULL){
|
||||
taosMemoryFreeClear(tmp);
|
||||
tmp = strdup(scope);
|
||||
tmp = taosStrdup(scope);
|
||||
strtrim(tmp);
|
||||
if (0 == strcasecmp(tmp, "all")) {
|
||||
slowScope |= SLOW_LOG_TYPE_ALL;
|
||||
|
|
|
@ -144,6 +144,11 @@ typedef enum {
|
|||
DND_REASON_ENABLE_WHITELIST_NOT_MATCH,
|
||||
DND_REASON_ENCRYPTION_KEY_NOT_MATCH,
|
||||
DND_REASON_STATUS_MONITOR_NOT_MATCH,
|
||||
DND_REASON_STATUS_MONITOR_SWITCH_NOT_MATCH,
|
||||
DND_REASON_STATUS_MONITOR_INTERVAL_NOT_MATCH,
|
||||
DND_REASON_STATUS_MONITOR_SLOW_LOG_THRESHOLD_NOT_MATCH,
|
||||
DND_REASON_STATUS_MONITOR_SLOW_LOG_SQL_MAX_LEN_NOT_MATCH,
|
||||
DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH,
|
||||
DND_REASON_OTHERS
|
||||
} EDndReason;
|
||||
|
||||
|
|
|
@ -49,6 +49,12 @@ static const char *offlineReason[] = {
|
|||
"ttlChangeOnWrite not match",
|
||||
"enableWhiteList not match",
|
||||
"encryptionKey not match",
|
||||
"monitor not match",
|
||||
"monitor switch not match",
|
||||
"monitor interval not match",
|
||||
"monitor slow log threshold not match",
|
||||
"monitor slow log sql max len not match",
|
||||
"monitor slow log scopenot match",
|
||||
"unknown",
|
||||
};
|
||||
|
||||
|
@ -438,20 +444,20 @@ void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo) {
|
|||
}
|
||||
}
|
||||
|
||||
#define CHECK_MONITOR_PARA(para) \
|
||||
#define CHECK_MONITOR_PARA(para,err) \
|
||||
if (pCfg->monitorParas.para != para) { \
|
||||
mError("dnode:%d, para:%d inconsistent with cluster:%d", pDnode->id, pCfg->monitorParas.para, para); \
|
||||
terrno = TSDB_CODE_DNODE_INVALID_MONITOR_PARAS; \
|
||||
return DND_REASON_STATUS_MONITOR_NOT_MATCH;\
|
||||
terrno = err; \
|
||||
return err;\
|
||||
}
|
||||
|
||||
static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const SClusterCfg *pCfg) {
|
||||
CHECK_MONITOR_PARA(tsEnableMonitor);
|
||||
CHECK_MONITOR_PARA(tsMonitorInterval);
|
||||
CHECK_MONITOR_PARA(tsSlowLogThreshold);
|
||||
CHECK_MONITOR_PARA(tsSlowLogThresholdTest);
|
||||
CHECK_MONITOR_PARA(tsSlowLogMaxLen);
|
||||
CHECK_MONITOR_PARA(tsSlowLogScope);
|
||||
CHECK_MONITOR_PARA(tsEnableMonitor, DND_REASON_STATUS_MONITOR_SWITCH_NOT_MATCH);
|
||||
CHECK_MONITOR_PARA(tsMonitorInterval, DND_REASON_STATUS_MONITOR_INTERVAL_NOT_MATCH);
|
||||
CHECK_MONITOR_PARA(tsSlowLogThreshold, DND_REASON_STATUS_MONITOR_SLOW_LOG_THRESHOLD_NOT_MATCH);
|
||||
CHECK_MONITOR_PARA(tsSlowLogThresholdTest, DND_REASON_STATUS_MONITOR_NOT_MATCH);
|
||||
CHECK_MONITOR_PARA(tsSlowLogMaxLen, DND_REASON_STATUS_MONITOR_SLOW_LOG_SQL_MAX_LEN_NOT_MATCH);
|
||||
CHECK_MONITOR_PARA(tsSlowLogScope, DND_REASON_STATUS_MONITOR_SLOW_LOG_SCOPE_NOT_MATCH);
|
||||
|
||||
if (0 != strcasecmp(pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb)) {
|
||||
mError("dnode:%d, tsSlowLogExceptDb:%s inconsistent with cluster:%s", pDnode->id, pCfg->monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb);
|
||||
|
@ -557,9 +563,6 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
|
|||
SStatisReq statisReq = {0};
|
||||
int32_t code = -1;
|
||||
|
||||
char strClusterId[TSDB_CLUSTER_ID_LEN] = {0};
|
||||
sprintf(strClusterId, "%" PRId64, pMnode->clusterId);
|
||||
|
||||
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return code;
|
||||
|
|
|
@ -1222,20 +1222,24 @@ int32_t taosUmaskFile(int32_t maskVal) {
|
|||
|
||||
int32_t taosGetErrorFile(TdFilePtr pFile) { return errno; }
|
||||
int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
|
||||
int64_t ret = -1;
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockRdlock(&(pFile->rwlock));
|
||||
#endif
|
||||
if (pFile == NULL || ptrBuf == NULL) {
|
||||
return -1;
|
||||
goto END;
|
||||
}
|
||||
if (*ptrBuf != NULL) {
|
||||
taosMemoryFreeClear(*ptrBuf);
|
||||
}
|
||||
ASSERT(pFile->fp != NULL);
|
||||
if (pFile->fp == NULL) {
|
||||
return -1;
|
||||
goto END;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
size_t bufferSize = 512;
|
||||
*ptrBuf = taosMemoryMalloc(bufferSize);
|
||||
if (*ptrBuf == NULL) return -1;
|
||||
if (*ptrBuf == NULL) goto END;
|
||||
|
||||
size_t bytesRead = 0;
|
||||
size_t totalBytesRead = 0;
|
||||
|
@ -1244,7 +1248,7 @@ int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
|
|||
char *result = fgets(*ptrBuf + totalBytesRead, bufferSize - totalBytesRead, pFile->fp);
|
||||
if (result == NULL) {
|
||||
taosMemoryFreeClear(*ptrBuf);
|
||||
return -1;
|
||||
goto END;
|
||||
}
|
||||
bytesRead = strlen(*ptrBuf + totalBytesRead);
|
||||
totalBytesRead += bytesRead;
|
||||
|
@ -1257,18 +1261,24 @@ int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf) {
|
|||
void *newBuf = taosMemoryRealloc(*ptrBuf, bufferSize);
|
||||
if (newBuf == NULL) {
|
||||
taosMemoryFreeClear(*ptrBuf);
|
||||
return -1;
|
||||
goto END;
|
||||
}
|
||||
|
||||
*ptrBuf = newBuf;
|
||||
}
|
||||
|
||||
(*ptrBuf)[totalBytesRead] = '\0';
|
||||
return totalBytesRead;
|
||||
ret = totalBytesRead;
|
||||
#else
|
||||
size_t len = 0;
|
||||
return getline(ptrBuf, &len, pFile->fp);
|
||||
ret = getline(ptrBuf, &len, pFile->fp);
|
||||
#endif
|
||||
|
||||
END:
|
||||
#if FILE_WITH_LOCK
|
||||
taosThreadRwlockUnlock(&(pFile->rwlock));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t taosGetsFile(TdFilePtr pFile, int32_t maxSize, char *__restrict buf) {
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "tlog.h"
|
||||
#include "tunit.h"
|
||||
#include "tutil.h"
|
||||
#include "tglobal.h"
|
||||
|
||||
#define CFG_NAME_PRINT_LEN 24
|
||||
#define CFG_SRC_PRINT_LEN 12
|
||||
|
@ -432,6 +433,18 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p
|
|||
}
|
||||
|
||||
switch (pItem->dtype) {
|
||||
case CFG_DTYPE_STRING:{
|
||||
if(strcasecmp(name, "slowLogScope") == 0){
|
||||
char* tmp = taosStrdup(pVal);
|
||||
if(taosSetSlowLogScope(tmp) < 0){
|
||||
terrno = TSDB_CODE_INVALID_CFG;
|
||||
cfgUnLock(pCfg);
|
||||
taosMemoryFree(tmp);
|
||||
return -1;
|
||||
}
|
||||
taosMemoryFree(tmp);
|
||||
}
|
||||
} break;
|
||||
case CFG_DTYPE_BOOL: {
|
||||
int32_t ival = (int32_t)atoi(pVal);
|
||||
if (ival != 0 && ival != 1) {
|
||||
|
|
Loading…
Reference in New Issue