提交 f8e20ec3 编写于 作者: S Steven Li

Adjusted crash_gen tool directory structure, added valgrind suppression file...

Adjusted crash_gen tool directory structure, added valgrind suppression file to expose client side memory leaks
上级 a4852c16
Branches不可用
ver ver-3.1.0.2 ver-3.1.0.1 ver-3.1.0.0 ver-3.0.7.8 ver-3.0.7.1 ver-3.0.7.0 ver-3.0.6.1 ver-3.0.6.0 ver-3.0.5.1 ver-3.0.5.0 ver-3.0.4.2 ver-3.0.4.1 ver-3.0.4.0 ver-3.0.3.2 ver-3.0.3.1 ver-3.0.3.0 ver-3.0.2.220221228 ver-3.0.2.20221226 ver-3.0.2.20105 ver-3.0.2.6 ver-3.0.2.5 ver-3.0.2.4 ver-3.0.2.3 ver-3.0.2.2 ver-3.0.2.1 ver-3.0.2.0 ver-3.0.1.8 ver-3.0.1.7 ver-3.0.1.6 ver-3.0.1.5 ver-3.0.1.4 ver-3.0.1.3 ver-3.0.1.2 ver-3.0.1.1 ver-3.0.1.0 ver-3.0.0.2 ver-3.0.0.1 ver-3.0.0.0 ver-2.6.0.99 ver-2.6.0.63 ver-2.6.0.61 ver-2.6.0.59 ver-2.6.0.57 ver-2.6.0.55 ver-2.6.0.53 ver-2.6.0.51 ver-2.6.0.49 ver-2.6.0.47 ver-2.6.0.45 ver-2.6.0.44 ver-2.6.0.43 ver-2.6.0.41 ver-2.6.0.39 ver-2.6.0.38 ver-2.6.0.36 ver-2.6.0.35 ver-2.6.0.34 ver-2.6.0.33 ver-2.6.0.32 ver-2.6.0.31 ver-2.6.0.30 ver-2.6.0.28 ver-2.6.0.27 ver-2.6.0.25 ver-2.6.0.24 ver-2.6.0.22 ver-2.6.0.21 ver-2.6.0.19 ver-2.6.0.18 ver-2.6.0.17 ver-2.6.0.16 ver-2.6.0.15 ver-2.6.0.14 ver-2.6.0.12 ver-2.6.0.10 ver-2.6.0.8 ver-2.6.0.7 ver-2.6.0.6 ver-2.6.0.4 ver-2.6.0.3-kh ver-2.6.0.1 ver-2.6.0.0 ver-2.5.0.1 ver-2.5.0.0 ver-2.4.0.43 ver-2.4.0.41 ver-2.4.0.39 ver-2.4.0.38 ver-2.4.0.37 ver-2.4.0.36 ver-2.4.0.35 ver-2.4.0.33 ver-2.4.0.31 ver-2.4.0.30 ver-2.4.0.27 ver-2.4.0.26 ver-2.4.0.25 ver-2.4.0.24 ver-2.4.0.20 ver-2.4.0.18 ver-2.4.0.16 ver-2.4.0.14 ver-2.4.0.12 ver-2.4.0.11 ver-2.4.0.10 ver-2.4.0.9 ver-2.4.0.8 ver-2.4.0.7 ver-2.4.0.6 ver-2.4.0.5 ver-2.4.0.4 ver-2.4.0.3 ver-2.4.0.2 ver-2.4.0.1 ver-2.4.0.0 ver-2.3.6.0 ver-2.3.5.0 ver-2.3.4.0 ver-2.3.3.0 ver-2.3.2.2 ver-2.3.2.1 ver-2.3.2.0 ver-2.3.1.0 ver-2.3.0.0 ver-2.2.2.16 ver-2.2.2.15 ver-2.2.2.14 ver-2.2.2.13 ver-2.2.2.12 ver-2.2.2.11 ver-2.2.2.10 ver-2.2.2.9 ver-2.2.2.8 ver-2.2.2.7 ver-2.2.2.6 ver-2.2.2.5 ver-2.2.2.4 ver-2.2.2.3 ver-2.2.2.1 ver-2.2.2.1-ningsi ver-2.2.2.0 ver-2.2.1.6 ver-2.2.1.5 ver-2.2.1.4 ver-2.2.1.3 ver-2.2.1.2 ver-2.2.1.1 ver-2.2.1.0 ver-2.2.0.1001 ver-2.2.0.7 ver-2.2.0.6 ver-2.2.0.5 ver-2.2.0.4 ver-2.2.0.3 ver-2.2.0.2 ver-2.2.0.1 ver-2.2.0.0 ver-2.1.7.7 ver-2.1.7.6 ver-2.1.7.2 ver-2.1.7.1 ver-2.1.6.0 ver-2.1.5.0 ver-2.1.4.1 ver-2.1.3.2 ver-2.1.3.0 ver-2.1.2.0 ver-2.1.1.0 ver-2.1.0.1 ver-2.1.0.0 ver-2.1.0 ver-2.0.22.3 ver-2.0.22.2 ver-2.0.22.1 ver-2.0.22.0 ver-2.0.21.6 ver-2.0.21.5 ver-2.0.21.4 ver-2.0.21.3 ver-2.0.21.2 ver-2.0.21.1 ver-2.0.21.0 ver-2.0.20.20 ver-2.0.20.19 ver-2.0.20.18 ver-2.0.20.16 ver-2.0.20.13 ver-2.0.20.12 ver-2.0.20.11 ver-2.0.20.10 ver-2.0.20.9 ver-2.0.20.4 ver-2.0.20.3 ver-2.0.20.2 ver-2.0.20.0 ver-2.0.19.1 ver-2.0.19.0 ver-2.0.18.2 ver-2.0.18.0 ver-2.0.17.4 ver-2.0.17.0 ver-2.0.16.0 ver-2.0.15.0 ver-2.0.14.0 ver-2.0.13.0 ver-2.0.12.0 ver-2.0.11.0 ver-2.0.10.0 ver-2.0.9.0 ver-2.0.8.2 ver-2.0.8.0 ver-2.0.7.0 ver-2.0.6.0 tq-1.0.0.1 release/ver-2.1.2.0 mac-enter-test autoaddcol_07161651 autoaddcol_07161108 autoaddcol_07150626 autoaddcol_0720_1434 autoaddcol_0719_1122 autoaddcol_0718_2208 TDB-ver0.8 TDB-ver-0.7
无相关合并请求
......@@ -43,10 +43,23 @@ TAOSD_DIR=`find $TAOS_DIR -name "taosd"|grep bin|head -n1`
LIB_DIR=`echo $TAOSD_DIR|rev|cut -d '/' -f 3,4,5,6|rev`/lib
# First we need to set up a path for Python to find our own TAOS modules, so that "import" can work.
export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3
export PYTHONPATH=$(pwd)/../../src/connector/python/linux/python3:$(pwd)
# Then let us set up the library path so that our compiled SO file can be loaded by Python
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIB_DIR
# Now we are all let, and let's see if we can find a crash. Note we pass all params
python3.8 ./crash_gen.py $@
if [[ $1 == '--valgrind' ]]; then
shift
export PYTHONMALLOC=malloc
# How to generate valgrind suppression file: https://stackoverflow.com/questions/17159578/generating-suppressions-for-memory-leaks
# valgrind --leak-check=full --gen-suppressions=all --log-fd=9 python3.8 ./crash_gen.py $@ 9>>memcheck.log
valgrind \
--leak-check=yes \
--suppressions=crash_gen/valgrind_taos.supp \
python3.8 \
./crash_gen/crash_gen.py $@
else
python3.8 ./crash_gen/crash_gen.py $@
fi
......@@ -15,7 +15,6 @@
# https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel
from __future__ import annotations
import taos
import crash_gen
from util.sql import *
from util.cases import *
from util.dnodes import *
......@@ -42,6 +41,9 @@ import os
import io
import signal
import traceback
import resource
from guppy import hpy
import gc
try:
import psutil
......@@ -382,6 +384,14 @@ class ThreadCoordinator:
while not self._runShouldEnd(transitionFailed, hasAbortedTask, workerTimeout):
if not gConfig.debug: # print this only if we are not in debug mode
print(".", end="", flush=True)
# if (self._curStep % 2) == 0: # print memory usage once every 10 steps
# memUsage = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
# print("[m:{}]".format(memUsage), end="", flush=True) # print memory usage
# if (self._curStep % 10) == 3:
# h = hpy()
# print("\n")
# print(h.heap())
try:
self._syncAtBarrier() # For now just cross the barrier
......@@ -434,6 +444,19 @@ class ThreadCoordinator:
logger.info("\nAll worker threads finished")
self._execStats.endExec()
def cleanup(self): # free resources
self._pool.cleanup()
self._pool = None
self._te = None
self._dbManager = None
self._executedTasks = None
self._lock = None
self._stepBarrier = None
self._execStats = None
self._runStatus = None
def printStats(self):
self._execStats.printStats()
......@@ -525,6 +548,9 @@ class ThreadPool:
logger.debug("Joining thread...")
workerThread._thread.join()
def cleanup(self):
self.threadList = None # maybe clean up each?
# A queue of continguous POSITIVE integers, used by DbManager to generate continuous numbers
# for new table names
......@@ -812,6 +838,7 @@ class MyTDSql:
# self.cursor.log(caller.filename + ".sql")
def close(self):
self._cursor.close() # can we double close?
self._conn.close() # TODO: very important, cursor close does NOT close DB connection!
self._cursor.close()
......@@ -1819,7 +1846,7 @@ class ExecutionStats:
"| Total Elapsed Time (from wall clock): {:.3f} seconds".format(
self._elapsedTime))
logger.info("| Top numbers written: {}".format(TaskExecutor.getBoundedList()))
logger.info("| Total Number of Active DB Native Connections: {}".format(DbConnNative.totalConnections))
logger.info("| Active DB Native Connections (now): {}".format(DbConnNative.totalConnections))
logger.info("| Longest native query time: {:.3f} seconds, started: {}".
format(MyTDSql.longestQueryTime,
time.strftime("%x %X", time.localtime(MyTDSql.lqStartTime))) )
......@@ -2322,7 +2349,7 @@ class SvcManager:
self.inSigHandler = False
# self._status = MainExec.STATUS_RUNNING # set inside
# _startTaosService()
self.svcMgrThread = None
self.svcMgrThread = None # type: ServiceManagerThread
self._lock = threading.Lock()
self._isRestarting = False
......@@ -2409,13 +2436,12 @@ class SvcManager:
time.sleep(2.0)
proc.kill()
# print("Process: {}".format(proc.name()))
self.svcMgrThread = ServiceManagerThread() # create the object
print("Attempting to start TAOS service started, printing out output...")
self.svcMgrThread.start()
self.svcMgrThread.procIpcBatch(
trimToTarget=10,
forceOutput=True) # for printing 10 lines
self.svcMgrThread.procIpcBatch(trimToTarget=10, forceOutput=True) # for printing 10 lines
print("TAOS service started")
def stopTaosService(self, outputLines=20):
......@@ -2464,7 +2490,7 @@ class ServiceManagerThread:
MAX_QUEUE_SIZE = 10000
def __init__(self):
self._tdeSubProcess = None
self._tdeSubProcess = None # type: TdeSubProcess
self._thread = None
self._status = None
......@@ -2495,13 +2521,13 @@ class ServiceManagerThread:
self._tdeSubProcess.start()
self._ipcQueue = Queue()
self._thread = threading.Thread(
self._thread = threading.Thread( # First thread captures server OUTPUT
target=self.svcOutputReader,
args=(self._tdeSubProcess.getStdOut(), self._ipcQueue))
self._thread.daemon = True # thread dies with the program
self._thread.start()
self._thread2 = threading.Thread(
self._thread2 = threading.Thread( # 2nd thread captures server ERRORs
target=self.svcErrorReader,
args=(self._tdeSubProcess.getStdErr(), self._ipcQueue))
self._thread2.daemon = True # thread dies with the program
......@@ -2866,6 +2892,7 @@ class ClientManager:
def run(self, svcMgr):
# self._printLastNumbers()
global gConfig
dbManager = DbManager() # Regular function
thPool = ThreadPool(gConfig.num_threads, gConfig.max_steps)
......@@ -2876,15 +2903,37 @@ class ClientManager:
# print("TC failed = {}".format(self.tc.isFailed()))
if svcMgr: # gConfig.auto_start_service:
svcMgr.stopTaosService()
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/
return 1 if self.tc.isFailed() else 0
ret = 1 if self.tc.isFailed() else 0
self.tc.cleanup()
# Release global variables
gConfig = None
gSvcMgr = None
logger = None
# Release variables here
self.tc = None
thPool = None
dbManager = None
gc.collect() # force garbage collection
# h = hpy()
# print("\n----- Final Python Heap -----\n")
# print(h.heap())
return ret
def conclude(self):
# self.tc.getDbManager().cleanUp() # clean up first, so we can show ZERO db connections
self.tc.printStats()
self.tc.getDbManager().cleanUp()
class MainExec:
STATUS_STARTING = 1
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部