more
This commit is contained in:
parent
18db4d514a
commit
4eddef574c
|
@ -137,7 +137,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnodeCloseImpl(SVnode *pVnode) {
|
static void vnodeCloseImpl(SVnode *pVnode) {
|
||||||
// vnodeSyncCommit(pVnode);
|
vnodeSyncCommit(pVnode);
|
||||||
if (pVnode) {
|
if (pVnode) {
|
||||||
vnodeCloseBufPool(pVnode);
|
vnodeCloseBufPool(pVnode);
|
||||||
metaClose(pVnode->pMeta);
|
metaClose(pVnode->pMeta);
|
||||||
|
|
|
@ -15,10 +15,14 @@
|
||||||
|
|
||||||
#include "tsdbDef.h"
|
#include "tsdbDef.h"
|
||||||
|
|
||||||
|
#define TSDB_MAX_SUBBLOCKS 8
|
||||||
|
|
||||||
|
static void tsdbStartCommit(STsdb *pRepo);
|
||||||
|
static void tsdbEndCommit(STsdb *pTsdb, int eno);
|
||||||
|
|
||||||
int tsdbPrepareCommit(STsdb *pTsdb) {
|
int tsdbPrepareCommit(STsdb *pTsdb) {
|
||||||
if (pTsdb->mem == NULL) return 0;
|
if (pTsdb->mem == NULL) return 0;
|
||||||
|
|
||||||
// tsem_wait(&(pTsdb->canCommit));
|
|
||||||
ASSERT(pTsdb->imem == NULL);
|
ASSERT(pTsdb->imem == NULL);
|
||||||
|
|
||||||
pTsdb->imem = pTsdb->mem;
|
pTsdb->imem = pTsdb->mem;
|
||||||
|
@ -26,9 +30,11 @@ int tsdbPrepareCommit(STsdb *pTsdb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tsdbCommit(STsdb *pTsdb) {
|
int tsdbCommit(STsdb *pTsdb) {
|
||||||
// TODO
|
if (pTsdb->imem == NULL) return 0;
|
||||||
pTsdb->imem = NULL;
|
|
||||||
// tsem_post(&(pTsdb->canCommit));
|
tsdbStartCommit(pTsdb);
|
||||||
|
|
||||||
|
tsdbEndCommit(pTsdb, TSDB_CODE_SUCCESS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +55,21 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) {
|
||||||
pRtn->minFid, pRtn->midFid, pRtn->maxFid);
|
pRtn->minFid, pRtn->midFid, pRtn->maxFid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tsdbStartCommit(STsdb *pRepo) {
|
||||||
|
STsdbMemTable *pMem = pRepo->imem;
|
||||||
|
|
||||||
|
tsdbInfo("vgId:%d start to commit", REPO_ID(pRepo));
|
||||||
|
|
||||||
|
tsdbStartFSTxn(pRepo, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tsdbEndCommit(STsdb *pTsdb, int eno) {
|
||||||
|
tsdbEndFSTxn(pTsdb);
|
||||||
|
tsdbFreeMemTable(pTsdb, pTsdb->imem);
|
||||||
|
pTsdb->imem = NULL;
|
||||||
|
tsdbInfo("vgId:%d commit over, %s", REPO_ID(pTsdb), (eno == TSDB_CODE_SUCCESS) ? "succeed" : "failed");
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
@ -68,14 +89,6 @@ void tsdbGetRtnSnap(STsdb *pRepo, SRtn *pRtn) {
|
||||||
|
|
||||||
extern int32_t tsTsdbMetaCompactRatio;
|
extern int32_t tsTsdbMetaCompactRatio;
|
||||||
|
|
||||||
#define TSDB_MAX_SUBBLOCKS 8
|
|
||||||
static FORCE_INLINE int TSDB_KEY_FID(TSKEY key, int32_t days, int8_t precision) {
|
|
||||||
if (key < 0) {
|
|
||||||
return (int)((key + 1) / tsTickPerDay[precision] / days - 1);
|
|
||||||
} else {
|
|
||||||
return (int)((key / tsTickPerDay[precision] / days));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SRtn rtn; // retention snapshot
|
SRtn rtn; // retention snapshot
|
||||||
|
@ -709,38 +722,6 @@ static int tsdbCommitTSData(STsdbRepo *pRepo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tsdbStartCommit(STsdbRepo *pRepo) {
|
|
||||||
SMemTable *pMem = pRepo->imem;
|
|
||||||
|
|
||||||
ASSERT(pMem->numOfRows > 0 || listNEles(pMem->actList) > 0);
|
|
||||||
|
|
||||||
tsdbInfo("vgId:%d start to commit! keyFirst %" PRId64 " keyLast %" PRId64 " numOfRows %" PRId64 " meta rows: %d",
|
|
||||||
REPO_ID(pRepo), pMem->keyFirst, pMem->keyLast, pMem->numOfRows, listNEles(pMem->actList));
|
|
||||||
|
|
||||||
tsdbStartFSTxn(pRepo, pMem->pointsAdd, pMem->storageAdd);
|
|
||||||
|
|
||||||
pRepo->code = TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void tsdbEndCommit(STsdbRepo *pRepo, int eno) {
|
|
||||||
if (eno != TSDB_CODE_SUCCESS) {
|
|
||||||
tsdbEndFSTxnWithError(REPO_FS(pRepo));
|
|
||||||
} else {
|
|
||||||
tsdbEndFSTxn(pRepo);
|
|
||||||
}
|
|
||||||
|
|
||||||
tsdbInfo("vgId:%d commit over, %s", REPO_ID(pRepo), (eno == TSDB_CODE_SUCCESS) ? "succeed" : "failed");
|
|
||||||
|
|
||||||
if (pRepo->appH.notifyStatus) pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_OVER, eno);
|
|
||||||
|
|
||||||
SMemTable *pIMem = pRepo->imem;
|
|
||||||
(void)tsdbLockRepo(pRepo);
|
|
||||||
pRepo->imem = NULL;
|
|
||||||
(void)tsdbUnlockRepo(pRepo);
|
|
||||||
tsdbUnRefMemTable(pRepo, pIMem);
|
|
||||||
tsem_post(&(pRepo->readyToCommit));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static bool tsdbHasDataToCommit(SCommitIter *iters, int nIters, TSKEY minKey, TSKEY maxKey) {
|
static bool tsdbHasDataToCommit(SCommitIter *iters, int nIters, TSKEY minKey, TSKEY maxKey) {
|
||||||
for (int i = 0; i < nIters; i++) {
|
for (int i = 0; i < nIters; i++) {
|
||||||
|
|
Loading…
Reference in New Issue