fix:add rows to pSub if rebalance
This commit is contained in:
parent
ce0b71c634
commit
865a3b2509
|
@ -472,20 +472,14 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pInput->pRebInfo->key); // put all offset rows
|
SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pInput->pRebInfo->key); // put all offset rows
|
||||||
if (pSub) {
|
if (pSub) {
|
||||||
taosRLockLatch(&pSub->lock);
|
taosRLockLatch(&pSub->lock);
|
||||||
bool init = false;
|
|
||||||
if (pOutput->pSub->offsetRows == NULL) {
|
if (pOutput->pSub->offsetRows == NULL) {
|
||||||
pOutput->pSub->offsetRows = taosArrayInit(4, sizeof(OffsetRows));
|
pOutput->pSub->offsetRows = taosArrayInit(4, sizeof(OffsetRows));
|
||||||
init = true;
|
|
||||||
}
|
}
|
||||||
pIter = NULL;
|
pIter = NULL;
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = taosHashIterate(pSub->consumerHash, pIter);
|
pIter = taosHashIterate(pSub->consumerHash, pIter);
|
||||||
if (pIter == NULL) break;
|
if (pIter == NULL) break;
|
||||||
SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter;
|
SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter;
|
||||||
if (init) {
|
|
||||||
taosArrayAddAll(pOutput->pSub->offsetRows, pConsumerEp->offsetRows);
|
|
||||||
mInfo("pSub->offsetRows is init");
|
|
||||||
} else {
|
|
||||||
SMqConsumerEp *pConsumerEpNew = taosHashGet(pOutput->pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t));
|
SMqConsumerEp *pConsumerEpNew = taosHashGet(pOutput->pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t));
|
||||||
|
|
||||||
for (int j = 0; j < taosArrayGetSize(pConsumerEp->offsetRows); j++) {
|
for (int j = 0; j < taosArrayGetSize(pConsumerEp->offsetRows); j++) {
|
||||||
|
@ -500,14 +494,19 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(jump) continue;
|
if(jump) continue;
|
||||||
|
bool find = false;
|
||||||
for (int i = 0; i < taosArrayGetSize(pOutput->pSub->offsetRows); i++) {
|
for (int i = 0; i < taosArrayGetSize(pOutput->pSub->offsetRows); i++) {
|
||||||
OffsetRows *d2 = taosArrayGet(pOutput->pSub->offsetRows, i);
|
OffsetRows *d2 = taosArrayGet(pOutput->pSub->offsetRows, i);
|
||||||
if (d1->vgId == d2->vgId) {
|
if (d1->vgId == d2->vgId) {
|
||||||
d2->rows += d1->rows;
|
d2->rows += d1->rows;
|
||||||
d2->offset = d1->offset;
|
d2->offset = d1->offset;
|
||||||
|
find = true;
|
||||||
mInfo("pSub->offsetRows add vgId:%d, after:%"PRId64", before:%"PRId64, d2->vgId, d2->rows, d1->rows);
|
mInfo("pSub->offsetRows add vgId:%d, after:%"PRId64", before:%"PRId64, d2->vgId, d2->rows, d1->rows);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(!find){
|
||||||
|
taosArrayPush(pOutput->pSub->offsetRows, d1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue