From a651affa47a71a3e1befd9b75107f251ed7d5e43 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Sat, 2 Apr 2022 17:47:27 +0800 Subject: [PATCH] [TD-13756]: log file open fail error. --- source/util/src/tlog.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 1f26ab7c51..563acfec78 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -214,6 +214,7 @@ static void *taosThreadToOpenNewFile(void *param) { tsLogObj.logHandle->pFile = pFile; tsLogObj.lines = 0; tsLogObj.openInProgress = 0; + taosSsleep(3); taosCloseLogByFd(pOldFile); uInfo(" new log file:%d is opened", tsLogObj.flag); @@ -347,16 +348,12 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { taosThreadMutexInit(&tsLogObj.logMutex, NULL); taosUmaskFile(0); - TdFilePtr pFile = taosOpenFile(fileName, TD_FILE_CTEATE | TD_FILE_WRITE); + tsLogObj.logHandle->pFile = taosOpenFile(fileName, TD_FILE_CTEATE | TD_FILE_WRITE); - if (pFile == NULL) { + if (tsLogObj.logHandle->pFile == NULL) { printf("\nfailed to open log file:%s, reason:%s\n", fileName, strerror(errno)); return -1; } - TdFilePtr pOldFile = tsLogObj.logHandle->pFile; - tsLogObj.logHandle->pFile = pFile; - taosUnLockLogFile(pOldFile); - taosCloseFile(&pOldFile); taosLockLogFile(tsLogObj.logHandle->pFile); // only an estimate for number of lines