提交 40728d1b 编写于 作者: S Shengliang Guan

TD-1949

上级 59b25a96
...@@ -54,16 +54,17 @@ typedef int32_t FWalWrite(void *ahandle, void *pHead, int32_t qtype, void *pMsg) ...@@ -54,16 +54,17 @@ typedef int32_t FWalWrite(void *ahandle, void *pHead, int32_t qtype, void *pMsg)
int32_t walInit(); int32_t walInit();
void walCleanUp(); void walCleanUp();
twalh walOpen(char *path, SWalCfg *pCfg); twalh walOpen(char *path, SWalCfg *pCfg);
int32_t walAlter(twalh pWal, SWalCfg *pCfg); int32_t walAlter(twalh pWal, SWalCfg *pCfg);
void walStop(twalh); void walStop(twalh);
void walClose(twalh); void walClose(twalh);
int32_t walRenew(twalh); int32_t walRenew(twalh);
void walRemoveOldFiles(twalh); void walRemoveOneOldFile(twalh);
int32_t walWrite(twalh, SWalHead *); void walRemoveAllOldFiles(twalh);
void walFsync(twalh, bool forceFsync); int32_t walWrite(twalh, SWalHead *);
int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp); void walFsync(twalh, bool forceFsync);
int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId); int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp);
int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId);
uint64_t walGetVersion(twalh); uint64_t walGetVersion(twalh);
#ifdef __cplusplus #ifdef __cplusplus
......
...@@ -318,6 +318,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) { ...@@ -318,6 +318,7 @@ int32_t vnodeOpen(int32_t vnode, char *rootDir) {
} }
tsdbSyncCommit(pVnode->tsdb); tsdbSyncCommit(pVnode->tsdb);
walRemoveAllOldFiles(pVnode->tsdb);
walRenew(pVnode->wal); walRenew(pVnode->wal);
SSyncInfo syncInfo; SSyncInfo syncInfo;
...@@ -593,7 +594,7 @@ static int vnodeProcessTsdbStatus(void *arg, int status) { ...@@ -593,7 +594,7 @@ static int vnodeProcessTsdbStatus(void *arg, int status) {
if (status == TSDB_STATUS_COMMIT_OVER) { if (status == TSDB_STATUS_COMMIT_OVER) {
vDebug("vgId:%d, commit over, fver:%" PRIu64 " vver:%" PRIu64, pVnode->vgId, pVnode->fversion, pVnode->version); vDebug("vgId:%d, commit over, fver:%" PRIu64 " vver:%" PRIu64, pVnode->vgId, pVnode->fversion, pVnode->version);
walRemoveOldFiles(pVnode->wal); walRemoveOneOldFile(pVnode->wal);
return vnodeSaveVersion(pVnode); return vnodeSaveVersion(pVnode);
} }
......
...@@ -128,16 +128,7 @@ void walClose(void *handle) { ...@@ -128,16 +128,7 @@ void walClose(void *handle) {
taosClose(pWal->fd); taosClose(pWal->fd);
if (pWal->keep != TAOS_WAL_KEEP) { if (pWal->keep != TAOS_WAL_KEEP) {
int64_t fileId = -1; walRemoveAllOldFiles(pWal);
while (walGetNextFile(pWal, &fileId) >= 0) {
snprintf(pWal->name, sizeof(pWal->name), "%s/%s%" PRId64, pWal->path, WAL_PREFIX, fileId);
if (remove(pWal->name) < 0) {
wError("vgId:%d, wal:%p file:%s, failed to remove", pWal->vgId, pWal, pWal->name);
} else {
wInfo("vgId:%d, wal:%p file:%s, it is removed", pWal->vgId, pWal, pWal->name);
}
}
} else { } else {
wDebug("vgId:%d, wal:%p file:%s, it is closed and kept", pWal->vgId, pWal, pWal->name); wDebug("vgId:%d, wal:%p file:%s, it is closed and kept", pWal->vgId, pWal, pWal->name);
} }
......
...@@ -63,7 +63,7 @@ int32_t walRenew(void *handle) { ...@@ -63,7 +63,7 @@ int32_t walRenew(void *handle) {
return code; return code;
} }
void walRemoveOldFiles(void *handle) { void walRemoveOneOldFile(void *handle) {
SWal *pWal = handle; SWal *pWal = handle;
if (pWal == NULL) return; if (pWal == NULL) return;
if (pWal->keep == TAOS_WAL_KEEP) return; if (pWal->keep == TAOS_WAL_KEEP) return;
...@@ -86,6 +86,22 @@ void walRemoveOldFiles(void *handle) { ...@@ -86,6 +86,22 @@ void walRemoveOldFiles(void *handle) {
pthread_mutex_unlock(&pWal->mutex); pthread_mutex_unlock(&pWal->mutex);
} }
void walRemoveAllOldFiles(void *handle) {
if (handle == NULL) return;
SWal * pWal = handle;
int64_t fileId = -1;
while (walGetNextFile(pWal, &fileId) >= 0) {
snprintf(pWal->name, sizeof(pWal->name), "%s/%s%" PRId64, pWal->path, WAL_PREFIX, fileId);
if (remove(pWal->name) < 0) {
wError("vgId:%d, wal:%p file:%s, failed to remove", pWal->vgId, pWal, pWal->name);
} else {
wInfo("vgId:%d, wal:%p file:%s, it is removed", pWal->vgId, pWal, pWal->name);
}
}
}
int32_t walWrite(void *handle, SWalHead *pHead) { int32_t walWrite(void *handle, SWalHead *pHead) {
if (handle == NULL) return -1; if (handle == NULL) return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册