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

This commit is contained in:
dmchen 2024-11-11 09:54:56 +08:00
parent 3598b3b917
commit b1d5dc9e05
1 changed files with 59 additions and 52 deletions

View File

@ -23,7 +23,7 @@ class TDTestCase(TBase):
tdLog.debug(f"start to init {__file__}")
self.replicaVar = int(replicaVar)
tdSql.init(conn.cursor(), logSql) # output sql.txt file
self.configJsonFile('splitVgroupByLearner.json', 'db', 4, 1, 'splitVgroupByLearner.json', 100000)
self.configJsonFile('splitVgroupByLearner.json', 'db', 4, 1, 'compactDBConflict.json', 100000)
def configJsonFile(self, fileName, dbName, vgroups, replica, newFileName='', insert_rows=100000,
timestamp_step=10000):
@ -60,22 +60,27 @@ class TDTestCase(TBase):
tdSql.execute('use db')
t0 = threading.Thread(target=self.compactDBThread)
event0 = threading.Event()
t0 = threading.Thread(target=self.compactDBThread, args=(event0))
t0.start()
tdLog.debug("threading started!!!!!")
event0.wait()
tdSql.error('ALTER DATABASE db REPLICA 3;', expectErrInfo="Transaction not completed due to conflict with compact")
t0.join()
t1 = threading.Thread(target=self.compactDBThread)
event1 = threading.Event()
t1 = threading.Thread(target=self.compactDBThread, args=(event1))
t1.start()
tdLog.debug("threading started!!!!!")
time.sleep(1)
event1.wait()
tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
t1.join()
t2 = threading.Thread(target=self.compactDBThread)
event2 = threading.Event()
t2 = threading.Thread(target=self.compactDBThread, args=(event2))
t2.start()
tdLog.debug("threading started!!!!!")
event2.wait()
rowLen = tdSql.query('show vgroups')
if rowLen > 0:
vgroupId = tdSql.getData(0, 0)
@ -83,10 +88,11 @@ class TDTestCase(TBase):
tdSql.error('REDISTRIBUTE VGROUP 5 DNODE 1;', expectErrInfo="Transaction not completed due to conflict with compact")
t2.join()
t3 = threading.Thread(target=self.compactDBThread)
event3 = threading.Event()
t3 = threading.Thread(target=self.compactDBThread, args=(event3))
t3.start()
tdLog.debug("threading started!!!!!")
time.sleep(1)
event3.wait()
tdSql.error('BALANCE VGROUP;', expectErrInfo="Transaction not completed due to conflict with compact")
t3.join()
@ -119,9 +125,10 @@ class TDTestCase(TBase):
t7.join()
def compactDBThread(self):
def compactDBThread(self, event):
tdLog.info("compact db start")
tdSql.execute('compact DATABASE db')
event.set()
if self.waitCompactsZero() is False:
tdLog.info(f"compact not finished")