fix:[TS-4921]refactor reporting logic for slow log

This commit is contained in:
wangmm0220 2024-07-02 17:34:28 +08:00
parent 08245d6eb2
commit 3b6cb21771
1 changed files with 19 additions and 0 deletions

View File

@ -568,6 +568,19 @@ static void monitorSendAllSlowLogAtQuit(){
}
}
static void processFileRemoved(SlowLogClient* pClient){
taosUnLockFile(pClient->pFile);
taosCloseFile(&(pClient->pFile));
TdFilePtr pFile = taosOpenFile(pClient->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
if (pFile == NULL) {
terrno = TAOS_SYSTEM_ERROR(errno);
uError("failed to open file:%s since %s", pClient->path, terrstr());
}else{
pClient->pFile = pFile;
}
}
static void monitorSendAllSlowLog(){
int64_t t = taosGetMonoTimestampMs();
void* pIter = NULL;
@ -588,6 +601,12 @@ static void monitorSendAllSlowLog(){
if (pInst != NULL && pClient->offset == 0) {
int64_t size = getFileSize(pClient->path);
if(size <= 0){
if(size < 0){
uError("[monitor] monitorSendAllSlowLog failed to get file size:%s, err:%d", pClient->path, errno);
if(errno == ENOENT){
processFileRemoved(pClient);
}
}
continue;
}
SEpSet ep = getEpSet_s(&pInst->mgmtEp);