fix: close file on sdbStopWrite
This commit is contained in:
parent
7607a9788f
commit
e2ac984f61
|
@ -636,31 +636,31 @@ int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, int64_t term, int64_t config) {
|
int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, int64_t term, int64_t config) {
|
||||||
int32_t code = 0;
|
int32_t code = -1;
|
||||||
|
|
||||||
if (!isApply) {
|
if (!isApply) {
|
||||||
mInfo("sdbiter:%p, not apply to sdb", pIter);
|
mInfo("sdbiter:%p, not apply to sdb", pIter);
|
||||||
sdbCloseIter(pIter);
|
code = 0;
|
||||||
return 0;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosFsyncFile(pIter->file);
|
if (taosFsyncFile(pIter->file) != 0) {
|
||||||
taosCloseFile(&pIter->file);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
pIter->file = NULL;
|
mError("sdbiter:%p, failed to fasync file %s since %s", pIter, pIter->name, terrstr());
|
||||||
|
goto _OVER;
|
||||||
|
}
|
||||||
|
|
||||||
char datafile[PATH_MAX] = {0};
|
char datafile[PATH_MAX] = {0};
|
||||||
snprintf(datafile, sizeof(datafile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP);
|
snprintf(datafile, sizeof(datafile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP);
|
||||||
if (taosRenameFile(pIter->name, datafile) != 0) {
|
if (taosRenameFile(pIter->name, datafile) != 0) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
mError("sdbiter:%p, failed to rename file %s to %s since %s", pIter, pIter->name, datafile, terrstr());
|
mError("sdbiter:%p, failed to rename file %s to %s since %s", pIter, pIter->name, datafile, terrstr());
|
||||||
sdbCloseIter(pIter);
|
goto _OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sdbReadFile(pSdb) != 0) {
|
if (sdbReadFile(pSdb) != 0) {
|
||||||
mError("sdbiter:%p, failed to read from %s since %s", pIter, datafile, terrstr());
|
mError("sdbiter:%p, failed to read from %s since %s", pIter, datafile, terrstr());
|
||||||
sdbCloseIter(pIter);
|
goto _OVER;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config > 0) {
|
if (config > 0) {
|
||||||
|
@ -675,7 +675,13 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i
|
||||||
|
|
||||||
mInfo("sdbiter:%p, success applyed to sdb", pIter);
|
mInfo("sdbiter:%p, success applyed to sdb", pIter);
|
||||||
sdbCloseIter(pIter);
|
sdbCloseIter(pIter);
|
||||||
return 0;
|
code = 0;
|
||||||
|
|
||||||
|
_OVER:
|
||||||
|
taosCloseFile(&pIter->file);
|
||||||
|
pIter->file = NULL;
|
||||||
|
sdbCloseIter(pIter);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len) {
|
int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len) {
|
||||||
|
|
Loading…
Reference in New Issue