Repository navigation
[SpannerToSourceDb] Fix JdbcDao connection leak and add rollback on error - #4662
Closed
aasthabharill wants to merge 1 commit into
Closed
aasthabharill wants to merge 1 commit into
aasthabharill wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4662 +/- ##
============================================
+ Coverage 59.72% 66.39% +6.67%
+ Complexity 8218 3268 -4950
============================================
Files 1122 551 -571
Lines 72762 32602 -40160
Branches 8855 3772 -5083
============================================
- Hits 43454 21647 -21807
+ Misses 26405 9883 -16522
+ Partials 2903 1072 -1831
🚀 New features to boost your workflow:
|
aasthabharill
force-pushed
the
pg-ps-1-jdbc-dao
branch
from
December 1, 2026 12:18
d2d5a6b to
3c037b1
Compare
This was referenced Dec 1, 2026
Member
Author
|
Closing as superseded by merged PR #4644, which already fixed the JdbcDao.write() connection leak when statement.close() throws. The non-overlapping rollback() and JdbcDaoTest changes are dropped to keep this migration strictly scoped to PostgreSQL prepared statements. Remaining PostgreSQL changes continue in #4664 (and #4665 for expanded IT coverage). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part 1 of 7 for migrating
v2/spanner-to-sourcedbJDBC reverse-replication writers from string-concatenated SQL to parameterizedPreparedStatementexecution (split out of combined prototype #4655).This PR is self-contained and safe to merge on its own: it fixes a real connection-leak bug in
JdbcDao.write, adds explicit transaction rollback on failure across all JDBC dialects, and removes static connection-pool mutation fromJdbcDaoTest.Implementation & Why
JdbcDao(dbutils/dao/source/JdbcDao.java):ConnectionandStatement/PreparedStatementto try-with-resources with explicitconnObj.rollback()onException(attaching rollback errors as suppressed exceptions).statement.close()threw on a broken socket or after a failed transactional check, the pooledConnectionleaked without being closed or rolled back. Narrowing the catch toExceptionavoids attempting network rollbacks on JVMErrors.bindParameterwhile keeping existing untyped Oracle LOB (setBlob/setObject) and plainStatementbehavior identical for all dialects.JdbcDaoTest.java):JdbcDaoTestto mockIConnectionHelperinstead of mutating staticJdbcConnectionHelper.connectionPoolMap.setAutoCommit(false)->executeUpdate->TransactionalCheck->commitordering, Oraclebyte[]blob stream verification, rollback on failure (PreparedStatement, rawStatement,commit,TransactionalCheck), post-commitclose()error handling, and suppressed exception preservation.Verification
mvn -pl v2/spanner-common,v2/spanner-custom-shard,v2/spanner-to-sourcedb test spotless:check(Checkstyle, Spotless, and unit tests passed).JdbcDaowith zero regressions.Series Context
JdbcDaoconnection-leak/rollback fix +JdbcDaoTestcleanup.PreparedStatementValueand wires typedPreparedStatementbinding intoJdbcDao.bindParameter.bytesToHexand Spanner value/non-finite helpers toDMLGeneratorUtils.DMLGeneratorUtilsonto a shared generic column walker, fixing the legacy null custom-transformation NPE across MySQL, Oracle, and SQL Server.ColumnBindingandDMLGeneratorUtils.getColumnBindings/getPkColumnBindings.PostgreSQLDMLGeneratorontoPreparedStatementbinding + unit tests + docs.SpannerToPostgreSQLDataTypesITacross 11 non-bigint PK types, enums, non-finite floats, and generated-PK CRUD.