pg.ddx.io aws/aws-advanced-jdbc-wrapper GitHub issues and pull requestshelp / color / mirror / Atom feed
[aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state 16+ messages / 3 participants [nested] [flat]
* [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-02 23:51 "karenc-bq (@karenc-bq)" <noreply+karenc-bq@github.com> 0 siblings, 0 replies; 16+ messages in thread From: karenc-bq (@karenc-bq) @ 2026-11-02 23:51 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> ### Summary - Ask the target driver for the current transaction state (pgjdbc `TransactionState`, Connector/J `SERVER_STATUS_IN_TRANS`, MariaDB Connector/J `ServerStatus.IN_TRANSACTION`), read from state the driver already holds, no round trip. Fall back to the state tracked from SQL statements and JDBC calls only when the driver cannot say (no dialect support, or the connection is closed). - When the driver reports state, the SQL is no longer analyzed to infer transaction boundaries. Instead the driver's answer is recorded after every completed call, so that once the connection breaks and the driver stops reporting, failover still sees the state as of the last completed statement. `SET AUTOCOMMIT` statements are still recognized, via a cheap pre-check before the full analysis, so the driver's autocommit view stays in step. The analysis and tracking are unchanged for a dialect that reports nothing. - The driver flag is read through internal connection pool proxies too (HikariCP and c3p0 delegate `isWrapperFor`/`unwrap`). A closed or returned-to-pool handle reports nothing. - Each statement is analyzed at most once per call and the result reused. ### Behavior change With `autocommit=false` on MySQL, a statement that touches no transactional table (`SELECT 1`, `SELECT @@aurora_server_id`) does not start a server-side transaction, and the driver now reports none. The old SQL heuristic treated any statement under `autocommit=false` as opening one. In that narrow case failover now raises `FailoverSuccessSQLException` rather than `TransactionStateUnknownSQLException`, and `setReadOnly` is allowed to switch. PostgreSQL is unaffected (pgjdbc opens a transaction on any statement). The affected integration tests were rewritten to open a real transaction. ### Tests - `TransactionStateTests` (integration): the flag each of the three drivers reports for autocommit on/off, commit/rollback, explicit BEGIN/COMMIT, PG aborted transactions, closed connections and the internal-pool proxy; plus the tracked-state fallback, forced through the generic dialect. - `DefaultConnectionPluginTest`: every tracked transition on the fallback path; the driver state is recorded and survives a connection break; `SET AUTOCOMMIT` still synced. - `SqlMethodAnalyzerTest`: the pre-check never misses a `SET AUTOCOMMIT`. - `PluginServiceImplTests`: driver state wins over tracked state, null falls back, no connection returns null. - `ReadWriteSplittingTests`: the two in-transaction tests now open a transaction on a real table. ### By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-03 00:21 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-03 00:21 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> (on wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MysqlConnectorJDriverHelper.java:170) Will it work in case of internal connection pool? ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-03 00:22 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-03 00:22 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> (on wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/PgDriverHelper.java:147) similar concern here ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-03 00:24 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-03 00:24 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> Can we have some integration tests to verify flags provided by target drivers? ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-04 16:25 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-04 16:25 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> @sergiyvamz applied label "wip". ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-12 16:52 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-12 16:52 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> @sergiyvamz removed label "wip". ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-12 16:53 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-12 16:53 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> (on wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MysqlConnectorJDriverHelper.java:172) Yes. Both HikariCP's `ProxyConnection` and c3p0's proxy delegate `isWrapperFor`/`unwrap` to the inner driver connection, so the dialect reads the driver's own flag through the pool handle. One gap this turned up: Connector/J's `isWrapperFor` does not reject a closed connection (pgjdbc's does), so a closed or returned-to-pool handle could report stale state. Both helpers now check `isClosed()` first. `TransactionStateTests.test_internalConnectionPool_proxyPassesDriverStateThrough` covers the pooled path end to end. ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-12 16:53 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-12 16:53 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> (on wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/PgDriverHelper.java:149) Yes. Both HikariCP's `ProxyConnection` and c3p0's proxy delegate `isWrapperFor`/`unwrap` to the inner driver connection, so the dialect reads the driver's own flag through the pool handle. One gap this turned up: Connector/J's `isWrapperFor` does not reject a closed connection (pgjdbc's does), so a closed or returned-to-pool handle could report stale state. Both helpers now check `isClosed()` first. `TransactionStateTests.test_internalConnectionPool_proxyPassesDriverStateThrough` covers the pooled path end to end. ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-12 16:53 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-12 16:53 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> Added `TransactionStateTests`: it runs against all three drivers and checks what pgjdbc / Connector/J report for autocommit, commit/rollback, explicit BEGIN/COMMIT, PG's aborted-transaction state, closed connections, and the internal-pool proxy. For MariaDB it checks the wrapper falls back to its own tracking. ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-12 17:53 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-12 17:53 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> Follow-up in 444348b4: the MariaDB driver exposes the same flag (`ServerStatus.IN_TRANSACTION` on the connection context), so `MariadbTargetDriverDialect` reports it now too. With that, `DefaultConnectionPlugin` skips the SQL analysis for transaction boundaries whenever the dialect reports state for the current connection; it only still looks for `SET AUTOCOMMIT` so the driver's autocommit view stays in step. The tracked-state fallback is unchanged and is now exercised by forcing the generic dialect in `TransactionStateTests`, and per transition in `DefaultConnectionPluginTest`. ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-16 18:03 "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sophia-bq (@sophia-bq) @ 2026-11-16 18:03 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> (on benchmarks/src/jmh/java/software/amazon/jdbc/benchmarks/PluginServiceBenchmarks.java:255) I would be somewhat curious to know what performance impact this change has when the driver does report transaction state - have we run any comparisons? ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215 (approved): fix: check target driver for current transaction state @ 2026-11-16 18:03 "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sophia-bq (@sophia-bq) @ 2026-11-16 18:03 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-16 18:24 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-16 18:24 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> (on benchmarks/src/jmh/java/software/amazon/jdbc/benchmarks/PluginServiceBenchmarks.java:255) I assume that these changes improve overall driver performance. All 3 major driver provides transaction flag out-of-the-box without additional SQL parsing or extra network call. Boxing/unboxing of Boolean definitely takes some extra time but it's negligible comparing to SQL parsing. But we did not run any comparison. ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-16 18:38 "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sophia-bq (@sophia-bq) @ 2026-11-16 18:38 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> (on benchmarks/src/jmh/java/software/amazon/jdbc/benchmarks/PluginServiceBenchmarks.java:255) Sounds good! I would've just been curious to see the improvement but it is certainly not necessary :) ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-17 17:23 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-17 17:23 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> @sergiyvamz closed this. ^ permalink raw [nested|flat] 16+ messages in thread
* Re: [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state @ 2026-11-17 17:23 "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 14 siblings, 0 replies; 16+ messages in thread From: sergiyvamz (@sergiyvamz) @ 2026-11-17 17:23 UTC (permalink / raw) To: aws/aws-advanced-jdbc-wrapper <noreply+aws-aws-advanced-jdbc-wrapper@github.com> @sergiyvamz merged this (commit 8b505879b074). ^ permalink raw [nested|flat] 16+ messages in thread
end of thread, other threads:[~2026-11-17 17:23 UTC | newest] Thread overview: 16+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-02 23:51 [aws/aws-advanced-jdbc-wrapper] PR #2215: fix: check target driver for current transaction state "karenc-bq (@karenc-bq)" <noreply+karenc-bq@github.com> 2026-11-03 00:21 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-03 00:22 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-03 00:24 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-04 16:25 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-12 16:52 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-12 16:53 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-12 16:53 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-12 16:53 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-12 17:53 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-16 18:03 ` "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com> 2026-11-16 18:03 ` Re: [aws/aws-advanced-jdbc-wrapper] PR #2215 (approved): fix: check target driver for current transaction state "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com> 2026-11-16 18:24 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-16 18:38 ` "sophia-bq (@sophia-bq)" <noreply+sophia-bq@github.com> 2026-11-17 17:23 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com> 2026-11-17 17:23 ` "sergiyvamz (@sergiyvamz)" <noreply+sergiyvamz@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox