-
Notifications
You must be signed in to change notification settings - Fork 5k
dmchen/try-copilot-self-audit #35244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,20 +15,24 @@ | |||||||||||
|
|
||||||||||||
| #define _DEFAULT_SOURCE | ||||||||||||
|
|
||||||||||||
| #include "tarray.h" | ||||||||||||
| #include "audit.h" | ||||||||||||
| #include "auditInt.h" | ||||||||||||
| #include "osMemory.h" | ||||||||||||
| #include "taos.h" | ||||||||||||
| #include "taoserror.h" | ||||||||||||
| #include "tarray.h" | ||||||||||||
| #include "tglobal.h" | ||||||||||||
| #include "thttp.h" | ||||||||||||
| #include "ttime.h" | ||||||||||||
| #include "tjson.h" | ||||||||||||
| #include "tglobal.h" | ||||||||||||
| #include "audit.h" | ||||||||||||
| #include "osMemory.h" | ||||||||||||
| #include "ttime.h" | ||||||||||||
|
|
||||||||||||
| SAudit tsAudit = {0}; | ||||||||||||
| char* tsAuditUri = "/audit_v2"; | ||||||||||||
| char* tsAuditBatchUri = "/audit-batch"; | ||||||||||||
|
|
||||||||||||
| extern int32_t auditPreconnectLocal(); | ||||||||||||
| extern void auditStopPreconnectLocal(); | ||||||||||||
|
|
||||||||||||
| static FORCE_INLINE void auditDeleteRecord(SAuditRecord *record) { | ||||||||||||
| if (record) { | ||||||||||||
| taosMemoryFree(record->detail); | ||||||||||||
|
|
@@ -50,13 +54,37 @@ int32_t auditInit(const SAuditCfg *pCfg) { | |||||||||||
| taosArrayDestroyP(tsAudit.records, (FDelete)auditDeleteRecord); | ||||||||||||
| return -1; | ||||||||||||
| } | ||||||||||||
| if (taosThreadMutexInit(&tsAudit.connLock, NULL) != 0) { | ||||||||||||
| (void)taosThreadMutexDestroy(&tsAudit.recordLock); | ||||||||||||
| (void)taosThreadRwlockDestroy(&tsAudit.infoLock); | ||||||||||||
| taosArrayDestroyP(tsAudit.records, (FDelete)auditDeleteRecord); | ||||||||||||
| return -1; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Start non-blocking preconnect in background so startup and RPC threads never wait on taos_connect. | ||||||||||||
| if (auditPreconnectLocal() != 0) { | ||||||||||||
|
Comment on lines
+64
to
+65
|
||||||||||||
| // Start non-blocking preconnect in background so startup and RPC threads never wait on taos_connect. | |
| if (auditPreconnectLocal() != 0) { | |
| // Start non-blocking preconnect in background only when local audit write is enabled, | |
| // so startup and RPC threads never wait on taos_connect for an opt-in feature. | |
| if (tsAuditLocalWrite && auditPreconnectLocal() != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential undefined behavior: if auditInit fails before tsAudit.connLock is initialized (e.g., if taosArrayInit or taosThreadRwlockInit fails), tsAudit.connLock remains zero-initialized. Calling taosThreadMutexLock on an uninitialized mutex is unsafe. Consider adding a check to verify that the audit system was successfully initialized before attempting to lock and destroy its mutexes.
Copilot
AI
Apr 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auditCleanup() unconditionally locks/destroys tsAudit.connLock. If auditInit() returns early before connLock is initialized (e.g., records/locks init failure), cleanup can still be invoked during env teardown and this becomes undefined behavior. Track whether connLock was successfully initialized (and whether pLocalConn was ever created) and only lock/destroy/close when initialized; alternatively initialize connLock in a way that makes cleanup always safe.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,64 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/sh | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| set +e | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #set -x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| unset LD_PRELOAD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| UNAME_BIN=`which uname` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OS_TYPE=`$UNAME_BIN` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| psby() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$OS_TYPE" != "Darwin" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ps -C $1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ps a -c | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PID=`ps -efww | grep /usr/bin/taosd | grep -v grep | awk '{print $2}'` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -n "$PID" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo systemctl stop taosd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| systemctl stop taosd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PID=`psby taosd | grep -w "[t]aosd" | awk '{print $1}' | head -n 1` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while [ -n "$PID" ]; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo kill -9 $PID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #pkill -9 taosd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kill -9 $PID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Killing taosd processes" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$OS_TYPE" != "Darwin" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fuser -k -n tcp 6030 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lsof -nti:6030 | xargs kill -9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+31
to
+34
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PID=`psby taosd | grep -w "[t]aosd" | awk '{print $1}' | head -n 1` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PID=`psby taos | grep -w "[t]aos" | awk '{print $1}' | head -n 1` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while [ -n "$PID" ]; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo kill -9 $PID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #pkill -9 taos | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kill -9 $PID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Killing taos processes" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$OS_TYPE" != "Darwin" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fuser -k -n tcp 6030 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lsof -nti:6030 | xargs kill -9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PID=`psby taos | grep -w "[t]aos" | awk '{print $1}' | head -n 1` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PID=`psby tmq_sim | grep -w "[t]mq_sim" | awk '{print $1}' | head -n 1` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| while [ -n "$PID" ]; do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo kill -9 $PID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #pkill -9 tmq_sim | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| kill -9 $PID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Killing tmq_sim processes" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ "$OS_TYPE" != "Darwin" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fuser -k -n tcp 6030 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lsof -nti:6030 | xargs kill -9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PID=`psby tmq_sim | grep -w "[t]mq_sim" | awk '{print $1}' | head -n 1` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+18
to
+64
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| PID=`ps -efww | grep /usr/bin/taosd | grep -v grep | awk '{print $2}'` | |
| if [ -n "$PID" ]; then | |
| echo systemctl stop taosd | |
| systemctl stop taosd | |
| fi | |
| PID=`psby taosd | grep -w "[t]aosd" | awk '{print $1}' | head -n 1` | |
| while [ -n "$PID" ]; do | |
| echo kill -9 $PID | |
| #pkill -9 taosd | |
| kill -9 $PID | |
| echo "Killing taosd processes" | |
| if [ "$OS_TYPE" != "Darwin" ]; then | |
| fuser -k -n tcp 6030 | |
| else | |
| lsof -nti:6030 | xargs kill -9 | |
| fi | |
| PID=`psby taosd | grep -w "[t]aosd" | awk '{print $1}' | head -n 1` | |
| done | |
| PID=`psby taos | grep -w "[t]aos" | awk '{print $1}' | head -n 1` | |
| while [ -n "$PID" ]; do | |
| echo kill -9 $PID | |
| #pkill -9 taos | |
| kill -9 $PID | |
| echo "Killing taos processes" | |
| if [ "$OS_TYPE" != "Darwin" ]; then | |
| fuser -k -n tcp 6030 | |
| else | |
| lsof -nti:6030 | xargs kill -9 | |
| fi | |
| PID=`psby taos | grep -w "[t]aos" | awk '{print $1}' | head -n 1` | |
| done | |
| PID=`psby tmq_sim | grep -w "[t]mq_sim" | awk '{print $1}' | head -n 1` | |
| while [ -n "$PID" ]; do | |
| echo kill -9 $PID | |
| #pkill -9 tmq_sim | |
| kill -9 $PID | |
| echo "Killing tmq_sim processes" | |
| if [ "$OS_TYPE" != "Darwin" ]; then | |
| fuser -k -n tcp 6030 | |
| else | |
| lsof -nti:6030 | xargs kill -9 | |
| fi | |
| PID=`psby tmq_sim | grep -w "[t]mq_sim" | awk '{print $1}' | head -n 1` | |
| done | |
| kill_processes_with_retry() { | |
| PROC_NAME="$1" | |
| GREP_PATTERN="$2" | |
| MAX_RETRIES=10 | |
| RETRY_COUNT=0 | |
| PID=`psby "$PROC_NAME" | grep -w "$GREP_PATTERN" | awk '{print $1}' | head -n 1` | |
| while [ -n "$PID" ] && [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; do | |
| echo kill -9 "$PID" | |
| kill -9 "$PID" | |
| if command -v pkill >/dev/null 2>&1; then | |
| pkill -9 "$PROC_NAME" | |
| fi | |
| echo "Killing $PROC_NAME processes" | |
| if [ "$OS_TYPE" != "Darwin" ]; then | |
| fuser -k -n tcp 6030 | |
| else | |
| lsof -nti:6030 | xargs kill -9 | |
| fi | |
| RETRY_COUNT=`expr "$RETRY_COUNT" + 1` | |
| sleep 1 | |
| PID=`psby "$PROC_NAME" | grep -w "$GREP_PATTERN" | awk '{print $1}' | head -n 1` | |
| done | |
| if [ -n "$PID" ]; then | |
| echo "Failed to kill $PROC_NAME processes after $MAX_RETRIES attempts; last PID: $PID" | |
| fi | |
| } | |
| PID=`ps -efww | grep /usr/bin/taosd | grep -v grep | awk '{print $2}'` | |
| if [ -n "$PID" ]; then | |
| echo systemctl stop taosd | |
| systemctl stop taosd | |
| fi | |
| kill_processes_with_retry taosd "[t]aosd" | |
| kill_processes_with_retry taos "[t]aos" | |
| kill_processes_with_retry tmq_sim "[t]mq_sim" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from util.log import * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from util.cases import * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from util.sql import * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from ..common.basic import BasicFun | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class TDTestCase: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def init(self, conn, logSql, replicaVar=1): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.debug(f"start to execute {__file__}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.replicaVar = int(replicaVar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self.Fun = BasicFun() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+4
to
+14
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import time | |
| from ..common.basic import BasicFun | |
| class TDTestCase: | |
| def init(self, conn, logSql, replicaVar=1): | |
| tdLog.debug(f"start to execute {__file__}") | |
| self.replicaVar = int(replicaVar) | |
| self.Fun = BasicFun() | |
| from util.dnodes import * | |
| import time | |
| class BasicFunCompat: | |
| def __init__(self, conn, logSql): | |
| self.conn = conn | |
| self.logSql = logSql | |
| self.TDDnodes = tdDnodes | |
| self.dnodes_count = 1 | |
| def config_cluster(self, dnodes_count): | |
| self.dnodes_count = int(dnodes_count) | |
| if hasattr(self.TDDnodes, "init"): | |
| self.TDDnodes.init(self.dnodes_count) | |
| def deploy_start_cluster(self): | |
| if hasattr(self.TDDnodes, "deploy"): | |
| self.TDDnodes.deploy(self.dnodes_count) | |
| if hasattr(self.TDDnodes, "start"): | |
| self.TDDnodes.start(self.dnodes_count) | |
| def connect(self): | |
| tdSql.init(self.conn.cursor(), self.logSql) | |
| class TDTestCase: | |
| def init(self, conn, logSql, replicaVar=1): | |
| tdLog.debug(f"start to execute {__file__}") | |
| self.replicaVar = int(replicaVar) | |
| self.conn = conn | |
| self.logSql = logSql | |
| tdSql.init(conn.cursor(), logSql) | |
| self.Fun = BasicFunCompat(conn, logSql) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the error path of
auditInit, after destroying therecordsarray, it is important to set the pointer toNULL. This prevents potential double-free or use-after-free issues ifauditCleanupis called later (which is common during dnode shutdown even if initialization partially failed).