fix: write crash log
This commit is contained in:
parent
1e269c8dd6
commit
852f5b6fa4
|
@ -815,12 +815,6 @@ static void *tscCrashReportThreadFp(void *param) {
|
||||||
int32_t reportPeriodNum = 3600 * 1000 / sleepTime;
|
int32_t reportPeriodNum = 3600 * 1000 / sleepTime;
|
||||||
int32_t loopTimes = reportPeriodNum;
|
int32_t loopTimes = reportPeriodNum;
|
||||||
|
|
||||||
code = initCrashLogWriter();
|
|
||||||
if (code) {
|
|
||||||
tscError("failed to init crash log writer, code:%s", tstrerror(code));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
if (taosCheckCurrentInDll()) {
|
if (taosCheckCurrentInDll()) {
|
||||||
atexit(crashReportThreadFuncUnexpectedStopped);
|
atexit(crashReportThreadFuncUnexpectedStopped);
|
||||||
|
@ -837,6 +831,12 @@ static void *tscCrashReportThreadFp(void *param) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
code = initCrashLogWriter();
|
||||||
|
if (code) {
|
||||||
|
tscError("failed to init crash log writer, code:%s", tstrerror(code));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
checkAndPrepareCrashInfo();
|
checkAndPrepareCrashInfo();
|
||||||
if (clientStop > 0) break;
|
if (clientStop > 0) break;
|
||||||
|
|
|
@ -231,6 +231,7 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t
|
||||||
TAOS_CHECK_GOTO(tjsonAddIntegerToObject(pJson, "crashSig", signum), NULL, _exit);
|
TAOS_CHECK_GOTO(tjsonAddIntegerToObject(pJson, "crashSig", signum), NULL, _exit);
|
||||||
TAOS_CHECK_GOTO(tjsonAddIntegerToObject(pJson, "crashTs", taosGetTimestampUs()), NULL, _exit);
|
TAOS_CHECK_GOTO(tjsonAddIntegerToObject(pJson, "crashTs", taosGetTimestampUs()), NULL, _exit);
|
||||||
|
|
||||||
|
#if 0
|
||||||
#ifdef _TD_DARWIN_64
|
#ifdef _TD_DARWIN_64
|
||||||
taosLogTraceToBuf(tmp, sizeof(tmp), 4);
|
taosLogTraceToBuf(tmp, sizeof(tmp), 4);
|
||||||
#elif !defined(WINDOWS)
|
#elif !defined(WINDOWS)
|
||||||
|
@ -240,7 +241,7 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "stackInfo", tmp), NULL, _exit);
|
TAOS_CHECK_GOTO(tjsonAddStringToObject(pJson, "stackInfo", tmp), NULL, _exit);
|
||||||
|
#endif
|
||||||
char* pCont = tjsonToString(pJson);
|
char* pCont = tjsonToString(pJson);
|
||||||
if (pCont == NULL) {
|
if (pCont == NULL) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
|
|
|
@ -1317,29 +1317,28 @@ void checkAndPrepareCrashInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initCrashLogWriter() {
|
int32_t initCrashLogWriter() {
|
||||||
gCrashBasicInfo.init = true;
|
|
||||||
gCrashBasicInfo.isCrash = false;
|
|
||||||
int32_t code = tsem_init(&gCrashBasicInfo.sem, 0, 0);
|
int32_t code = tsem_init(&gCrashBasicInfo.sem, 0, 0);
|
||||||
uInfo("crashLogWriter init finished.");
|
if (code != 0) {
|
||||||
|
uError("failed to init sem for crashLogWriter, code:%d", code);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
gCrashBasicInfo.isCrash = false;
|
||||||
|
gCrashBasicInfo.init = true;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeCrashLogToFile(int signum, void *sigInfo, char *nodeType, int64_t clusterId, int64_t startTime) {
|
void writeCrashLogToFile(int signum, void *sigInfo, char *nodeType, int64_t clusterId, int64_t startTime) {
|
||||||
if (!gCrashBasicInfo.init) {
|
if (!gCrashBasicInfo.init) {
|
||||||
uInfo("crashLogWriter has not init!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uInfo("write crash log to file, signum:%d, nodeType:%s, clusterId:%" PRId64, signum, nodeType, clusterId);
|
|
||||||
gCrashBasicInfo.isCrash = true;
|
|
||||||
gCrashBasicInfo.clusterId = clusterId;
|
gCrashBasicInfo.clusterId = clusterId;
|
||||||
gCrashBasicInfo.startTime = startTime;
|
gCrashBasicInfo.startTime = startTime;
|
||||||
gCrashBasicInfo.nodeType = nodeType;
|
gCrashBasicInfo.nodeType = nodeType;
|
||||||
gCrashBasicInfo.signum = signum;
|
gCrashBasicInfo.signum = signum;
|
||||||
gCrashBasicInfo.sigInfo = sigInfo;
|
gCrashBasicInfo.sigInfo = sigInfo;
|
||||||
|
gCrashBasicInfo.isCrash = true;
|
||||||
|
|
||||||
tsem_wait(&gCrashBasicInfo.sem);
|
tsem_wait(&gCrashBasicInfo.sem);
|
||||||
|
|
||||||
uInfo("write crash log to file done, signum:%d, nodeType:%s, clusterId:%" PRId64, signum, nodeType, clusterId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosReadCrashInfo(char *filepath, char **pMsg, int64_t *pMsgLen, TdFilePtr *pFd) {
|
void taosReadCrashInfo(char *filepath, char **pMsg, int64_t *pMsgLen, TdFilePtr *pFd) {
|
||||||
|
|
Loading…
Reference in New Issue