提交 32bdf913 编写于 作者: J Jeff Tao

add one more parameter in walCfg

keep the wal file when it is closed
上级 3f8a10d9
......@@ -368,6 +368,7 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode) {
if (strcmp(option[0], "wals") != 0) return TSDB_CODE_INVALID_FILE_FORMAT;
if (wals == -1) return TSDB_CODE_INVALID_FILE_FORMAT;
pVnode->walCfg.wals = (int8_t)wals;
pVnode->walCfg.keep = 0;
int32_t arbitratorIp = -1;
num = fscanf(fp, "%s %u", option[0], &arbitratorIp);
......
......@@ -36,6 +36,7 @@
typedef struct {
int fd;
int keep;
int level;
int max; // maximum number of wal files
uint32_t id; // increase continuously
......@@ -61,6 +62,7 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
pWal->id = 0;
pWal->num = 0;
pWal->level = pCfg->commitLog;
pWal->keep = pCfg->keep;
strcpy(pWal->path, path);
pthread_mutex_init(&pWal->mutex, NULL);
......@@ -82,18 +84,21 @@ void *walOpen(const char *path, const SWalCfg *pCfg) {
void walClose(void *handle) {
if (handle == NULL) return;
SWal *pWal = handle;
SWal *pWal = handle;
close(pWal->fd);
// remove all files in the directory
for (int i=0; i<pWal->num; ++i) {
sprintf(pWal->name, "%s/%s%d", pWal->path, walPrefix, pWal->id-i);
if (remove(pWal->name) <0) {
wError("wal:%s, failed to remove", pWal->name);
} else {
wTrace("wal:%s, it is removed", pWal->name);
if (pWal->keep == 0) {
// remove all files in the directory
for (int i=0; i<pWal->num; ++i) {
sprintf(pWal->name, "%s/%s%d", pWal->path, walPrefix, pWal->id-i);
if (remove(pWal->name) <0) {
wError("wal:%s, failed to remove", pWal->name);
} else {
wTrace("wal:%s, it is removed", pWal->name);
}
}
} else {
wTrace("wal:%s, it is closed and kept", pWal->name);
}
pthread_mutex_destroy(&pWal->mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册