|
| 1 | +# Admin Session Autocommit Compatibility Implementation Plan |
| 2 | + |
| 3 | +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| 4 | +
|
| 5 | +**Goal:** Let Connector/Python's `SET @@session.autocommit = ON|OFF` complete successfully on ProxySQL's classic Admin interface. |
| 6 | + |
| 7 | +**Architecture:** The Admin handler already has a connect-setup compatibility block that replies with an OK packet and no result set for bare `SET AUTOCOMMIT`. Extend that same block with the Connector/Python spelling, preserving the Admin interface's existing no-op semantics. Extend its focused TAP regression test with exact Connector/Python payloads. |
| 8 | + |
| 9 | +**Tech Stack:** C++17, ProxySQL classic Admin protocol, TAP/libmysqlclient regression test, GNU Make. |
| 10 | + |
| 11 | +## Global Constraints |
| 12 | + |
| 13 | +- Keep the scope to connection-setup compatibility; do not add Admin transaction-state support. |
| 14 | +- Match `SET @@session.autocommit` case-insensitively after leading SQL comments are stripped. |
| 15 | +- Return the existing OK/no-result-set response and do not modify `global_variables`. |
| 16 | +- Build from a clean worktree with `make clean` followed by `make` using a bounded parallelism level derived from available CPUs and memory. |
| 17 | +- Preserve normal red/green CI semantics; do not mask the Connector/Python 26.7.0 soak failure. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +### Task 1: Establish the Admin compatibility regression |
| 22 | + |
| 23 | +**Files:** |
| 24 | +- Modify: `test/tap/tests/mysql-reg_test_5786_admin_strip_leading_sql_comments-t.cpp:39-55` |
| 25 | +- Test: `test/tap/tests/mysql-reg_test_5786_admin_strip_leading_sql_comments-t.cpp` |
| 26 | + |
| 27 | +**Interfaces:** |
| 28 | +- Consumes: the existing `ACCEPT_CASES` array; each entry is sent via `mysql_query()` to the classic Admin interface. |
| 29 | +- Produces: three failing, exact Connector/Python compatibility assertions that become green only when the Admin handler sends an OK packet. |
| 30 | + |
| 31 | +- [ ] **Step 1: Add the precise failing connection-setup cases** |
| 32 | + |
| 33 | + Add these three entries immediately after the existing bare `SET AUTOCOMMIT=1` cases: |
| 34 | + |
| 35 | + ```cpp |
| 36 | + "SET @@session.autocommit = OFF", // Connector/Python pure-Python post-connect setup |
| 37 | + "SET @@session.autocommit = ON", // setter's opposite state uses the same syntax |
| 38 | + "/*connector-python*/ SET @@session.autocommit = OFF", // comment-stripping compatibility path |
| 39 | + ``` |
| 40 | + |
| 41 | +- [ ] **Step 2: Build and run the regression test before the handler change** |
| 42 | + |
| 43 | + Determine `build_jobs` as the smaller of the available CPU count and 8, then use it consistently: |
| 44 | + |
| 45 | + ```bash |
| 46 | + build_jobs=$(nproc) |
| 47 | + [ "$build_jobs" -gt 8 ] && build_jobs=8 |
| 48 | + make clean |
| 49 | + make -j"$build_jobs" |
| 50 | + make -C test/tap/tests -j"$build_jobs" mysql-reg_test_5786_admin_strip_leading_sql_comments-t |
| 51 | + ``` |
| 52 | + |
| 53 | + Run only the focused test through its normal isolated harness and clean up its |
| 54 | + uniquely named infrastructure on exit: |
| 55 | + |
| 56 | + ```bash |
| 57 | + export INFRA_ID="admin-session-autocommit-red-$(date +%s)" |
| 58 | + export TAP_GROUP=legacy-g1 |
| 59 | + export TEST_PY_TAP_INCL='mysql-reg_test_5786_admin_strip_leading_sql_comments-t' |
| 60 | + export SKIP_CLUSTER_START=1 |
| 61 | + trap 'test/infra/control/stop-proxysql-isolated.bash || true; test/infra/control/destroy-infras.bash || true' EXIT |
| 62 | + test/infra/control/ensure-infras.bash |
| 63 | + test/infra/control/run-tests-isolated.bash |
| 64 | + ``` |
| 65 | + |
| 66 | + The new cases must fail with `ERROR: Unknown global variable: |
| 67 | + '@@session.autocommit'.`; retain the failing TAP output as the red-phase |
| 68 | + evidence. |
| 69 | + |
| 70 | +- [ ] **Step 3: Commit the regression test** |
| 71 | + |
| 72 | + ```bash |
| 73 | + git add test/tap/tests/mysql-reg_test_5786_admin_strip_leading_sql_comments-t.cpp |
| 74 | + git commit -m "test: cover admin session autocommit setup" |
| 75 | + ``` |
| 76 | + |
| 77 | +### Task 2: Accept the Connector/Python session spelling as an Admin setup no-op |
| 78 | + |
| 79 | +**Files:** |
| 80 | +- Modify: `lib/Admin_Handler.cpp:4065-4088` |
| 81 | +- Test: `test/tap/tests/mysql-reg_test_5786_admin_strip_leading_sql_comments-t.cpp` |
| 82 | + |
| 83 | +**Interfaces:** |
| 84 | +- Consumes: `mb`, the comment-stripped command pointer in `admin_session_handler()`. |
| 85 | +- Produces: an OK packet through `SPA->send_ok_msg_to_client()` for `SET @@session.autocommit`, with no SQLite query or ProxySQL global-variable update. |
| 86 | + |
| 87 | +- [ ] **Step 1: Extend only the existing compatibility predicate** |
| 88 | + |
| 89 | + Add one branch next to the existing `SET AUTOCOMMIT` condition: |
| 90 | + |
| 91 | + ```cpp |
| 92 | + || |
| 93 | + (!strncasecmp("SET @@session.autocommit", mb, strlen("SET @@session.autocommit"))) |
| 94 | + ``` |
| 95 | + |
| 96 | + Do not change `admin_handler_command_set()`: the command must be consumed before it reaches the global-variable translator. |
| 97 | + |
| 98 | +- [ ] **Step 2: Rebuild cleanly and verify the focused TAP test is green** |
| 99 | + |
| 100 | + ```bash |
| 101 | + build_jobs=$(nproc) |
| 102 | + [ "$build_jobs" -gt 8 ] && build_jobs=8 |
| 103 | + make clean |
| 104 | + make -j"$build_jobs" |
| 105 | + make -C test/tap/tests -j"$build_jobs" mysql-reg_test_5786_admin_strip_leading_sql_comments-t |
| 106 | + ``` |
| 107 | + |
| 108 | + Run the focused group using the same exact isolated-harness command as the |
| 109 | + red phase, with a new `INFRA_ID` ending in `-green`. Confirm all old and new |
| 110 | + accept cases receive an OK packet with no result set, then run: |
| 111 | + |
| 112 | + ```bash |
| 113 | + git diff --check |
| 114 | + ``` |
| 115 | + |
| 116 | +- [ ] **Step 3: Commit the minimal handler fix** |
| 117 | + |
| 118 | + ```bash |
| 119 | + git add lib/Admin_Handler.cpp test/tap/tests/mysql-reg_test_5786_admin_strip_leading_sql_comments-t.cpp |
| 120 | + git commit -m "fix(admin): accept session autocommit setup" |
| 121 | + ``` |
| 122 | + |
| 123 | +### Task 3: Verify the real Connector/Python 26.7.0 path and publish |
| 124 | + |
| 125 | +**Files:** |
| 126 | +- Modify: no additional source files |
| 127 | +- Test: `test/scripts/mysqlx/behavioral_validation.py` through the existing `mysqlx-soak-g1` harness |
| 128 | + |
| 129 | +**Interfaces:** |
| 130 | +- Consumes: the image built with `MYSQL_CONNECTOR_PYTHON_VERSION=26.7.0` and the existing behavioral-validation Admin connection. |
| 131 | +- Produces: evidence that the connector reaches its Admin delete/reload actions rather than failing during post-connect setup. |
| 132 | + |
| 133 | +- [ ] **Step 1: Build the test image with the compatibility connector version** |
| 134 | + |
| 135 | + ```bash |
| 136 | + docker build --network host \ |
| 137 | + --build-arg MYSQL_CONNECTOR_PYTHON_VERSION=26.7.0 \ |
| 138 | + -t proxysql-ci-base:mysqlx-connector-26.7.0 \ |
| 139 | + -f test/infra/docker-base/Dockerfile test/infra/docker-base |
| 140 | + ``` |
| 141 | + |
| 142 | +- [ ] **Step 2: Run the existing MySQLX soak harness against that image** |
| 143 | + |
| 144 | + The isolation scripts consume `proxysql-ci-base:latest`, so temporarily |
| 145 | + point that local compatibility alias at the versioned image, run only the |
| 146 | + behavioral test, and restore the 9.7.0 alias afterwards: |
| 147 | + |
| 148 | + ```bash |
| 149 | + docker tag proxysql-ci-base:mysqlx-connector-26.7.0 proxysql-ci-base:latest |
| 150 | + export INFRA_ID="admin-session-autocommit-mysqlx-$(date +%s)" |
| 151 | + export TAP_GROUP=mysqlx-soak-g1 |
| 152 | + export TEST_PY_TAP_INCL='test_mysqlx_soak_behavioral-t' |
| 153 | + export SKIP_CLUSTER_START=1 |
| 154 | + trap 'test/infra/control/stop-proxysql-isolated.bash || true; test/infra/control/destroy-infras.bash || true; docker tag proxysql-ci-base:mysqlx-connector-9.7.0 proxysql-ci-base:latest' EXIT |
| 155 | + test/infra/control/ensure-infras.bash |
| 156 | + test/infra/control/run-tests-isolated.bash |
| 157 | + ``` |
| 158 | + |
| 159 | + Verify that `mysql.connector.connect()` reaches the Admin delete/reload |
| 160 | + actions instead of emitting `Unknown global variable: |
| 161 | + '@@session.autocommit'`; assess any subsequent route-reload result |
| 162 | + separately. |
| 163 | + |
| 164 | +- [ ] **Step 3: Publish the focused branch as a pull request** |
| 165 | + |
| 166 | + Rebase or merge the current `origin/v3.0` only if it has advanced, run `git diff --check`, push `fix/admin-session-autocommit`, and open a PR targeting `v3.0`. The PR description must state the pure-Python Connector/Python fallback mechanism, the Admin no-op behavior, focused TAP evidence, and that #5984 must land before CI can exercise the 26.7.0 soak matrix. |
0 commit comments