enh: trigger vnode commit at exit if meta changed, for dbs of single replica
This commit is contained in:
parent
421a154d2a
commit
f7f9546d1e
|
@ -79,6 +79,7 @@ struct SMeta {
|
|||
|
||||
char* path;
|
||||
SVnode* pVnode;
|
||||
bool changed;
|
||||
TDB* pEnv;
|
||||
TXN* txn;
|
||||
TTB* pTbDb;
|
||||
|
|
|
@ -56,7 +56,7 @@ int metaPrepareAsyncCommit(SMeta *pMeta) {
|
|||
code = ttlMgrFlush(pMeta->pTtlMgr, pMeta->txn);
|
||||
metaULock(pMeta);
|
||||
code = tdbCommit(pMeta->pEnv, pMeta->txn);
|
||||
|
||||
pMeta->changed = false;
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -251,6 +251,7 @@ int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
|
||||
++pMeta->pVnode->config.vndStats.numOfSTables;
|
||||
|
||||
pMeta->changed = true;
|
||||
metaDebug("vgId:%d, stb:%s is created, suid:%" PRId64, TD_VID(pMeta->pVnode), pReq->name, pReq->suid);
|
||||
|
||||
return 0;
|
||||
|
@ -325,6 +326,8 @@ _drop_super_table:
|
|||
|
||||
metaUpdTimeSeriesNum(pMeta);
|
||||
|
||||
pMeta->changed = true;
|
||||
|
||||
_exit:
|
||||
tdbFree(pKey);
|
||||
tdbFree(pData);
|
||||
|
@ -424,6 +427,8 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
|
|||
metaTimeSeriesNotifyCheck(pMeta);
|
||||
}
|
||||
|
||||
pMeta->changed = true;
|
||||
|
||||
_exit:
|
||||
if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf);
|
||||
tDecoderClear(&dc);
|
||||
|
@ -847,6 +852,7 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs
|
|||
}
|
||||
}
|
||||
|
||||
pMeta->changed = true;
|
||||
metaDebug("vgId:%d, table:%s uid %" PRId64 " is created, type:%" PRId8, TD_VID(pMeta->pVnode), pReq->name, pReq->uid,
|
||||
pReq->type);
|
||||
return 0;
|
||||
|
@ -895,6 +901,7 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
|
|||
*tbUid = uid;
|
||||
}
|
||||
|
||||
pMeta->changed = true;
|
||||
_exit:
|
||||
tdbFree(pData);
|
||||
return rc;
|
||||
|
@ -938,6 +945,8 @@ void metaDropTables(SMeta *pMeta, SArray *tbUids) {
|
|||
}
|
||||
}
|
||||
tSimpleHashCleanup(suidHash);
|
||||
|
||||
pMeta->changed = true;
|
||||
}
|
||||
|
||||
static int32_t metaFilterTableByHash(SMeta *pMeta, SArray *uidList) {
|
||||
|
@ -1970,6 +1979,7 @@ _err:
|
|||
}
|
||||
|
||||
int metaAlterTable(SMeta *pMeta, int64_t version, SVAlterTbReq *pReq, STableMetaRsp *pMetaRsp) {
|
||||
pMeta->changed = true;
|
||||
switch (pReq->action) {
|
||||
case TSDB_ALTER_TABLE_ADD_COLUMN:
|
||||
case TSDB_ALTER_TABLE_DROP_COLUMN:
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "meta.h"
|
||||
#include "sync.h"
|
||||
#include "vnd.h"
|
||||
#include "vnodeInt.h"
|
||||
#include "sync.h"
|
||||
|
||||
extern int32_t tsdbPreCommit(STsdb *pTsdb);
|
||||
extern int32_t tsdbCommitBegin(STsdb *pTsdb, SCommitInfo *pInfo);
|
||||
|
@ -155,7 +156,8 @@ int vnodeShouldCommit(SVnode *pVnode, bool atExit) {
|
|||
|
||||
taosThreadMutexLock(&pVnode->mutex);
|
||||
if (pVnode->inUse && diskAvail) {
|
||||
needCommit = (pVnode->inUse->size > pVnode->inUse->node.size) || (pVnode->inUse->size > 0 && atExit);
|
||||
needCommit = (pVnode->inUse->size > pVnode->inUse->node.size) ||
|
||||
(atExit && (pVnode->inUse->size > 0 || pVnode->pMeta->changed));
|
||||
}
|
||||
taosThreadMutexUnlock(&pVnode->mutex);
|
||||
return needCommit;
|
||||
|
|
Loading…
Reference in New Issue