fix:[TS-4921]refactor reporting logic for slow log
This commit is contained in:
parent
f593b644fc
commit
4739607b91
|
@ -69,9 +69,7 @@ static void monitorFreeSlowLogData(void *paras) {
|
||||||
if (pData == NULL) {
|
if (pData == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pData->type == SLOW_LOG_WRITE){
|
|
||||||
taosMemoryFree(pData->data);
|
taosMemoryFree(pData->data);
|
||||||
}
|
|
||||||
if (pData->type == SLOW_LOG_READ_BEGINNIG){
|
if (pData->type == SLOW_LOG_READ_BEGINNIG){
|
||||||
taosMemoryFree(pData->fileName);
|
taosMemoryFree(pData->fileName);
|
||||||
}
|
}
|
||||||
|
@ -101,6 +99,7 @@ static int32_t monitorReportAsyncCB(void* param, SDataBuf* pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
if(monitorPutData2MonitorQueue(*p) == 0){
|
if(monitorPutData2MonitorQueue(*p) == 0){
|
||||||
p->fileName = NULL;
|
p->fileName = NULL;
|
||||||
|
p->data = NULL;
|
||||||
}
|
}
|
||||||
monitorFreeSlowLogData(p);
|
monitorFreeSlowLogData(p);
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
|
@ -361,12 +360,6 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpP
|
||||||
uError("failed to lock file:%p since %s", pFile, terrstr());
|
uError("failed to lock file:%p since %s", pFile, terrstr());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SAppInstInfo* pInst = getAppInstByClusterId(slowLogData->clusterId);
|
|
||||||
if(pInst == NULL){
|
|
||||||
uError("failed to get app instance by clusterId:%" PRId64, slowLogData->clusterId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
pFile = (*(SlowLogClient**)tmp)->pFile;
|
pFile = (*(SlowLogClient**)tmp)->pFile;
|
||||||
}
|
}
|
||||||
|
@ -444,6 +437,7 @@ static int64_t getFileSize(char* path){
|
||||||
static int32_t sendSlowLog(int64_t clusterId, char* data, TdFilePtr pFile, int64_t offset, SLOW_LOG_QUEUE_TYPE type, char* fileName, void* pTransporter, SEpSet *epSet){
|
static int32_t sendSlowLog(int64_t clusterId, char* data, TdFilePtr pFile, int64_t offset, SLOW_LOG_QUEUE_TYPE type, char* fileName, void* pTransporter, SEpSet *epSet){
|
||||||
MonitorSlowLogData* pParam = taosMemoryMalloc(sizeof(MonitorSlowLogData));
|
MonitorSlowLogData* pParam = taosMemoryMalloc(sizeof(MonitorSlowLogData));
|
||||||
if(pParam == NULL){
|
if(pParam == NULL){
|
||||||
|
taosMemoryFree(data);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
pParam->data = data;
|
pParam->data = data;
|
||||||
|
@ -469,7 +463,6 @@ static void monitorSendSlowLogAtBeginning(int64_t clusterId, char* fileName, TdF
|
||||||
sendSlowLog(clusterId, data, pFile, offset, SLOW_LOG_READ_BEGINNIG, taosStrdup(fileName), pTransporter, epSet);
|
sendSlowLog(clusterId, data, pFile, offset, SLOW_LOG_READ_BEGINNIG, taosStrdup(fileName), pTransporter, epSet);
|
||||||
}
|
}
|
||||||
uDebug("[monitor] monitorSendSlowLogAtBeginning send slow log file:%p, data:%s", pFile, data);
|
uDebug("[monitor] monitorSendSlowLogAtBeginning send slow log file:%p, data:%s", pFile, data);
|
||||||
taosMemoryFree(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +494,6 @@ static void monitorSendSlowLogAtRunning(int64_t clusterId){
|
||||||
sendSlowLog(clusterId, data, pClient->pFile, pClient->offset, SLOW_LOG_READ_RUNNING, NULL, pInst->pTransporter, &ep);
|
sendSlowLog(clusterId, data, pClient->pFile, pClient->offset, SLOW_LOG_READ_RUNNING, NULL, pInst->pTransporter, &ep);
|
||||||
}
|
}
|
||||||
uDebug("[monitor] monitorSendSlowLogAtRunning send slow log:%s", data);
|
uDebug("[monitor] monitorSendSlowLogAtRunning send slow log:%s", data);
|
||||||
taosMemoryFree(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +526,6 @@ static bool monitorSendSlowLogAtQuit(int64_t clusterId) {
|
||||||
sendSlowLog(clusterId, data, pClient->pFile, pClient->offset, SLOW_LOG_READ_QUIT, NULL, pInst->pTransporter, &ep);
|
sendSlowLog(clusterId, data, pClient->pFile, pClient->offset, SLOW_LOG_READ_QUIT, NULL, pInst->pTransporter, &ep);
|
||||||
}
|
}
|
||||||
uInfo("[monitor] monitorSendSlowLogAtQuit send slow log:%s", data);
|
uInfo("[monitor] monitorSendSlowLogAtQuit send slow log:%s", data);
|
||||||
taosMemoryFree(data);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -564,7 +555,6 @@ static void monitorSendAllSlowLogAtQuit(){
|
||||||
quitCnt ++;
|
quitCnt ++;
|
||||||
}
|
}
|
||||||
uInfo("[monitor] monitorSendAllSlowLogAtQuit send slow log :%s", data);
|
uInfo("[monitor] monitorSendAllSlowLogAtQuit send slow log :%s", data);
|
||||||
taosMemoryFree(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -616,7 +606,6 @@ static void monitorSendAllSlowLog(){
|
||||||
sendSlowLog(*clusterId, data, NULL, pClient->offset, SLOW_LOG_READ_RUNNING, NULL, pInst->pTransporter, &ep);
|
sendSlowLog(*clusterId, data, NULL, pClient->offset, SLOW_LOG_READ_RUNNING, NULL, pInst->pTransporter, &ep);
|
||||||
}
|
}
|
||||||
uDebug("[monitor] monitorSendAllSlowLog send slow log :%s", data);
|
uDebug("[monitor] monitorSendAllSlowLog send slow log :%s", data);
|
||||||
taosMemoryFree(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -746,7 +735,7 @@ static void* monitorThreadFunc(void *param){
|
||||||
monitorWriteSlowLog2File(slowLogData, tmpPath);
|
monitorWriteSlowLog2File(slowLogData, tmpPath);
|
||||||
} else if(slowLogData->type == SLOW_LOG_READ_RUNNING){
|
} else if(slowLogData->type == SLOW_LOG_READ_RUNNING){
|
||||||
monitorSendSlowLogAtRunning(slowLogData->clusterId);
|
monitorSendSlowLogAtRunning(slowLogData->clusterId);
|
||||||
}else if(slowLogData->type == SLOW_LOG_READ_QUIT){
|
} else if(slowLogData->type == SLOW_LOG_READ_QUIT){
|
||||||
if(monitorSendSlowLogAtQuit(slowLogData->clusterId)){
|
if(monitorSendSlowLogAtQuit(slowLogData->clusterId)){
|
||||||
uInfo("monitorThreadFunc quit since all slow log sended");
|
uInfo("monitorThreadFunc quit since all slow log sended");
|
||||||
monitorFreeSlowLogData(slowLogData);
|
monitorFreeSlowLogData(slowLogData);
|
||||||
|
|
|
@ -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){
|
if(taosHashPut(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES, &pTscObj->pAppInfo, POINTER_BYTES) != 0){
|
||||||
tscError("failed to put appInfo into appInfo.pInstMapByClusterId");
|
tscError("failed to put appInfo into appInfo.pInstMapByClusterId");
|
||||||
}
|
}
|
||||||
MonitorSlowLogData data ={.clusterId = pTscObj->pAppInfo->clusterId, .type = SLOW_LOG_READ_BEGINNIG, .pFile = NULL};
|
MonitorSlowLogData data ={.clusterId = pTscObj->pAppInfo->clusterId, .type = SLOW_LOG_READ_BEGINNIG, .pFile = NULL, .data = NULL};
|
||||||
monitorPutData2MonitorQueue(data);
|
monitorPutData2MonitorQueue(data);
|
||||||
monitorClientSlowQueryInit(connectRsp.clusterId);
|
monitorClientSlowQueryInit(connectRsp.clusterId);
|
||||||
monitorClientSQLReqInit(connectRsp.clusterId);
|
monitorClientSQLReqInit(connectRsp.clusterId);
|
||||||
|
|
Loading…
Reference in New Issue