提交 9383fc9c 编写于 作者: S slguan

fix issue #502

上级 a721d0d2
...@@ -393,7 +393,7 @@ void vnodeCloseCommitFiles(SVnodeObj *pVnode) { ...@@ -393,7 +393,7 @@ void vnodeCloseCommitFiles(SVnodeObj *pVnode) {
if (tsCheckHeaderFile != 0) { if (tsCheckHeaderFile != 0) {
assert(vnodeCheckNewHeaderFile(pVnode->nfd, pVnode) == 0); assert(vnodeCheckNewHeaderFile(pVnode->nfd, pVnode) == 0);
} }
close(pVnode->nfd); close(pVnode->nfd);
pVnode->nfd = 0; pVnode->nfd = 0;
...@@ -649,23 +649,39 @@ _again: ...@@ -649,23 +649,39 @@ _again:
// last block is at last file // last block is at last file
if (pMeter->last) { if (pMeter->last) {
if (pMeter->lastBlock.sversion != pObj->sversion) { if ((pMeter->lastBlock.sversion != pObj->sversion) || (query.over)) {
// TODO : Check the correctness of this code. write the last block to // TODO : Check the correctness of this code. write the last block to
// .data file // .data file
pCompBlock = (SCompBlock *)(hmem + headLen); pCompBlock = (SCompBlock *)(hmem + headLen);
assert(dmem - (char *)pCompBlock >= sizeof(SCompBlock)); assert(dmem - (char *)pCompBlock >= sizeof(SCompBlock));
*pCompBlock = pMeter->lastBlock; *pCompBlock = pMeter->lastBlock;
pCompBlock->last = 0; if (pMeter->lastBlock.sversion != pObj->sversion) {
pCompBlock->offset = lseek(pVnode->dfd, 0, SEEK_END); pCompBlock->last = 0;
lseek(pVnode->lfd, pMeter->lastBlock.offset, SEEK_SET); pCompBlock->offset = lseek(pVnode->dfd, 0, SEEK_END);
tsendfile(pVnode->dfd, pVnode->lfd, NULL, pMeter->lastBlock.len); pMeter->last = 0;
pVnode->dfSize = pCompBlock->offset + pMeter->lastBlock.len; lseek(pVnode->lfd, pMeter->lastBlock.offset, SEEK_SET);
tsendfile(pVnode->dfd, pVnode->lfd, NULL, pMeter->lastBlock.len);
pVnode->dfSize = pCompBlock->offset + pMeter->lastBlock.len;
} else {
if (ssid == 0) {
// Here, pVnode->tfd != -1
assert(pVnode->tfd != -1);
pCompBlock->offset = lseek(pVnode->tfd, 0, SEEK_END);
lseek(pVnode->lfd, pMeter->lastBlock.offset, SEEK_SET);
tsendfile(pVnode->tfd, pVnode->lfd, NULL, pMeter->lastBlock.len);
pVnode->lfSize = pCompBlock->offset + pMeter->lastBlock.len;
} else {
// Here, pVnode->tfd = -1
assert(pVnode->tfd == -1);
}
}
headLen += sizeof(SCompBlock); headLen += sizeof(SCompBlock);
pMeter->newNumOfBlocks++; pMeter->newNumOfBlocks++;
} else { } else {
// read last block into memory // read last block into memory
if (vnodeReadLastBlockToMem(pObj, &pMeter->lastBlock, data) < 0) goto _over; if (vnodeReadLastBlockToMem(pObj, &pMeter->lastBlock, data) < 0) goto _over;
pMeter->last = 0;
pointsReadLast = pMeter->lastBlock.numOfPoints; pointsReadLast = pMeter->lastBlock.numOfPoints;
query.over = 0; query.over = 0;
headInfo.totalStorage -= (pointsReadLast * pObj->bytesPerPoint); headInfo.totalStorage -= (pointsReadLast * pObj->bytesPerPoint);
...@@ -675,7 +691,6 @@ _again: ...@@ -675,7 +691,6 @@ _again:
} }
pMeter->changed = 1; pMeter->changed = 1;
pMeter->last = 0;
pMeter->oldNumOfBlocks--; pMeter->oldNumOfBlocks--;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册