fix(tsdb/commit): make commit failing core in release buildings

This commit is contained in:
Minglei Jin 2024-07-03 16:40:54 +08:00
parent 71af880554
commit 0fa44fe8cf
3 changed files with 25 additions and 17 deletions

View File

@ -92,7 +92,7 @@ void taosPrintSlowLog(const char *format, ...)
#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

View File

@ -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);

View File

@ -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);