提交 8e8437ad 编写于 作者: S Shengliang Guan

[TD-3068]<fix>: When the creation of log file fails, the length of old log grows infinitely

上级 98fd7660
......@@ -25,6 +25,7 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
char tmpPath[PATH_MAX];
int32_t len = strlen(tsTempDir);
memcpy(tmpPath, tsTempDir, len);
static uint64_t seqId = 0;
if (tmpPath[len - 1] != '/') {
tmpPath[len++] = '/';
......@@ -36,8 +37,10 @@ void taosGetTmpfilePath(const char *fileNamePrefix, char *dstPath) {
strcat(tmpPath, "-%d-%s");
}
char rand[8] = {0};
taosRandStr(rand, tListLen(rand) - 1);
char rand[32] = {0};
sprintf(rand, "%"PRIu64, atomic_add_fetch_64(&seqId, 1));
snprintf(dstPath, PATH_MAX, tmpPath, getpid(), rand);
}
......
......@@ -202,7 +202,7 @@ static int32_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi
break;
}
sDebug("%s, last wal is forwarded, hver:%" PRIu64, pPeer->id, pHead->version);
sTrace("%s, last wal is forwarded, hver:%" PRIu64, pPeer->id, pHead->version);
int32_t wsize = code;
int32_t ret = taosWriteMsg(pPeer->syncFd, pHead, wsize);
......@@ -245,7 +245,7 @@ static int32_t syncProcessLastWal(SSyncPeer *pPeer, char *wname, int64_t index)
int32_t bytes = syncRetrieveLastWal(pPeer, fname, fversion, offset);
if (bytes < 0) {
sDebug("%s, failed to retrieve last wal", pPeer->id);
sDebug("%s, failed to retrieve last wal, bytes:%d", pPeer->id, bytes);
return bytes;
}
......@@ -309,6 +309,7 @@ static int32_t syncRetrieveWal(SSyncPeer *pPeer) {
if (code == 0) { // last wal
code = syncProcessLastWal(pPeer, wname, index);
sInfo("%s, last wal processed, code:%d", pPeer->id, code);
break;
}
......
......@@ -171,7 +171,9 @@ static void *taosThreadToOpenNewFile(void *param) {
int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) {
uError("open new log file fail! fd:%d reason:%s", fd, strerror(errno));
tsLogObj.openInProgress = 0;
tsLogObj.lines = tsLogObj.maxLines - 1000;
uError("open new log file fail! fd:%d reason:%s, reuse lastlog", fd, strerror(errno));
return NULL;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册