Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/TD-31459

This commit is contained in:
54liuyao 2024-08-15 15:57:42 +08:00
commit e40f91f8a3
5 changed files with 37 additions and 11 deletions

View File

@ -184,7 +184,7 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) {
code = mndTransValidate(pMnode, pRaw); code = mndTransValidate(pMnode, pRaw);
if (code != 0) { if (code != 0) {
mError("trans:%d, failed to validate requested trans since %s", transId, terrstr()); mError("trans:%d, failed to validate requested trans since %s", transId, terrstr());
code = 0; // code = 0;
pMeta->code = code; pMeta->code = code;
goto _OUT; goto _OUT;
} }
@ -192,7 +192,7 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) {
code = sdbWriteWithoutFree(pMnode->pSdb, pRaw); code = sdbWriteWithoutFree(pMnode->pSdb, pRaw);
if (code != 0) { if (code != 0) {
mError("trans:%d, failed to write to sdb since %s", transId, terrstr()); mError("trans:%d, failed to write to sdb since %s", transId, terrstr());
code = 0; // code = 0;
pMeta->code = code; pMeta->code = code;
goto _OUT; goto _OUT;
} }
@ -207,7 +207,10 @@ int32_t mndProcessWriteMsg(SMnode *pMnode, SRpcMsg *pMsg, SFsmCbMeta *pMeta) {
if (pTrans->stage == TRN_STAGE_PREPARE) { if (pTrans->stage == TRN_STAGE_PREPARE) {
bool continueExec = mndTransPerformPrepareStage(pMnode, pTrans, false); bool continueExec = mndTransPerformPrepareStage(pMnode, pTrans, false);
if (!continueExec) goto _OUT; if (!continueExec) {
if (terrno != 0) code = terrno;
goto _OUT;
}
} }
mndTransRefresh(pMnode, pTrans); mndTransRefresh(pMnode, pTrans);

View File

@ -1569,6 +1569,7 @@ static int32_t mndTransExecuteUndoActionsSerial(SMnode *pMnode, STrans *pTrans,
bool mndTransPerformPrepareStage(SMnode *pMnode, STrans *pTrans, bool topHalf) { bool mndTransPerformPrepareStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
bool continueExec = true; bool continueExec = true;
int32_t code = 0; int32_t code = 0;
terrno = 0;
int32_t numOfActions = taosArrayGetSize(pTrans->prepareActions); int32_t numOfActions = taosArrayGetSize(pTrans->prepareActions);
if (numOfActions == 0) goto _OVER; if (numOfActions == 0) goto _OVER;
@ -1579,7 +1580,9 @@ bool mndTransPerformPrepareStage(SMnode *pMnode, STrans *pTrans, bool topHalf) {
STransAction *pAction = taosArrayGet(pTrans->prepareActions, action); STransAction *pAction = taosArrayGet(pTrans->prepareActions, action);
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf); code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
if (code != 0) { if (code != 0) {
mError("trans:%d, failed to execute prepare action:%d, numOfActions:%d", pTrans->id, action, numOfActions); terrno = code;
mError("trans:%d, failed to execute prepare action:%d, numOfActions:%d, since %s", pTrans->id, action,
numOfActions, tstrerror(code));
return false; return false;
} }
} }

View File

@ -275,12 +275,14 @@ void metaPauseTbCursor(SMTbCursor *pTbCur) {
int32_t metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) { int32_t metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) {
int32_t code = 0; int32_t code = 0;
int32_t lino; int32_t lino;
int8_t locked = 0;
if (pTbCur->paused) { if (pTbCur->paused) {
metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK); metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK);
locked = 1;
code = tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL); code = tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL);
TSDB_CHECK_CODE(code, lino, _exit); if (code != 0) {
TSDB_CHECK_CODE(code, lino, _exit);
}
if (first) { if (first) {
code = tdbTbcMoveToFirst((TBC *)pTbCur->pDbc); code = tdbTbcMoveToFirst((TBC *)pTbCur->pDbc);
@ -304,6 +306,9 @@ int32_t metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) {
} }
_exit: _exit:
if (code != 0 && locked) {
metaReaderReleaseLock(&pTbCur->mr);
}
return code; return code;
} }
@ -791,6 +796,7 @@ void metaCloseSmaCursor(SMSmaCursor *pSmaCur) {
if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta); if (pSmaCur->pMeta) metaULock(pSmaCur->pMeta);
if (pSmaCur->pCur) { if (pSmaCur->pCur) {
(void)tdbTbcClose(pSmaCur->pCur); (void)tdbTbcClose(pSmaCur->pCur);
pSmaCur->pCur = NULL;
tdbFree(pSmaCur->pKey); tdbFree(pSmaCur->pKey);
tdbFree(pSmaCur->pVal); tdbFree(pSmaCur->pVal);
@ -1307,7 +1313,8 @@ int32_t metaFilterTableIds(void *pVnode, SMetaFltParam *arg, SArray *pUids) {
} }
TAOS_CHECK_GOTO(metaCreateTagIdxKey(pCursor->suid, pCursor->cid, tagData, nTagData, pCursor->type, TAOS_CHECK_GOTO(metaCreateTagIdxKey(pCursor->suid, pCursor->cid, tagData, nTagData, pCursor->type,
param->reverse ? INT64_MAX : INT64_MIN, &pKey, &nKey), NULL, END); param->reverse ? INT64_MAX : INT64_MIN, &pKey, &nKey),
NULL, END);
int cmp = 0; int cmp = 0;
TAOS_CHECK_GOTO(tdbTbcMoveTo(pCursor->pCur, pKey, nKey, &cmp), 0, END); TAOS_CHECK_GOTO(tdbTbcMoveTo(pCursor->pCur, pKey, nKey, &cmp), 0, END);

View File

@ -570,7 +570,12 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) {
if (pInfo->pCur == NULL) { if (pInfo->pCur == NULL) {
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode); pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
} else { } else {
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0); code = pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
if (code != 0) {
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
pInfo->pCur = NULL;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
if (pInfo->pSchema == NULL) { if (pInfo->pSchema == NULL) {
@ -786,7 +791,8 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) {
pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode); pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode);
QUERY_CHECK_NULL(pInfo->pCur, code, lino, _end, terrno); QUERY_CHECK_NULL(pInfo->pCur, code, lino, _end, terrno);
} else { } else {
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0); code = pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0);
QUERY_CHECK_CODE(code, lino, _end);
} }
while ((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_SUPER_TABLE)) == 0) { while ((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_SUPER_TABLE)) == 0) {
@ -1589,7 +1595,12 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) {
firstMetaCursor = 1; firstMetaCursor = 1;
} }
if (!firstMetaCursor) { if (!firstMetaCursor) {
(void)pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 1); code = pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 1);
if (code != 0) {
pAPI->metaFn.closeTableMetaCursor(pInfo->pCur);
pInfo->pCur = NULL;
QUERY_CHECK_CODE(code, lino, _end);
}
} }
blockDataCleanup(pInfo->pRes); blockDataCleanup(pInfo->pRes);

View File

@ -2238,6 +2238,8 @@ static int32_t parseDataFromFileImpl(SInsertParseContext* pCxt, SVnodeModifyOpSt
if (pStmt->insertType != TSDB_QUERY_TYPE_FILE_INSERT) { if (pStmt->insertType != TSDB_QUERY_TYPE_FILE_INSERT) {
return buildSyntaxErrMsg(&pCxt->msg, "keyword VALUES or FILE is exclusive", NULL); return buildSyntaxErrMsg(&pCxt->msg, "keyword VALUES or FILE is exclusive", NULL);
} }
} else {
return buildInvalidOperationMsg(&pCxt->msg, tstrerror(code));
} }
// just record pTableCxt whose data come from file // just record pTableCxt whose data come from file