未验证 提交 68e29fa8 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #3455 from taosdata/hotfix/TD-1401

TD-1401
...@@ -142,12 +142,30 @@ int tsdbOpenFileH(STsdbRepo *pRepo) { ...@@ -142,12 +142,30 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
} else if (code == REG_NOMATCH) { } else if (code == REG_NOMATCH) {
code = regexec(&regex2, dp->d_name, 0, NULL, 0); code = regexec(&regex2, dp->d_name, 0, NULL, 0);
if (code == 0) { if (code == 0) {
tsdbDebug("vgId:%d invalid file %s exists, remove it", REPO_ID(pRepo), dp->d_name); size_t tsize = strlen(tDataDir) + strlen(dp->d_name) + 2;
char *fname = malloc(strlen(tDataDir) + strlen(dp->d_name) + 2); char * fname1 = malloc(tsize);
if (fname == NULL) goto _err; if (fname1 == NULL) {
sprintf(fname, "%s/%s", tDataDir, dp->d_name); terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
(void)remove(fname); goto _err;
free(fname); }
sprintf(fname1, "%s/%s", tDataDir, dp->d_name);
tsize = tsize + 64;
char *fname2 = malloc(tsize);
if (fname2 == NULL) {
free(fname1);
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
goto _err;
}
sprintf(fname2, "%s/%s_back_%" PRId64, tDataDir, dp->d_name, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
(void)rename(fname1, fname2);
tsdbDebug("vgId:%d file %s exists, backup it as %s", REPO_ID(pRepo), fname1, fname2);
free(fname1);
free(fname2);
continue;
} else if (code == REG_NOMATCH) { } else if (code == REG_NOMATCH) {
tsdbError("vgId:%d invalid file %s exists, ignore it", REPO_ID(pRepo), dp->d_name); tsdbError("vgId:%d invalid file %s exists, ignore it", REPO_ID(pRepo), dp->d_name);
continue; continue;
...@@ -160,6 +178,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) { ...@@ -160,6 +178,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
pFileH->pFGroup[pFileH->nFGroups++] = fileGroup; pFileH->pFGroup[pFileH->nFGroups++] = fileGroup;
qsort((void *)(pFileH->pFGroup), pFileH->nFGroups, sizeof(SFileGroup), compFGroup); qsort((void *)(pFileH->pFGroup), pFileH->nFGroups, sizeof(SFileGroup), compFGroup);
tsdbDebug("vgId:%d file group %d is restored, nFGroups %d", REPO_ID(pRepo), fileGroup.fileId, pFileH->nFGroups);
} }
regfree(&regex1); regfree(&regex1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册