diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index bee68b81f567bf0259edea33e944a4aa074ccdaa..02940a3d93bef7c675f23cb079135abda9f101b4 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -111,7 +111,7 @@ int tsdbDropTable(TsdbRepoT *pRepo, STableId tableId); int tsdbAlterTable(TsdbRepoT *repo, STableCfg *pCfg); TSKEY tsdbGetTableLastKey(TsdbRepoT *repo, uint64_t uid); -uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t *size); +uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t eindex, int32_t *size); // the TSDB repository info typedef struct STsdbRepoInfo { diff --git a/src/inc/tsync.h b/src/inc/tsync.h index fcf26d22c39d5bb6f2742677196409456bc531b7..972db294f62a35ba7910576534f4291c021b6272 100644 --- a/src/inc/tsync.h +++ b/src/inc/tsync.h @@ -21,6 +21,7 @@ extern "C" { #endif #define TAOS_SYNC_MAX_REPLICA 5 +#define TAOS_SYNC_MAX_INDEX 0x7FFFFFFF typedef enum _TAOS_SYNC_ROLE { TAOS_SYNC_ROLE_OFFLINE, @@ -53,11 +54,16 @@ typedef struct { uint32_t nodeId[TAOS_SYNC_MAX_REPLICA]; int role[TAOS_SYNC_MAX_REPLICA]; } SNodesRole; - -// if name is empty(name[0] is zero), get the file from index or after, used by master -// if name is provided(name[0] is not zero), get the named file at the specified index, used by unsynced node -// it returns the file magic number and size, if file not there, magic shall be 0. -typedef uint32_t (*FGetFileInfo)(void *ahandle, char *name, uint32_t *index, int32_t *size, uint64_t *fversion); + +/* + if name is empty(name[0] is zero), get the file from index or after, but not larger than eindex. If a file + is found between index and eindex, index shall be updated, name shall be set, size shall be set to + file size, and file magic number shall be returned. + + if name is provided(name[0] is not zero), get the named file at the specified index. If not there, return + zero. If it is there, set the size to file size, and return file magic number. Index shall not be updated. +*/ +typedef uint32_t (*FGetFileInfo)(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion); // get the wal file from index or after // return value, -1: error, 1:more wal files, 0:last WAL. if name[0]==0, no WAL file diff --git a/src/mnode/src/mgmtSdb.c b/src/mnode/src/mgmtSdb.c index 237d2ca499296d00ffd50007430a57649767fa9f..9ab9d59b1b618ea4d5211e8c0bec1da8d36dea4b 100644 --- a/src/mnode/src/mgmtSdb.c +++ b/src/mnode/src/mgmtSdb.c @@ -201,7 +201,7 @@ void sdbUpdateMnodeRoles() { mgmtUpdateMnodeIpSet(); } -static uint32_t sdbGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size, uint64_t *fversion) { +static uint32_t sdbGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion) { sdbUpdateMnodeRoles(); return 0; } diff --git a/src/tsdb/src/tsdbMain.c b/src/tsdb/src/tsdbMain.c index 55342ffd38add8f8975945addaedf466955af969..e1e09940477f1321644a293c6aa2c3c27effd552 100644 --- a/src/tsdb/src/tsdbMain.c +++ b/src/tsdb/src/tsdbMain.c @@ -1179,7 +1179,7 @@ static void tsdbAlterMaxTables(STsdbRepo *pRepo, int32_t maxTables) { tsdbTrace("vgId:%d, tsdb maxTables is changed from %d to %d!", pRepo->config.tsdbId, oldMaxTables, maxTables); } -uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, int32_t *size) { +uint32_t tsdbGetFileInfo(TsdbRepoT *repo, char *name, uint32_t *index, uint32_t eindex, int32_t *size) { // TODO: need to refactor this function STsdbRepo *pRepo = (STsdbRepo *)repo; diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index b8bc29550e3ee810b850b12922debbe06dfbe104..13cd8ef7e23fddefafa02c2dc769b6b2a2839caf 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -37,7 +37,7 @@ static int32_t vnodeReadCfg(SVnodeObj *pVnode); static int32_t vnodeSaveVersion(SVnodeObj *pVnode); static int32_t vnodeReadVersion(SVnodeObj *pVnode); static int vnodeProcessTsdbStatus(void *arg, int status); -static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size, uint64_t *fversion); +static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion); static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index); static void vnodeNotifyRole(void *ahandle, int8_t role); static void vnodeNotifyFileSynced(void *ahandle, uint64_t fversion); @@ -429,10 +429,10 @@ static int vnodeProcessTsdbStatus(void *arg, int status) { return 0; } -static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, int32_t *size, uint64_t *fversion) { +static uint32_t vnodeGetFileInfo(void *ahandle, char *name, uint32_t *index, uint32_t eindex, int32_t *size, uint64_t *fversion) { SVnodeObj *pVnode = ahandle; *fversion = pVnode->fversion; - return tsdbGetFileInfo(pVnode->tsdb, name, index, size); + return tsdbGetFileInfo(pVnode->tsdb, name, index, eindex, size); } static int vnodeGetWalInfo(void *ahandle, char *name, uint32_t *index) {