enh: solve conflict during process log file
This commit is contained in:
parent
db807020a0
commit
74f8a252c6
|
@ -205,7 +205,7 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int64_t id;
|
int64_t id;
|
||||||
char name[TSDB_CLUSTER_ID_LEN];
|
char nameX[TSDB_CLUSTER_ID_LEN];
|
||||||
int64_t createdTime;
|
int64_t createdTime;
|
||||||
int64_t updateTime;
|
int64_t updateTime;
|
||||||
int32_t upTime;
|
int32_t upTime;
|
||||||
|
|
|
@ -385,13 +385,21 @@ static void taosReserveOldLog(char *oldName, char *keepName) {
|
||||||
|
|
||||||
static void taosKeepOldLog(char *oldName) {
|
static void taosKeepOldLog(char *oldName) {
|
||||||
if (oldName[0] != 0) {
|
if (oldName[0] != 0) {
|
||||||
char compressFileName[PATH_MAX + 20];
|
int32_t code = 0, lino = 0;
|
||||||
snprintf(compressFileName, PATH_MAX + 20, "%s.gz", oldName);
|
TdFilePtr oldFile = NULL;
|
||||||
if (taosCompressFile(oldName, compressFileName) == 0) {
|
if ((oldFile = taosOpenFile(oldName, TD_FILE_READ))) {
|
||||||
int32_t code = taosRemoveFile(oldName);
|
TAOS_CHECK_GOTO(taosLockFile(oldFile), &lino, _exit2);
|
||||||
if (code != 0) {
|
char compressFileName[PATH_MAX + 20];
|
||||||
TAOS_UNUSED(printf("failed to remove file:%s, reason:%s\n", oldName, tstrerror(code)));
|
snprintf(compressFileName, PATH_MAX + 20, "%s.gz", oldName);
|
||||||
}
|
TAOS_CHECK_GOTO(taosCompressFile(oldName, compressFileName), &lino, _exit1);
|
||||||
|
TAOS_CHECK_GOTO(taosRemoveFile(oldName), &lino, _exit1);
|
||||||
|
}
|
||||||
|
_exit1:
|
||||||
|
TAOS_UNUSED(taosUnLockFile(oldFile));
|
||||||
|
_exit2:
|
||||||
|
TAOS_UNUSED(taosCloseFile(&oldFile));
|
||||||
|
if (code != 0) {
|
||||||
|
uWarn("failed at line %d to keep old log file:%s, reason:%s\n", oldName, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1041,7 +1049,7 @@ static void taosWriteLog(SLogBuff *pLogBuf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LOG_ROTATE_INTERVAL 3600
|
#define LOG_ROTATE_INTERVAL 3600
|
||||||
#if !defined(TD_ENTERPRISE) || defined(ASSERT_NOT_CORE)
|
#if !defined(TD_ENTERPRISE) || defined(ASSERT_NOT_CORE) || defined(GRANTS_CFG)
|
||||||
#define LOG_INACTIVE_TIME 7200
|
#define LOG_INACTIVE_TIME 7200
|
||||||
#define LOG_ROTATE_BOOT 900
|
#define LOG_ROTATE_BOOT 900
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in New Issue