fix: eliminate the risk of deadlock when switching logs
This commit is contained in:
parent
d148191bf2
commit
a42d498169
|
@ -411,9 +411,7 @@ static OldFileKeeper *taosOpenNewFile() {
|
||||||
|
|
||||||
TdFilePtr pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
TdFilePtr pFile = taosOpenFile(name, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
|
||||||
if (pFile == NULL) {
|
if (pFile == NULL) {
|
||||||
tsLogObj.openInProgress = 0;
|
uError("open new log file fail! reason:%s, reuse lastlog", tstrerror(terrno));
|
||||||
tsLogObj.lines = tsNumOfLogLines - 1000;
|
|
||||||
uError("open new log file fail! reason:%s, reuse lastlog", strerror(errno));
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,7 +423,6 @@ static OldFileKeeper *taosOpenNewFile() {
|
||||||
TdFilePtr pOldFile = tsLogObj.logHandle->pFile;
|
TdFilePtr pOldFile = tsLogObj.logHandle->pFile;
|
||||||
tsLogObj.logHandle->pFile = pFile;
|
tsLogObj.logHandle->pFile = pFile;
|
||||||
tsLogObj.lines = 0;
|
tsLogObj.lines = 0;
|
||||||
tsLogObj.openInProgress = 0;
|
|
||||||
OldFileKeeper *oldFileKeeper = taosMemoryMalloc(sizeof(OldFileKeeper));
|
OldFileKeeper *oldFileKeeper = taosMemoryMalloc(sizeof(OldFileKeeper));
|
||||||
if (oldFileKeeper == NULL) {
|
if (oldFileKeeper == NULL) {
|
||||||
uError("create old log keep info faild! mem is not enough.");
|
uError("create old log keep info faild! mem is not enough.");
|
||||||
|
@ -468,7 +465,9 @@ static int32_t taosOpenNewLogFile() {
|
||||||
|
|
||||||
OldFileKeeper *oldFileKeeper = taosOpenNewFile();
|
OldFileKeeper *oldFileKeeper = taosOpenNewFile();
|
||||||
if (!oldFileKeeper) {
|
if (!oldFileKeeper) {
|
||||||
|
tsLogObj.openInProgress = 0;
|
||||||
TAOS_UNUSED(taosThreadMutexUnlock(&tsLogObj.logMutex));
|
TAOS_UNUSED(taosThreadMutexUnlock(&tsLogObj.logMutex));
|
||||||
|
(void)taosThreadAttrDestroy(&attr);
|
||||||
return terrno;
|
return terrno;
|
||||||
}
|
}
|
||||||
if (taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper) != 0) {
|
if (taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper) != 0) {
|
||||||
|
@ -476,6 +475,7 @@ static int32_t taosOpenNewLogFile() {
|
||||||
taosMemoryFreeClear(oldFileKeeper);
|
taosMemoryFreeClear(oldFileKeeper);
|
||||||
}
|
}
|
||||||
(void)taosThreadAttrDestroy(&attr);
|
(void)taosThreadAttrDestroy(&attr);
|
||||||
|
tsLogObj.openInProgress = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)taosThreadMutexUnlock(&tsLogObj.logMutex);
|
(void)taosThreadMutexUnlock(&tsLogObj.logMutex);
|
||||||
|
|
Loading…
Reference in New Issue