diff --git a/include/util/tlog.h b/include/util/tlog.h index af92e1864e..67aafbfe44 100644 --- a/include/util/tlog.h +++ b/include/util/tlog.h @@ -88,11 +88,11 @@ void taosPrintLongString(const char *flags, ELogLevel level, int32_t dflag, cons void taosPrintSlowLog(const char *format, ...) #ifdef __GNUC__ - __attribute__((format(printf, 1, 2))) + __attribute__((format(printf, 1, 2))) #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); // Disable all asserts that may compromise the performance. @@ -100,7 +100,9 @@ bool taosAssertRelease(bool condition); #define ASSERT(condition) #define ASSERTS(condition, ...) (0) #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 #define ASSERT(condition) taosAssertRelease(condition) #else @@ -108,9 +110,9 @@ bool taosAssertRelease(bool condition); #endif #endif -void taosLogCrashInfo(char *nodeType, char *pMsg, int64_t msgLen, int signum, void *sigInfo); -void taosReadCrashInfo(char *filepath, char **pMsg, int64_t *pMsgLen, TdFilePtr *pFd); -void taosReleaseCrashLogFile(TdFilePtr pFile, bool truncateFile); +void taosLogCrashInfo(char *nodeType, char *pMsg, int64_t msgLen, int signum, void *sigInfo); +void taosReadCrashInfo(char *filepath, char **pMsg, int64_t *pMsgLen, TdFilePtr *pFd); +void taosReleaseCrashLogFile(TdFilePtr pFile, bool truncateFile); // clang-format off #define uFatal(...) { if (uDebugFlag & DEBUG_FATAL) { taosPrintLog("UTL FATAL", DEBUG_FATAL, tsLogEmbedded ? 255 : uDebugFlag, __VA_ARGS__); }} diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit2.c b/source/dnode/vnode/src/tsdb/tsdbCommit2.c index 4d62bc9632..998fba8722 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit2.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit2.c @@ -715,7 +715,7 @@ _exit: int32_t tsdbPreCommit(STsdb *tsdb) { taosThreadMutexLock(&tsdb->mutex); - ASSERT(tsdb->imem == NULL); + ASSERT_CORE(tsdb->imem == NULL, "imem should be null to commit mem"); tsdb->imem = tsdb->mem; tsdb->mem = NULL; taosThreadMutexUnlock(&tsdb->mutex); @@ -825,4 +825,4 @@ _exit: tsdbInfo("vgId:%d %s done", TD_VID(pTsdb->pVnode), __func__); } return code; -} \ No newline at end of file +} diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index b224eac8c2..7a22efc887 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -164,7 +164,10 @@ int32_t taosInitSlowLog() { if (strlen(tsLogDir) != 0) { char lastC = tsLogDir[strlen(tsLogDir) - 1]; if (lastC == '\\' || lastC == '/') { - snprintf(fullName, PATH_MAX, "%s" "%s", tsLogDir, logFileName); + snprintf(fullName, PATH_MAX, + "%s" + "%s", + tsLogDir, logFileName); } else { 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) { char lastC = tsLogDir[strlen(tsLogDir) - 1]; if (lastC == '\\' || lastC == '/') { - snprintf(fullName, PATH_MAX, "%s" "%s", tsLogDir, logName); + snprintf(fullName, PATH_MAX, + "%s" + "%s", + tsLogDir, logName); } else { snprintf(fullName, PATH_MAX, "%s" TD_DIRSEP "%s", tsLogDir, logName); } @@ -344,9 +350,9 @@ static OldFileKeeper *taosOpenNewFile() { return oldFileKeeper; } -static void *taosThreadToCloseOldFile(void* param) { - if(!param) return NULL; - OldFileKeeper* oldFileKeeper = (OldFileKeeper*)param; +static void *taosThreadToCloseOldFile(void *param) { + if (!param) return NULL; + OldFileKeeper *oldFileKeeper = (OldFileKeeper *)param; taosSsleep(20); taosCloseLogByFd(oldFileKeeper->pOldFile); taosKeepOldLog(oldFileKeeper->keepName); @@ -366,7 +372,7 @@ static int32_t taosOpenNewLogFile() { taosThreadAttrInit(&attr); taosThreadAttrSetDetachState(&attr, PTHREAD_CREATE_DETACHED); - OldFileKeeper* oldFileKeeper = taosOpenNewFile(); + OldFileKeeper *oldFileKeeper = taosOpenNewFile(); taosThreadCreate(&thread, &attr, taosThreadToCloseOldFile, oldFileKeeper); taosThreadAttrDestroy(&attr); } @@ -856,7 +862,7 @@ static void *taosAsyncOutputLog(void *param) { 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; 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); taosPrintTrace(flags, level, dflag, -1); - if (tsAssert) { + if (tsAssert || core) { taosCloseLog(); taosMsleep(300);