fix/add-kill-restore-case

This commit is contained in:
dmchen 2024-11-13 19:31:56 +08:00
parent 11be1b1803
commit 2e3f9c0922
3 changed files with 115 additions and 2 deletions

View File

@ -1599,8 +1599,9 @@ static int32_t mndTransExecuteActionsSerial(SMnode *pMnode, STrans *pTrans, SArr
for (int32_t action = pTrans->actionPos; action < numOfActions; ++action) {
STransAction *pAction = taosArrayGet(pActions, action);
mInfo("trans:%d, current action:%d, stage:%s, actionType(0:log,1:msg):%d", pTrans->id, pTrans->actionPos,
mndTransStr(pAction->stage), pAction->actionType);
mInfo("trans:%d, current action:%d, stage:%s, actionType:%s, msgSent:%d, msgReceived:%d", pTrans->id,
pTrans->actionPos, mndTransStr(pAction->stage), mndTransTypeStr(pAction->actionType), pAction->msgSent,
pAction->msgReceived);
code = mndTransExecSingleAction(pMnode, pTrans, pAction, topHalf);
if (code == 0) {
@ -2462,6 +2463,7 @@ static int32_t mndRetrieveTransDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBloc
SArray *pActions = mndTransGetAction(pShowIter->pTrans, pShowIter->pTrans->stage);
mndTransShowActions(pSdb, pShowIter, pShow, pBlock, rows, &numOfRows, pActions, taosArrayGetSize(pActions), 0);
break;
} else {
mInfo("retrieve trans detail from iter, id:%d, iterStage:%d, IterNum:%d", pShowIter->pTrans->id, pShowIter->stage,
pShowIter->num);

View File

@ -0,0 +1,83 @@
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
from util.log import *
from util.cases import *
from util.sql import *
from util.common import *
sys.path.append("./3-enterprise/restore")
from restoreBasic import *
from util.common import tdCom
import threading
class TDTestCase:
# init
def init(self, conn, logSql, replicaVar=1):
tdLog.debug("start to execute %s" % __file__)
self.basic = RestoreBasic()
self.basic.init(conn, logSql, replicaVar)
# run
def run(self):
self.basic.restore_dnode_prepare(2)
self.execute()
def execute(self):
newTdSql=tdCom.newTdSql()
t0 = threading.Thread(target=self.restoreDnodeThread, args=('', newTdSql))
t0.start()
time.sleep(2)
sql ="show transactions;"
tdLog.info(sql)
rows = tdSql.query(sql)
if rows > 0:
self.basic.stop_dnode(2)
tranId = tdSql.getData(0, 0)
tdLog.info('kill transaction %d'%tranId)
tdSql.execute('kill transaction %d'%tranId, queryTimes=1 )
time.sleep(3)
sql ="show transactions;"
tdLog.info(sql)
rows = tdSql.query(sql)
if rows > 0:
tdLog.info(f"{sql} transaction not finished")
return False
self.basic.restore_dnode_exec(2)
else:
tdLog.exit(f"{sql} no transaction exist")
return False
def restoreDnodeThread(self, p, newTdSql):
sleep(1)
sql = f"restore dnode 2"
tdLog.info(sql)
newTdSql.error(sql, expectErrInfo="Wrong transaction execution context")
tdLog.info(f"{sql} finished")
# stop
def stop(self):
self.basic.stop()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())

View File

@ -143,6 +143,34 @@ class RestoreBasic:
tdSql.execute(sql)
self.check_corrent()
def restore_dnode_prepare(self, index):
tdLog.info(f"start restore dnode {index}")
dnode = self.dnodes[index - 1]
# stop dnode
tdLog.info(f"stop dnode {index}")
dnode.stoptaosd()
# remove dnode folder
try:
shutil.rmtree(dnode.dataDir)
tdLog.info(f"delete dir {dnode.dataDir} successful")
except OSError as x:
tdLog.exit(f"remove path {dnode.dataDir} error : {x.strerror}")
dnode.starttaosd()
def restore_dnode_exec(self, index):
# exec restore
sql = f"restore dnode {index}"
tdLog.info(sql)
tdSql.execute(sql)
self.check_corrent()
def stop_dnode(self, index):
dnode = self.dnodes[index - 1]
dnode.starttaosd()
# restore vnode
def restore_vnode(self, index):
tdLog.info(f"start restore vnode on dnode {index}")