From 581f5e79d9a539d92f32a2eb5d177beb9bc14a36 Mon Sep 17 00:00:00 2001 From: kailixu Date: Tue, 11 Jun 2024 18:20:00 +0800 Subject: [PATCH] fix: reserve log file name --- source/util/src/tlog.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 1dad1d9519..ca809e1d5d 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -66,6 +66,7 @@ typedef struct { int32_t lines; int32_t flag; int32_t openInProgress; + int64_t lastFileSec; pid_t pid; char logName[LOG_FILE_NAME_LEN]; SLogBuff *logHandle; @@ -275,6 +276,11 @@ static void taosReserveOldLog(char *oldName, char *keepName) { int32_t code = 0; int64_t fileSec = taosGetTimestampSec(); + if (tsLogObj.lastFileSec < fileSec) { + tsLogObj.lastFileSec = fileSec; + } else { + fileSec = ++tsLogObj.lastFileSec; + } snprintf(keepName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64, tsLogObj.logName, fileSec); if ((code = taosRenameFile(oldName, keepName))) { keepName[0] = 0;