more code
This commit is contained in:
parent
61eb991eca
commit
c748e4af25
|
@ -36,8 +36,8 @@ int32_t tsdbOpenFS(STsdb *pTsdb, STFileSystem **ppFS, int8_t rollback);
|
||||||
int32_t tsdbCloseFS(STFileSystem **ppFS);
|
int32_t tsdbCloseFS(STFileSystem **ppFS);
|
||||||
// txn
|
// txn
|
||||||
int32_t tsdbFSEditBegin(STFileSystem *pFS, const SArray *aFileOp, EFEditT etype);
|
int32_t tsdbFSEditBegin(STFileSystem *pFS, const SArray *aFileOp, EFEditT etype);
|
||||||
int32_t tsdbFSEditCommit(STFileSystem *pFS, EFEditT etype);
|
int32_t tsdbFSEditCommit(STFileSystem *pFS);
|
||||||
int32_t tsdbFSEditAbort(STFileSystem *pFS, EFEditT etype);
|
int32_t tsdbFSEditAbort(STFileSystem *pFS);
|
||||||
|
|
||||||
/* Exposed Structs */
|
/* Exposed Structs */
|
||||||
struct STFileSystem {
|
struct STFileSystem {
|
||||||
|
|
|
@ -448,8 +448,7 @@ int32_t tsdbCommitCommit(STsdb *pTsdb) {
|
||||||
// lock
|
// lock
|
||||||
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
taosThreadRwlockWrlock(&pTsdb->rwLock);
|
||||||
|
|
||||||
code = tsdbFSEditCommit(pTsdb->pFS, //
|
code = tsdbFSEditCommit(pTsdb->pFS);
|
||||||
TSDB_FEDIT_COMMIT);
|
|
||||||
if (code) {
|
if (code) {
|
||||||
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
taosThreadRwlockUnlock(&pTsdb->rwLock);
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
@ -481,8 +480,7 @@ int32_t tsdbCommitAbort(STsdb *pTsdb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
|
||||||
code = tsdbFSEditAbort(pTsdb->pFS, //
|
code = tsdbFSEditAbort(pTsdb->pFS);
|
||||||
TSDB_FEDIT_COMMIT);
|
|
||||||
TSDB_CHECK_CODE(code, lino, _exit);
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
|
|
|
@ -511,68 +511,48 @@ int32_t tsdbCloseFS(STFileSystem **ppFS) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFSEditBegin(STFileSystem *pFS, const SArray *aFileOp, EFEditT etype) {
|
int32_t tsdbFSEditBegin(STFileSystem *fs, const SArray *aFileOp, EFEditT etype) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t lino;
|
int32_t lino;
|
||||||
char fname[TSDB_FILENAME_LEN];
|
char current_t[TSDB_FILENAME_LEN];
|
||||||
|
|
||||||
// current_fname(pFS->pTsdb, fname, etype == TSDB_FEDIT_COMMIT ? TSDB_FCURRENT_C : TSDB_FCURRENT_M);
|
if (etype == TSDB_FEDIT_COMMIT) {
|
||||||
|
current_fname(fs->pTsdb, current_t, TSDB_FCURRENT_C);
|
||||||
|
} else {
|
||||||
|
current_fname(fs->pTsdb, current_t, TSDB_FCURRENT_M);
|
||||||
|
}
|
||||||
|
|
||||||
// tsem_wait(&pFS->canEdit);
|
tsem_wait(&fs->canEdit);
|
||||||
|
|
||||||
// TSDB_CHECK_CODE( //
|
fs->etype = etype;
|
||||||
// code = edit_fs(pFS, aFileOp), //
|
fs->eid = ++fs->neid;
|
||||||
// lino, //
|
|
||||||
// _exit);
|
|
||||||
|
|
||||||
// TSDB_CHECK_CODE( //
|
// edit
|
||||||
// code = save_fs(pFS, fname), //
|
code = edit_fs(fs, aFileOp);
|
||||||
// lino, //
|
TSDB_CHECK_CODE(code, lino, _exit);
|
||||||
// _exit);
|
|
||||||
|
// save fs
|
||||||
|
code = save_fs(fs->eid, fs->nstate, current_t);
|
||||||
|
TSDB_CHECK_CODE(code, lino, _exit)
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbError("vgId:%d %s failed at line %d since %s", //
|
tsdbError("vgId:%d %s failed at line %d since %s, eid:%" PRId64 " etype:%d", TD_VID(fs->pTsdb->pVnode), __func__,
|
||||||
TD_VID(pFS->pTsdb->pVnode), //
|
lino, tstrerror(code), fs->eid, etype);
|
||||||
__func__, //
|
|
||||||
lino, //
|
|
||||||
tstrerror(code));
|
|
||||||
} else {
|
} else {
|
||||||
tsdbInfo("vgId:%d %s done, etype:%d", //
|
tsdbInfo("vgId:%d %s done, eid:%" PRId64 " etype:%d", TD_VID(fs->pTsdb->pVnode), __func__, fs->eid, etype);
|
||||||
TD_VID(pFS->pTsdb->pVnode), //
|
|
||||||
__func__, //
|
|
||||||
etype);
|
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFSEditCommit(STFileSystem *pFS, EFEditT etype) {
|
int32_t tsdbFSEditCommit(STFileSystem *fs) {
|
||||||
int32_t code = commit_edit(pFS);
|
int32_t code = commit_edit(fs);
|
||||||
tsem_post(&pFS->canEdit);
|
tsem_post(&fs->canEdit);
|
||||||
if (code) {
|
|
||||||
tsdbError("vgId:%d %s failed since %s", //
|
|
||||||
TD_VID(pFS->pTsdb->pVnode), //
|
|
||||||
__func__, //
|
|
||||||
tstrerror(code));
|
|
||||||
} else {
|
|
||||||
tsdbInfo("vgId:%d %s done, etype:%d", //
|
|
||||||
TD_VID(pFS->pTsdb->pVnode), //
|
|
||||||
__func__, //
|
|
||||||
etype);
|
|
||||||
}
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbFSEditAbort(STFileSystem *pFS, EFEditT etype) {
|
int32_t tsdbFSEditAbort(STFileSystem *fs) {
|
||||||
int32_t code = abort_edit(pFS);
|
int32_t code = abort_edit(fs);
|
||||||
if (code) {
|
tsem_post(&fs->canEdit);
|
||||||
tsdbError("vgId:%d %s failed since %s, etype:%d", //
|
|
||||||
TD_VID(pFS->pTsdb->pVnode), //
|
|
||||||
__func__, //
|
|
||||||
tstrerror(code), //
|
|
||||||
etype);
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
tsem_post(&pFS->canEdit);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
|
@ -74,9 +74,9 @@ static int32_t tsdbCloseMerger(SMerger *pMerger) {
|
||||||
|
|
||||||
_exit:
|
_exit:
|
||||||
if (code) {
|
if (code) {
|
||||||
tsdbFSEditAbort(pTsdb->pFS, TSDB_FEDIT_MERGE);
|
tsdbFSEditAbort(pTsdb->pFS);
|
||||||
} else {
|
} else {
|
||||||
tsdbFSEditCommit(pTsdb->pFS, TSDB_FEDIT_MERGE);
|
tsdbFSEditCommit(pTsdb->pFS);
|
||||||
}
|
}
|
||||||
tsdbDestroyMerger(pMerger);
|
tsdbDestroyMerger(pMerger);
|
||||||
return code;
|
return code;
|
||||||
|
|
Loading…
Reference in New Issue