Skip to content

oracledb_cdc: add default connection read timeout - #4898

Merged
josephwoodward merged 16 commits into
mainfrom
jw/oracledb_cdc_read_timeout
Nov 25, 2026
Merged

josephwoodward merged 16 commits into
mainfrom
jw/oracledb_cdc_read_timeout

Conversation

@josephwoodward

@josephwoodward josephwoodward commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

This change adds a socket_timeout configuration setting (in seconds as that's what Oracle supports) to the Oracle connector that's passed to the go-ora driver via the connection string (ie oracle://c%23%23testdb:testdb123@localhost:1521/FREE?TIMEOUT=300) so a read from an Oracle database that stops responding fails and the input reconnects instead of waiting for a response.

If the connection string already contains the TIMEOUT flag then that takes precedence.

The default is 300 seconds (5m) and 0 turns it off (which is the current default before this change).

Proof of Work

Using Toxiproxy to leave the TCP connection up but block read traffic to the connector shows it timeouts, eventually disconnecting. Once the toxic is removed then it reconnects and continues streaming.

image

@josephwoodward
josephwoodward force-pushed the jw/oracledb_cdc_read_timeout branch 2 times, most recently from 6f6824a to 0cf8bb9 Compare November 13, 2026 12:16
@josephwoodward
josephwoodward force-pushed the jw/oracledb_cdc_read_timeout branch from a2a940c to d988a16 Compare November 13, 2026 13:16
Large transactions and driver fetch size: left to itself, the Oracle driver sizes each fetch to roughly 128 KiB based on the declared maximum width of the selected columns. As a result, wide columns such as LogMiner's redo SQL yield only a handful of rows per network round trip. This can make large committed transactions appear minutes late while the database, network and connector all look idle. Each round trip costs a full network exchange, and a large transaction requires thousands of them. The connector therefore fetches ` + "`" + ociFieldPrefetchRows + "`" + ` rows per round trip (500 by default). Raise it for large transactions over high-latency links. A ` + "`PREFETCH_ROWS`" + ` query parameter in ` + "`" + ociFieldConnectionString + "`" + ` takes precedence over the field.
Unresponsive databases: if the database stops responding without closing the connection, a query can wait indefinitely while the input still reports as connected. The connector therefore limits each network read from and write to the database to ` + "`" + ociFieldSocketTimeout + "`" + ` seconds. When it's exceeded, the query fails, and the input reconnects and resumes from its last checkpoint. Recovery can take a few multiples of ` + "`" + ociFieldSocketTimeout + "`" + `, because shutting down the stalled session and each failed reconnect attempt also wait for it. The limit applies to every individual read and write on every connection the input opens, including snapshot queries. It is not a limit on a whole query, because it restarts with each read or write. It must exceed the longest time Oracle takes to return the first rows of any query. A ` + "`TIMEOUT`" + `, ` + "`READ TIMEOUT`" + ` or ` + "`SOCKET TIMEOUT`" + ` query parameter in ` + "`" + ociFieldConnectionString + "`" + `, matched case-insensitively, takes precedence over the field.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new "Unresponsive databases" paragraph says recovery waits on "shutting down the stalled session," but this same PR adds closeDBInBackground (lines 1031-1038) specifically so the discarded pool closes without blocking reconnection — its own comment says "closes a discarded pool without blocking the reconnect." The claim contradicts the code it documents; per the writing standard, a description must state current behavior only.

Unresponsive databases: if the database stops responding without closing the connection, a query can wait indefinitely while the input still reports as connected. The connector therefore limits each network read from and write to the database to ` + "`" + ociFieldSocketTimeout + "`" + ` seconds. When it's exceeded, the query fails, and the input reconnects and resumes from its last checkpoint. Recovery can take a few multiples of ` + "`" + ociFieldSocketTimeout + "`" + `, because each reconnect attempt can itself take that long before it succeeds or fails. The limit applies to every individual read and write on every connection the input opens, including snapshot queries. It is not a limit on a whole query, because it restarts with each read or write. It must exceed the longest time Oracle takes to return the first rows of any query. A ` + "`TIMEOUT`" + `, ` + "`READ TIMEOUT`" + ` or ` + "`SOCKET TIMEOUT`" + ` query parameter in ` + "`" + ociFieldConnectionString + "`" + `, matched case-insensitively, takes precedence over the field.

doc-strings-review:fp=574b143f02f1a4f4

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This level of technical detail feels unnecessary for the documentation. I'm leaning more towards leaving it as "general connection shutdown" behaviour.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Connect docs check

The docs build passed with this PR's generated docs.

Preview: https://connect-pr-4898--redpanda-connect.netlify.app/connect/home/

This PR changes 1 published page (5 generated files: 5 changed, 0 added, 0 removed). Review the rendered pages, not only the Go strings.

Page Preview
/connect/components/inputs/oracledb_cdc/ preview

Per-file diffs and the rendered-HTML findings are in the job summary. Checked at 9eb7c39.

@vbotbuildovich
vbotbuildovich requested a review from a team November 13, 2026 14:11
Comment thread internal/impl/oracledb/logminer/conn.go Resolved
@josephwoodward
josephwoodward force-pushed the jw/oracledb_cdc_read_timeout branch from 2fad6af to 12b7d57 Compare November 24, 2026 21:14
- Rebuild the internal checkpoint cache on reconnect alongside the main
  pool. go-ora does not mark a connection bad on a read timeout, so a
  pooled cache connection could read a late reply to a timed-out query
  as its own.
- Log a hint naming socket_timeout when snapshotting, streaming or
  connecting fails with a socket timeout, since the driver only reports
  "i/o timeout".
- Move the socket timeout check to the replication package and test it
  against go-ora with a listener that never replies.
- Parse connection_string with redact.ParseURL, matching main.
- Mark socket_timeout as added in 4.120.0.
@josephwoodward
josephwoodward force-pushed the jw/oracledb_cdc_read_timeout branch from 12b7d57 to b67132a Compare November 24, 2026 21:23
Comment thread internal/impl/oracledb/logminer/conn.go Resolved
@josephwoodward
josephwoodward merged commit baaf221 into main Nov 25, 2026
16 checks passed
@josephwoodward
josephwoodward deleted the jw/oracledb_cdc_read_timeout branch November 25, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants