提交 204792c5 编写于 作者: S Steven Li

Fixed TD-2499, ensuring crash_gen tool releases ALL DB connections when completing tests

上级 088cd990
...@@ -2224,23 +2224,26 @@ class ClientManager: ...@@ -2224,23 +2224,26 @@ class ClientManager:
if svcMgr: # gConfig.auto_start_service: if svcMgr: # gConfig.auto_start_service:
svcMgr.stopTaosServices() svcMgr.stopTaosServices()
svcMgr = None svcMgr = None
# Print exec status, etc., AFTER showing messages from the server
self.conclude()
# print("TC failed (2) = {}".format(self.tc.isFailed()))
# Linux return code: ref https://shapeshed.com/unix-exit-codes/
ret = 1 if self.tc.isFailed() else 0
self.tc.cleanup()
# Release global variables # Release global variables
gConfig = None gConfig = None
gSvcMgr = None gSvcMgr = None
logger = None logger = None
# Release variables here
self.tc = None
thPool = None thPool = None
dbManager.cleanUp() # destructor wouldn't run in time
dbManager = None dbManager = None
# Print exec status, etc., AFTER showing messages from the server
self.conclude()
# print("TC failed (2) = {}".format(self.tc.isFailed()))
# Linux return code: ref https://shapeshed.com/unix-exit-codes/
ret = 1 if self.tc.isFailed() else 0
self.tc.cleanup()
# Release variables here
self.tc = None
gc.collect() # force garbage collection gc.collect() # force garbage collection
# h = hpy() # h = hpy()
# print("\n----- Final Python Heap -----\n") # print("\n----- Final Python Heap -----\n")
......
...@@ -394,6 +394,7 @@ class DbManager(): ...@@ -394,6 +394,7 @@ class DbManager():
cType == 'native') else DbConn.createRest(dbTarget) cType == 'native') else DbConn.createRest(dbTarget)
try: try:
self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected self._dbConn.open() # may throw taos.error.ProgrammingError: disconnected
Logging.debug("DbManager opened DB connection...")
except taos.error.ProgrammingError as err: except taos.error.ProgrammingError as err:
# print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err)) # print("Error type: {}, msg: {}, value: {}".format(type(err), err.msg, err))
if (err.msg == 'client disconnected'): # cannot open DB connection if (err.msg == 'client disconnected'): # cannot open DB connection
...@@ -412,6 +413,10 @@ class DbManager(): ...@@ -412,6 +413,10 @@ class DbManager():
# Moved to Database() # Moved to Database()
# self._stateMachine = StateMechine(self._dbConn) # self._stateMachine = StateMechine(self._dbConn)
def __del__(self):
''' Release the underlying DB connection upon deletion of DbManager '''
self.cleanUp()
def getDbConn(self): def getDbConn(self):
return self._dbConn return self._dbConn
...@@ -438,5 +443,8 @@ class DbManager(): ...@@ -438,5 +443,8 @@ class DbManager():
return "table_{}".format(tblNum) return "table_{}".format(tblNum)
def cleanUp(self): def cleanUp(self):
if self._dbConn:
self._dbConn.close() self._dbConn.close()
self._dbConn = None
Logging.debug("DbManager closed DB connection...")
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册