mirror of https://github.com/sysown/proxysql
sync_disk_to_memory() and copy_to_runtime() in mysqlx_plugin.cpp now check
every admindb.execute() return value. On BEGIN / DELETE / INSERT / COMMIT
failure the code issues a best-effort ROLLBACK, logs via
services->log_message, and skips the current table. Both functions return
false if any table's transaction failed, true if every replace succeeded.
coderabbitai flagged this on #5642, #5643, and #5644 (outside-diff because
the file appears in each PR's surrounding context). Without the return
checks, a failed INSERT landing between a successful DELETE and the
unconditional COMMIT silently wiped routes / users / endpoints /
backend_endpoints — the transaction wrap advertised atomicity it did not
deliver. The fix restores that guarantee.
The shared BEGIN/DELETE/INSERT/COMMIT body is now a local helper
replace_table_atomically() that takes a ProxySQL_PluginServices* so it
can log via the existing plugin log_message callback; the two callers
reduce to four-line loops over their table lists. mysqlx_start passes
ctx.services through; its return values remain advisory (log-and-continue
on a false return), intentionally — plugins shouldn't block proxysql
startup on one table's sync failure. Upgrading to fail-fast is a future
decision.
Testing: added test_insert_failure_rolls_back in
test/tap/tests/unit/mysqlx_robustness_unit-t.cpp. It seeds a dst table
with a CHECK (id %% 2 = 0) constraint plus pre-existing rows, points src
at odd ids, runs the atomic replace, and asserts (a) the function
returns false, (b) dst still holds its original rows, (c) the row sum
matches the pre-transaction state. plan(35) -> plan(39). All 39
assertions pass.
Out of scope: the Makefile link-line fix from 82fe27f4b still applies;
no further ripple.
fix/mysqlx-stale-row-sync
parent
82fe27f4b0
commit
7e2f7828ae
Loading…
Reference in new issue