Merge pull request #26390 from taosdata/fix/TS-5086
fix(tsdb/commit): make commit failing core in release buildings
This commit is contained in:
commit
6180488047
|
@ -92,7 +92,7 @@ void taosPrintSlowLog(const char *format, ...)
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...);
|
bool taosAssertDebug(bool condition, const char *file, int32_t line, bool core, const char *format, ...);
|
||||||
bool taosAssertRelease(bool condition);
|
bool taosAssertRelease(bool condition);
|
||||||
|
|
||||||
// Disable all asserts that may compromise the performance.
|
// Disable all asserts that may compromise the performance.
|
||||||
|
@ -100,7 +100,9 @@ bool taosAssertRelease(bool condition);
|
||||||
#define ASSERT(condition)
|
#define ASSERT(condition)
|
||||||
#define ASSERTS(condition, ...) (0)
|
#define ASSERTS(condition, ...) (0)
|
||||||
#else
|
#else
|
||||||
#define ASSERTS(condition, ...) ((condition) ? false : taosAssertDebug(condition, __FILE__, __LINE__, __VA_ARGS__))
|
#define ASSERT_CORE(condition, ...) \
|
||||||
|
((condition) ? false : taosAssertDebug(condition, __FILE__, __LINE__, 1, __VA_ARGS__))
|
||||||
|
#define ASSERTS(condition, ...) ((condition) ? false : taosAssertDebug(condition, __FILE__, __LINE__, 0, __VA_ARGS__))
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define ASSERT(condition) taosAssertRelease(condition)
|
#define ASSERT(condition) taosAssertRelease(condition)
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -715,7 +715,7 @@ _exit:
|
||||||
|
|
||||||
int32_t tsdbPreCommit(STsdb *tsdb) {
|
int32_t tsdbPreCommit(STsdb *tsdb) {
|
||||||
taosThreadMutexLock(&tsdb->mutex);
|
taosThreadMutexLock(&tsdb->mutex);
|
||||||
ASSERT(tsdb->imem == NULL);
|
ASSERT_CORE(tsdb->imem == NULL, "imem should be null to commit mem");
|
||||||
tsdb->imem = tsdb->mem;
|
tsdb->imem = tsdb->mem;
|
||||||
tsdb->mem = NULL;
|
tsdb->mem = NULL;
|
||||||
taosThreadMutexUnlock(&tsdb->mutex);
|
taosThreadMutexUnlock(&tsdb->mutex);
|
||||||
|
|
|
@ -164,7 +164,10 @@ int32_t taosInitSlowLog() {
|
||||||
if (strlen(tsLogDir) != 0) {
|
if (strlen(tsLogDir) != 0) {
|
||||||
char lastC = tsLogDir[strlen(tsLogDir) - 1];
|
char lastC = tsLogDir[strlen(tsLogDir) - 1];
|
||||||
if (lastC == '\\' || lastC == '/') {
|
if (lastC == '\\' || lastC == '/') {
|
||||||
snprintf(fullName, PATH_MAX, "%s" "%s", tsLogDir, logFileName);
|
snprintf(fullName, PATH_MAX,
|
||||||
|
"%s"
|
||||||
|
"%s",
|
||||||
|
tsLogDir, logFileName);
|
||||||
} else {
|
} else {
|
||||||
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logFileName);
|
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logFileName);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +196,10 @@ int32_t taosInitLog(const char *logName, int32_t maxFiles) {
|
||||||
if (strlen(tsLogDir) != 0) {
|
if (strlen(tsLogDir) != 0) {
|
||||||
char lastC = tsLogDir[strlen(tsLogDir) - 1];
|
char lastC = tsLogDir[strlen(tsLogDir) - 1];
|
||||||
if (lastC == '\\' || lastC == '/') {
|
if (lastC == '\\' || lastC == '/') {
|
||||||
snprintf(fullName, PATH_MAX, "%s" "%s", tsLogDir, logName);
|
snprintf(fullName, PATH_MAX,
|
||||||
|
"%s"
|
||||||
|
"%s",
|
||||||
|
tsLogDir, logName);
|
||||||
} else {
|
} else {
|
||||||
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName);
|
snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName);
|
||||||
}
|
}
|
||||||
|
@ -344,9 +350,9 @@ static OldFileKeeper *taosOpenNewFile() {
|
||||||
return oldFileKeeper;
|
return oldFileKeeper;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *taosThreadToCloseOldFile(void* param) {
|
static void *taosThreadToCloseOldFile(void *param) {
|
||||||
if(!param) return NULL;
|
if (!param) return NULL;
|
||||||
OldFileKeeper* oldFileKeeper = (OldFileKeeper*)param;
|
OldFileKeeper *oldFileKeeper = (OldFileKeeper *)param;
|
||||||
taosSsleep(20);
|
taosSsleep(20);
|
||||||
taosCloseLogByFd(oldFileKeeper->pOldFile);
|
taosCloseLogByFd(oldFileKeeper->pOldFile);
|
||||||
taosKeepOldLog(oldFileKeeper->keepName);
|
taosKeepOldLog(oldFileKeeper->keepName);
|
||||||
|
@ -366,7 +372,7 @@ static int32_t taosOpenNewLogFile() {
|
||||||
taosThreadAttrInit(&attr);
|
taosThreadAttrInit(&attr);
|
||||||
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
|
|
||||||
OldFileKeeper* oldFileKeeper = taosOpenNewFile();
|
OldFileKeeper *oldFileKeeper = taosOpenNewFile();
|
||||||
taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper);
|
taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper);
|
||||||
taosThreadAttrDestroy(&attr);
|
taosThreadAttrDestroy(&attr);
|
||||||
}
|
}
|
||||||
|
@ -856,7 +862,7 @@ static void *taosAsyncOutputLog(void *param) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool taosAssertDebug(bool condition, const char *file, int32_t line, const char *format, ...) {
|
bool taosAssertDebug(bool condition, const char *file, int32_t line, bool core, const char *format, ...) {
|
||||||
if (condition) return false;
|
if (condition) return false;
|
||||||
|
|
||||||
const char *flags = "UTL FATAL ";
|
const char *flags = "UTL FATAL ";
|
||||||
|
@ -876,7 +882,7 @@ bool taosAssertDebug(bool condition, const char *file, int32_t line, const char
|
||||||
taosPrintLog(flags, level, dflag, "tAssert at file %s:%d exit:%d", file, line, tsAssert);
|
taosPrintLog(flags, level, dflag, "tAssert at file %s:%d exit:%d", file, line, tsAssert);
|
||||||
taosPrintTrace(flags, level, dflag, -1);
|
taosPrintTrace(flags, level, dflag, -1);
|
||||||
|
|
||||||
if (tsAssert) {
|
if (tsAssert || core) {
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
taosMsleep(300);
|
taosMsleep(300);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue