fix/TS-5251-add-conflict-check-add-case

This commit is contained in:
dmchen 2024-11-06 09:49:27 +08:00
parent 8c1fdc92ed
commit 3598b3b917
2 changed files with 54 additions and 21 deletions

View File

@ -949,8 +949,10 @@ int32_t mndTransCheckConflictWithCompact(SMnode *pMnode, STrans *pTrans) {
pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact); pIter = sdbFetch(pMnode->pSdb, SDB_COMPACT, pIter, (void **)&pCompact);
if (pIter == NULL) break; if (pIter == NULL) break;
if (pTrans->conflict == TRN_CONFLICT_GLOBAL || pTrans->conflict == TRN_CONFLICT_DB || if (pTrans->conflict == TRN_CONFLICT_GLOBAL) {
pTrans->conflict == TRN_CONFLICT_DB_INSIDE) { thisConflict = true;
}
if (pTrans->conflict == TRN_CONFLICT_DB || pTrans->conflict == TRN_CONFLICT_DB_INSIDE) {
if (strcasecmp(pTrans->dbname, pCompact->dbname) == 0) thisConflict = true; if (strcasecmp(pTrans->dbname, pCompact->dbname) == 0) thisConflict = true;
} }

View File

@ -58,40 +58,72 @@ class TDTestCase(TBase):
self.insertData('splitVgroupByLearner.json') self.insertData('splitVgroupByLearner.json')
''' tdSql.execute('use db')
t1 = threading.Thread(target=self.alterDBThread)
t0 = threading.Thread(target=self.compactDBThread)
t0.start()
tdLog.debug("threading started!!!!!")
tdSql.error('ALTER DATABASE db REPLICA 3;', expectErrInfo="Transaction not completed due to conflict with compact")
t0.join()
t1 = threading.Thread(target=self.compactDBThread)
t1.start() t1.start()
tdLog.debug("threading started!!!!!") tdLog.debug("threading started!!!!!")
time.sleep(3) time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed") tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
t1.join() t1.join()
t2 = threading.Thread(target=self.compactDBThread)
t2 = threading.Thread(target=self.splitVgroupThread)
t2.start() t2.start()
tdLog.debug("threading started!!!!!") tdLog.debug("threading started!!!!!")
time.sleep(2) rowLen = tdSql.query('show vgroups')
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed") if rowLen > 0:
vgroupId = tdSql.getData(0, 0)
tdLog.debug(f"splitVgroupThread vgroupId:{vgroupId}")
tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
t2.join() t2.join()
'''
t3 = threading.Thread(target=self.RedistributeVGroups) t3 = threading.Thread(target=self.compactDBThread)
t3.start() t3.start()
tdLog.debug("threading started!!!!!") tdLog.debug("threading started!!!!!")
#time.sleep(2) time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed") tdSql.error('BALANCE VGROUP;', expectErrInfo="Transaction not completed due to conflict with compact")
t3.join() t3.join()
t4 = threading.Thread(target=self.balanceVGROUPThread) t4 = threading.Thread(target=self.splitVgroupThread)
t4.start() t4.start()
tdLog.debug("threading started!!!!!") tdLog.debug("threading started!!!!!")
#time.sleep(2) time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed") tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
t4.join() t4.join()
t5 = threading.Thread(target=self.RedistributeVGroups)
t5.start()
tdLog.debug("threading started!!!!!")
time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
t5.join()
t6 = threading.Thread(target=self.balanceVGROUPThread)
t6.start()
tdLog.debug("threading started!!!!!")
time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
t6.join()
t7 = threading.Thread(target=self.alterDBThread)
t7.start()
tdLog.debug("threading started!!!!!")
time.sleep(1)
tdSql.error('compact database db;', expectErrInfo="Conflict transaction not completed")
t7.join()
def compactDBThread(self):
tdLog.info("compact db start")
tdSql.execute('compact DATABASE db')
if self.waitCompactsZero() is False:
tdLog.info(f"compact not finished")
def alterDBThread(self): def alterDBThread(self):
tdLog.info("alter db start") tdLog.info("alter db start")
@ -127,7 +159,6 @@ class TDTestCase(TBase):
return True return True
def splitVgroupThread(self): def splitVgroupThread(self):
tdSql.execute('use db')
rowLen = tdSql.query('show vgroups') rowLen = tdSql.query('show vgroups')
if rowLen > 0: if rowLen > 0:
vgroupId = tdSql.getData(0, 0) vgroupId = tdSql.getData(0, 0)