fix: commit after drop child table
This commit is contained in:
parent
4dec02961b
commit
953ded5662
|
@ -264,6 +264,8 @@ STSchema *metaGetTbTSchema(SMeta *pMeta, tb_uid_t uid, int32_t sver) {
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
|
|
||||||
pSW = metaGetTableSchema(pMeta, quid, sver, 0);
|
pSW = metaGetTableSchema(pMeta, quid, sver, 0);
|
||||||
|
if (!pSW) return NULL;
|
||||||
|
|
||||||
tdInitTSchemaBuilder(&sb, 0);
|
tdInitTSchemaBuilder(&sb, 0);
|
||||||
for (int i = 0; i < pSW->nCols; i++) {
|
for (int i = 0; i < pSW->nCols; i++) {
|
||||||
pSchema = pSW->pSchema + i;
|
pSchema = pSW->pSchema + i;
|
||||||
|
|
|
@ -311,7 +311,7 @@ static int tsdbNextCommitFid(SCommitH *pCommith) {
|
||||||
|
|
||||||
for (int i = 0; i < pCommith->niters; i++) {
|
for (int i = 0; i < pCommith->niters; i++) {
|
||||||
SCommitIter *pIter = pCommith->iters + i;
|
SCommitIter *pIter = pCommith->iters + i;
|
||||||
// if (pIter->pTable == NULL || pIter->pIter == NULL) continue;
|
if (pIter->pTable == NULL || pIter->pIter == NULL) continue;
|
||||||
|
|
||||||
TSKEY nextKey = tsdbNextIterKey(pIter->pIter);
|
TSKEY nextKey = tsdbNextIterKey(pIter->pIter);
|
||||||
if (nextKey == TSDB_DATA_TIMESTAMP_NULL) {
|
if (nextKey == TSDB_DATA_TIMESTAMP_NULL) {
|
||||||
|
@ -394,6 +394,9 @@ static int tsdbCommitToFile(SCommitH *pCommith, SDFileSet *pSet, int fid) {
|
||||||
++fIter;
|
++fIter;
|
||||||
}
|
}
|
||||||
++mIter;
|
++mIter;
|
||||||
|
} else if (pIter && !pIter->pTable) {
|
||||||
|
// When table already dropped during commit, pIter is not NULL but pIter->pTable is NULL.
|
||||||
|
++mIter; // skip the table and do nothing
|
||||||
} else if (pIdx) {
|
} else if (pIdx) {
|
||||||
if (tsdbMoveBlkIdx(pCommith, pIdx) < 0) {
|
if (tsdbMoveBlkIdx(pCommith, pIdx) < 0) {
|
||||||
tsdbCloseCommitFile(pCommith, true);
|
tsdbCloseCommitFile(pCommith, true);
|
||||||
|
@ -439,6 +442,7 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) {
|
||||||
SCommitIter *pCommitIter;
|
SCommitIter *pCommitIter;
|
||||||
SSkipListNode *pNode;
|
SSkipListNode *pNode;
|
||||||
STbData *pTbData;
|
STbData *pTbData;
|
||||||
|
STSchema *pTSchema = NULL;
|
||||||
|
|
||||||
pCommith->niters = SL_SIZE(pMem->pSlIdx);
|
pCommith->niters = SL_SIZE(pMem->pSlIdx);
|
||||||
pCommith->iters = (SCommitIter *)taosMemoryCalloc(pCommith->niters, sizeof(SCommitIter));
|
pCommith->iters = (SCommitIter *)taosMemoryCalloc(pCommith->niters, sizeof(SCommitIter));
|
||||||
|
@ -462,11 +466,15 @@ static int tsdbCreateCommitIters(SCommitH *pCommith) {
|
||||||
pCommitIter->pIter = tSkipListCreateIter(pTbData->pData);
|
pCommitIter->pIter = tSkipListCreateIter(pTbData->pData);
|
||||||
tSkipListIterNext(pCommitIter->pIter);
|
tSkipListIterNext(pCommitIter->pIter);
|
||||||
|
|
||||||
|
pTSchema = metaGetTbTSchema(REPO_META(pRepo), pTbData->uid, 0); // TODO: schema version
|
||||||
|
|
||||||
|
if (pTSchema) {
|
||||||
pCommitIter->pTable = (STable *)taosMemoryMalloc(sizeof(STable));
|
pCommitIter->pTable = (STable *)taosMemoryMalloc(sizeof(STable));
|
||||||
pCommitIter->pTable->uid = pTbData->uid;
|
pCommitIter->pTable->uid = pTbData->uid;
|
||||||
pCommitIter->pTable->tid = pTbData->uid;
|
pCommitIter->pTable->tid = pTbData->uid;
|
||||||
pCommitIter->pTable->pSchema = metaGetTbTSchema(REPO_META(pRepo), pTbData->uid, 0);
|
pCommitIter->pTable->pSchema = metaGetTbTSchema(REPO_META(pRepo), pTbData->uid, 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue