meta snapshot write
This commit is contained in:
parent
be85e27234
commit
b3da0e2a15
|
@ -57,6 +57,9 @@ int metaRemoveTableFromIdx(SMeta* pMeta, tb_uid_t uid);
|
|||
// metaCommit ==================
|
||||
static FORCE_INLINE tb_uid_t metaGenerateUid(SMeta* pMeta) { return tGenIdPI64(); }
|
||||
|
||||
// metaTable ==================
|
||||
int metaHandleEntry(SMeta* pMeta, const SMetaEntry* pME);
|
||||
|
||||
struct SMeta {
|
||||
TdThreadRwlock lock;
|
||||
|
||||
|
|
|
@ -166,6 +166,19 @@ _err:
|
|||
|
||||
int32_t metaSnapWrite(SMetaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
int32_t code = 0;
|
||||
// TODO
|
||||
SMeta* pMeta = pWriter->pMeta;
|
||||
SMetaEntry metaEntry = {0};
|
||||
SDecoder* pDecoder = &(SDecoder){0};
|
||||
|
||||
tDecoderInit(pDecoder, pData, nData);
|
||||
metaDecodeEntry(pDecoder, &metaEntry);
|
||||
|
||||
code = metaHandleEntry(pMeta, &metaEntry);
|
||||
if (code) goto _err;
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
metaError("vgId:%d meta snapshot write failed since %s", TD_VID(pMeta->pVnode), tstrerror(code));
|
||||
return code;
|
||||
}
|
|
@ -16,7 +16,6 @@
|
|||
#include "meta.h"
|
||||
|
||||
static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const SSchema *pSchema);
|
||||
static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME);
|
||||
static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME);
|
||||
static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||
static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME);
|
||||
|
@ -419,7 +418,6 @@ static int metaDeleteTtlIdx(SMeta *pMeta, const SMetaEntry *pME) {
|
|||
return tdbTbDelete(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), &pMeta->txn);
|
||||
}
|
||||
|
||||
|
||||
static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
||||
void *pData = NULL;
|
||||
int nData = 0;
|
||||
|
@ -442,7 +440,6 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) {
|
|||
tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), &pMeta->txn);
|
||||
if (e.type != TSDB_SUPER_TABLE) metaDeleteTtlIdx(pMeta, &e);
|
||||
|
||||
|
||||
if (e.type == TSDB_CHILD_TABLE) {
|
||||
tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), &pMeta->txn);
|
||||
} else if (e.type == TSDB_NORMAL_TABLE) {
|
||||
|
@ -1072,7 +1069,7 @@ _exit:
|
|||
return rcode;
|
||||
}
|
||||
|
||||
static int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
int metaHandleEntry(SMeta *pMeta, const SMetaEntry *pME) {
|
||||
metaWLock(pMeta);
|
||||
|
||||
// save to table.db
|
||||
|
|
|
@ -449,6 +449,8 @@ static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint3
|
|||
} else if (c < 0) {
|
||||
code = tsdbSnapWriteAppendData(pWriter, pData, nData);
|
||||
if (code) goto _err;
|
||||
|
||||
break;
|
||||
} else {
|
||||
// commit the block
|
||||
code = tsdbReadBlock(pWriter->pDataFReader, pBlockIdx, &pWriter->mBlock, NULL);
|
||||
|
|
Loading…
Reference in New Issue