rsyslog/tests/mysql-asyn.sh
Rainer Gerhards a4a37b5b71
action: guard worker instance check on non-atomic builds
Motivation: CI surfaced TSAN-related flakes suggesting a threading edge
case. This change keeps the atomic fast path efficient and makes the
non-atomic slow path portable and safe. No real-world bug reports.

Impact: Non-atomic builds avoid a nested-lock scenario in worker init.
Atomic builds retain the lock-free fast path. No API/ABI change.

Before/After: non-atomic builds could check instance existence via a
mutex-backed fallback while holding the same mutex / the check happens
under a single mutex (or via atomics), preventing self-deadlock.

Technical: when HAVE_ATOMIC_BUILTINS is set, perform a fast pointer read
and re-check under mutWrkrDataTable (double-checked locking). On
non-atomic toolchains, take mutWrkrDataTable once and read actWrkrData
directly, avoiding fallback atomics that would re-lock the same mutex.
Provide pointer atomics for both __sync-based and mutex-backed paths, and
return type fix for ATOMIC_FETCH_32BIT_unsigned. Also reverts a recent
fix-attempt from earlier this week that introduced the nested-lock risk
on non-atomic builds. Add ommysql README with TSAN context and extend
tsan-rt.supp for libmysqlclient. Minor whitespace tweaks in diag.sh.

Tests/Docs: ommysql/README.md added (TSAN notes), tsan-rt.supp extended.

With the help of AI-Agents: Claude (Anthropic), Codex
2026-01-12 10:23:23 +01:00

35 lines
746 B
Bash
Executable File

#!/bin/bash
# This file is part of the rsyslog project, released under ASL 2.0
# asyn test for mysql functionality (running on async action queue)
. ${srcdir:=.}/diag.sh init
export NUMMESSAGES=25000
generate_conf
add_conf '
$ModLoad ../plugins/ommysql/.libs/ommysql
$ActionQueueType LinkedList
$ActionQueueTimeoutEnqueue 1000
if $msg contains "msgnum:" then {
action(
type="ommysql"
server="127.0.0.1"
db="'$RSYSLOG_DYNNAME'"
uid="rsyslog"
pwd="testbench"
queue.type="LinkedList"
queue.timeoutEnqueue="10000"
queue.workerThreads="2"
queue.workerThreadMinimumMessages="64"
)
}
'
mysql_prep_for_test
startup
injectmsg
shutdown_when_empty
wait_shutdown
mysql_get_data
seq_check
mysql_cleanup_test
exit_test