mirror of https://github.com/sysown/proxysql
fix(mysqlx): address reviewer feedback (transaction safety, fail-closed TLS, hostgroup refresh, status string)
Four reviewer-flagged issues from CodeRabbit + Gemini on the
consolidated mysqlx stack (originally raised on PRs #5704, #5707,
#5709), all addressed in one place since this is the consolidation
branch:
1. SQLite transaction safety in stats projections.
`MysqlxStatsStore::flush_to_sqlite` and
`mysqlx_populate_stats_processlist` previously did a bare DELETE
followed by a per-row INSERT loop. A transient SQLite error in
any INSERT left the projection table empty, which is far more
misleading to operators than stale-but-recent rows. Wrap both in
BEGIN/DELETE/INSERT/COMMIT with explicit ROLLBACK on any failure;
on rollback, the previous projection stays in place.
2. Fail-closed when backend TLS is required but no SSL_CTX is
available. The earlier code in handler_connecting_server had
`if (desired_backend_tls) { if (ctx) { /* set up TLS */ } }` —
the inner `if (ctx)` was a guard with no else-branch, so a
missing SSL_CTX silently produced a plaintext backend connection
in TLS-required and AsClient-on-TLS-frontend scenarios. Reject
the connect with X-Protocol error 2026 ("Backend TLS required
but no SSL context configured on this worker") instead. Caught
by CodeRabbit on PR #5707.
3. Stale destination_hostgroup in stats rows. `MysqlxStatsStore::
get_or_create` only set `destination_hostgroup` on first insert.
If a route was rebound to a different hostgroup via LOAD MYSQLX
ROUTES TO RUNTIME, subsequent traffic continued reporting the
first-seen hostgroup forever. Refresh the hostgroup field on
every lookup; counters are not reset (only metadata is updated).
4. session_status_to_string missing X_PASSTHROUGH_FORWARD case.
`Mysqlx_Thread::session_status_to_string` enumerated every
MysqlxSession::Status except the new X_PASSTHROUGH_FORWARD,
which fell through to the "UNKNOWN" default. The new state was
added in the TLS passthrough work (commit 4d8af5a02) but the
stringifier was not updated. Add the explicit case.
All four are local fixes with no test changes required — existing
unit tests still pass under ASAN (mysqlx_session 87/87,
mysqlx_message_dispatch 114/114, mysqlx_stats 26/26,
mysqlx_thread 25/25, mysqlx_concurrent 6/6, mysqlx_admin_schema
25/25, mysqlx_backend_auth 58/58, mysqlx_tls 44/44,
mysqlx_config_store 33/33). The pre-existing
mysqlx_admin_commands_unit-t test 24 failure
("mysqlx_variables has 4 rows after save") predates this branch.
feature/mysqlx-stack-consolidated
parent
352455d79c
commit
e4908a1df6
Loading…
Reference in new issue