laughingman7743 opened a new pull request, #200:
URL: https://github.com/apache/flink-connector-jdbc/pull/200

   ## What is the purpose of the change
   
   Fix the flaky `DerbyDynamicTableSourceITCase.testLimit` (and occasionally 
`testProject`). When a bounded query (e.g. `LIMIT`) finishes the job early, the 
source is cancelled while the split fetcher is still opening the next split; the
   JDBC connection validated by the provider is torn down before the statement 
is prepared/executed, so Derby raises `08003: No current connection` and the 
fatal `SQLException` fails the whole job (the test runs under
   `NoRestartBackoffTimeStrategy`). See 
[FLINK-39975](https://issues.apache.org/jira/browse/FLINK-39975) for the full 
analysis.
   
   ## Brief change log
   
   - `JdbcSourceSplitReader` now opens a split via 
`openResultSetForSplitWithReconnect`, a bounded retry (`MAX_CONNECTION_RETRIES 
= 3`).
   - It retries only when the connection is actually closed 
(`connection.isClosed()`); before retrying it drops the dead connection and the 
stale statement/result set and re-establishes via the provider. A query error 
on a healthy
   connection is rethrown immediately, and an unreachable database still fails 
after the retry budget — real errors are not masked.
   - `wakeUp()` / `fetch()` are unchanged.
   
   ## Verifying this change
   
   - Added 
`JdbcSourceSplitReaderTest#testFetchReconnectsWhenConnectionClosedWhileOpeningSplit`,
 a deterministic regression test that injects an already-closed connection, 
reproducing the exact `08003` error (it fails without this
   change) and asserting the reader re-establishes the connection and reads the 
whole split.
   - Added `testFetchRethrowsImmediatelyWhenConnectionStaysOpen` (a query error 
on a healthy connection is rethrown without reconnect) and 
`testFetchFailsAfterExhaustingReconnectRetries` (gives up after the retry 
budget instead of
   looping forever).
   - `DerbyDynamicTableSourceITCase` passes repeated runs.
   
   ## Does this pull request potentially affect one of the following parts:
   
   - Dependencies (does it add or upgrade a dependency): no
   - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
   - The serializers: no
   - The runtime per-record code paths (performance sensitive): no — the retry 
only triggers on a closed-connection error while opening a split
   - Anything that affects deployment or recovery: no
   - The S3 file system connector: no
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no
   - If yes, how is the feature documented? not applicable


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to