fix: deadlock in tmq test
This commit is contained in:
parent
4ab601279d
commit
b2924fd9c7
|
@ -268,15 +268,13 @@ void mndSyncStop(SMnode *pMnode) {
|
||||||
if (pMnode->syncMgmt.transId != 0) {
|
if (pMnode->syncMgmt.transId != 0) {
|
||||||
pMnode->syncMgmt.transId = 0;
|
pMnode->syncMgmt.transId = 0;
|
||||||
tsem_post(&pMnode->syncMgmt.syncSem);
|
tsem_post(&pMnode->syncMgmt.syncSem);
|
||||||
pMnode->syncMgmt.transId = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mndIsMaster(SMnode *pMnode) {
|
bool mndIsMaster(SMnode *pMnode) {
|
||||||
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
SSyncMgmt *pMgmt = &pMnode->syncMgmt;
|
||||||
|
|
||||||
ESyncState state = syncGetMyRole(pMgmt->sync);
|
if (!syncIsReady(pMgmt->sync)) {
|
||||||
if (state != TAOS_SYNC_STATE_LEADER) {
|
|
||||||
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
terrno = TSDB_CODE_SYN_NOT_LEADER;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -683,6 +683,12 @@ static int32_t mndTransSync(SMnode *pMnode, STrans *pTrans) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool mndCheckDbConflict(const char *db, STrans *pTrans) {
|
||||||
|
if (db[0] == 0) return false;
|
||||||
|
if (strcmp(db, pTrans->dbname1) == 0 || strcmp(db, pTrans->dbname2) == 0) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
|
static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
@ -698,21 +704,18 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) {
|
||||||
if (pNew->conflict == TRN_CONFLICT_DB) {
|
if (pNew->conflict == TRN_CONFLICT_DB) {
|
||||||
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
||||||
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
|
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
|
||||||
if (strcmp(pNew->dbname1, pTrans->dbname1) == 0 || strcmp(pNew->dbname1, pTrans->dbname2) == 0 ||
|
if (mndCheckDbConflict(pNew->dbname1, pTrans)) conflict = true;
|
||||||
strcmp(pNew->dbname2, pTrans->dbname1) == 0 || strcmp(pNew->dbname2, pTrans->dbname2) == 0) {
|
if (mndCheckDbConflict(pNew->dbname2, pTrans)) conflict = true;
|
||||||
conflict = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pNew->conflict == TRN_CONFLICT_DB_INSIDE) {
|
if (pNew->conflict == TRN_CONFLICT_DB_INSIDE) {
|
||||||
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true;
|
||||||
if (pTrans->conflict == TRN_CONFLICT_DB) {
|
if (pTrans->conflict == TRN_CONFLICT_DB) {
|
||||||
if (strcmp(pNew->dbname1, pTrans->dbname1) == 0 || strcmp(pNew->dbname1, pTrans->dbname2) == 0 ||
|
if (mndCheckDbConflict(pNew->dbname1, pTrans)) conflict = true;
|
||||||
strcmp(pNew->dbname2, pTrans->dbname1) == 0 || strcmp(pNew->dbname2, pTrans->dbname2) == 0) {
|
if (mndCheckDbConflict(pNew->dbname2, pTrans)) conflict = true;
|
||||||
conflict = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mError("trans:%d, can't execute since conflict with trans:%d, db1:%s db2:%s", pNew->id, pTrans->id, pTrans->dbname1,
|
mError("trans:%d, can't execute since conflict with trans:%d, db1:%s db2:%s", pNew->id, pTrans->id, pTrans->dbname1,
|
||||||
pTrans->dbname2);
|
pTrans->dbname2);
|
||||||
sdbRelease(pMnode->pSdb, pTrans);
|
sdbRelease(pMnode->pSdb, pTrans);
|
||||||
|
|
Loading…
Reference in New Issue