diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c index b9e064ec19..cfa0c341a6 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbCommit.c @@ -356,12 +356,32 @@ static int32_t close_committer(SCommitter *pCommiter, int32_t eno) { int32_t code = 0; int32_t lino; - code = tsdbFileSystemEditBegin(pCommiter->pTsdb->pFS, // - pCommiter->aFileOp, // - TSDB_FS_EDIT_COMMIT); - TSDB_CHECK_CODE(code, lino, _exit); + if (eno == 0) { + TSDB_CHECK_CODE( // + code = tsdbFileSystemEditBegin( // + pCommiter->pTsdb->pFS, // + pCommiter->aFileOp, // + TSDB_FS_EDIT_COMMIT), + lino, // + _exit); + } else { + ASSERTS(0, "TODO: Not implemented yet"); + } _exit: + if (code) { + tsdbError( // + "vgId:%d %s failed at line %d since %s", // + TD_VID(pCommiter->pTsdb->pVnode), // + __func__, // + lino, // + tstrerror(code)); + } else { + tsdbDebug( // + "vgId:%d %s done", // + TD_VID(pCommiter->pTsdb->pVnode), // + __func__); + } return code; } diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFS.c b/source/dnode/vnode/src/tsdb/dev/tsdbFS.c index 0e7a0a53aa..72dec3b424 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/dev/tsdbFS.c @@ -345,13 +345,25 @@ static int32_t close_file_system(struct STFileSystem *pFS) { return 0; } -static int32_t write_fs_to_file(struct STFileSystem *pFS, const char *fname) { +static int32_t read_fs_from_file(struct STFileSystem *pFS, const char *fname) { ASSERTS(0, "TODO: Not implemented yet"); return 0; } -static int32_t read_fs_from_file(struct STFileSystem *pFS, const char *fname) { +static int32_t edit_fs(struct STFileSystem *pFS, const SArray *aFileOp) { ASSERTS(0, "TODO: Not implemented yet"); + + for (int32_t iop = 0; iop < taosArrayGetSize(aFileOp); iop++) { + struct SFileOp *pOp = taosArrayGet(aFileOp, iop); + // if (pOp->op == TSDB_FS_OP_ADD) { + // ASSERTS(0, "TODO: Not implemented yet"); + // } else if (pOp->op == TSDB_FS_OP_DEL) { + // ASSERTS(0, "TODO: Not implemented yet"); + // } else { + // ASSERTS(0, "TODO: Not implemented yet"); + // } + } + return 0; } @@ -392,15 +404,22 @@ int32_t tsdbCloseFileSystem(struct STFileSystem **ppFS) { int32_t tsdbFileSystemEditBegin(struct STFileSystem *pFS, const SArray *aFileOp, tsdb_fs_edit_t etype) { int32_t code = 0; - int32_t lino = 0; + int32_t lino; char fname[TSDB_FILENAME_LEN]; get_current_temp(pFS->pTsdb, fname, etype); tsem_wait(&pFS->canEdit); - code = write_fs_to_file(pFS, fname); - TSDB_CHECK_CODE(code, lino, _exit); + TSDB_CHECK_CODE( // + code = edit_fs(pFS, aFileOp), // + lino, // + _exit); + + TSDB_CHECK_CODE( // + code = save_fs_to_file(pFS, fname), // + lino, // + _exit); _exit: if (code) { diff --git a/source/dnode/vnode/src/tsdb/dev/tsdbFS.h b/source/dnode/vnode/src/tsdb/dev/tsdbFS.h index 69fefd6fb0..e5c689406b 100644 --- a/source/dnode/vnode/src/tsdb/dev/tsdbFS.h +++ b/source/dnode/vnode/src/tsdb/dev/tsdbFS.h @@ -28,6 +28,7 @@ struct STFileSystem { tsem_t canEdit; int64_t nextEditId; SArray *aFileSet; // SArray + SArray *nState; // SArray }; typedef enum {