Skip to content

Fix flaky UseReaderWithoutDisposing test on high-latency servers - #26

Open
pmishchenko-ua wants to merge 1 commit into
masterfrom
cursor/fix-usereaderwithoutdisposing-flake-3310
Open

Fix flaky UseReaderWithoutDisposing test on high-latency servers#26
pmishchenko-ua wants to merge 1 commit into
masterfrom
cursor/fix-usereaderwithoutdisposing-flake-3310

Conversation

@pmishchenko-ua

Copy link
Copy Markdown
Collaborator

Problem

CI run 33603340491 (PR #24) failed in test-windowsRun SideBySide tests:

Failed SideBySide.QueryTests.UseReaderWithoutDisposing [44 s]
  SingleStoreConnector.SingleStoreException : Connect Timeout expired. All pooled connections are in use.

PR #24 only edits RELEASE.md, so this is unrelated to the PR — it's a pre-existing, latency-sensitive flake. It failed only on the Windows job, which runs against the remote S2MS managed cluster (aws-oregon), while every local-cluster Linux job passed.

Root cause

UseReaderWithoutDisposing starts MaximumPoolSize + 4 (12) threads against a pool of 8 and deliberately leaves each DbDataReader undisposed. Disposing a connection whose reader still has unread rows requires a session reset (network round-trips) before the connection can be reused. Against a high-latency managed server those resets are slow enough that the 4 excess threads can exceed the default 15s pool-wait timeout (ConnectionTimeout) and throw Connect Timeout expired. All pooled connections are in use. (SingleStoreConnection.cs). Loopback-latency local clusters never hit this.

Note the repo already scales timing-sensitive tests via AppConfig.TimeoutDelayFactor, but that only recognizes AppVeyor/Travis/TF_Build/CircleCI — not GitHub Actions — so timeouts aren't scaled on the GitHub Windows runner. Broadening IsCiBuild would have side effects (it also disables ServerFeatures.Timeout tests), so this change is scoped to the one affected test.

Fix

Give the test a generous pool-wait ConnectionTimeout (60s) so it still exercises pool reuse under contention without being sensitive to connection latency.

Verification

Reproduced and verified locally against MariaDB reached through a TCP proxy that injects 50 ms/chunk/direction latency (simulating the remote cluster's RTT). With latency and load held fixed, only ConnectionTimeout was varied:

Scenario ConnectionTimeout Result
Reproduction (through latency proxy) 2s FAILConnect Timeout expired. All pooled connections are in use. (44s, identical to CI)
Fix (through latency proxy) 60s PASS (1m7s)
Sanity (direct DB, no proxy) 60s PASS (53ms)

The reproduction produced the exact same exception and duration as the failing CI job, isolating the pool-wait timeout as the cause.

Open in Web Open in Cursor 

The test starts MaximumPoolSize + 4 threads and leaves readers undisposed,
so returning each connection to the pool requires a session reset. Against a
high-latency managed server (the remote S2MS cluster used by the Windows CI
job) those resets are slow enough that the excess threads exceed the default
15s pool-wait timeout and fail with 'Connect Timeout expired. All pooled
connections are in use.'

Set a generous ConnectionTimeout so the test still exercises pool reuse
without being sensitive to connection latency.

Co-authored-by: Pavlo Mishchenko <pmishchenko-ua@users.noreply.github.com>
@pmishchenko-ua
pmishchenko-ua marked this pull request as ready for review September 2, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants