← Back to Pull requests

[BACKPORT 2026.1][#34371,#34668] DocDB: Fail yb_thin_client connections over to another tserver when theirs stops answering (#34374, #34684) #34678

Closed
unknown closed this pull request without merging on Oct 06, 2026 13:08 UTC
View on GitHub
unknown unknown commented on Oct 06, 2026 02:28 UTC
Author

Summary

yb_thin_client pinned each connection to one tserver: connection i used
address i, and a session dropped on a network error was reopened on the same
tserver. A pool that fits on one connection, such as 1 read + 1 write session,
sent everything to the first address. When that tserver stopped answering,
every retry went back to it, and writes stalled until it returned, even though
the rest of the cluster held quorum. Client creation also failed if any
session's tserver was unreachable, so recreating the client could not escape
either.

  • Each connection keeps a proxy per configured tserver and the index of the

  • one it uses. Each session records the tserver it was opened on, since
    session ids are local to a tserver.
  • A broken connection on any RPC, or a timed-out Heartbeat (which the tserver

  • answers alone), moves the connection to the next tserver. A Perform or
    OpenTable timeout does not: the tserver may be alive and waiting on a tablet
    leader or the master.
  • A session left on a tserver its connection has moved off is reopened before

  • its next use. A paged scan pinned to it gets YBTHIN_READ_RESTART without a
    reopen.
  • ybthin_client_create tries each tserver in turn after any error, and

  • ybthin_table_open after any failed RPC. At create, the connection follows
    the tserver its session opened on. On the call path a reopen still tries
    one tserver, so it takes at most one RPC timeout; a caller also waits out
    any reopen of its session already in progress.
  • A late failure no longer drops a session that was reopened after the failed

  • call went out.
  • The keepalive pings outside the session mutex, reopens dropped or stranded

  • sessions (after one failed reopen, a connection's other sessions wait for
    the next round), and checks for shutdown between sessions.

    No new flags, and no defaults change. With a single configured address,
    nothing moves.

    Test fix from #34684

    Also includes #34684, which fixes a race in the failover tests:
    PagedScanAcrossAFrozenTserver failed 2 of 20 times on ASAN.
    ExternalDaemon::Pause() sends SIGSTOP and returns before the tserver's
    threads have stopped, so a tserver the test meant to freeze could still
    answer the next RPC. A Freeze() helper now pauses the tserver and waits,
    via waitid(WSTOPPED | WNOHANG | WNOWAIT), until the whole process has
    stopped. All three failover tests use it. Test-only change.

    Backport notes

    Two clean cherry-picks, in separate commits.

  • #34374: the five changed files were identical on 2026.1 and on master

  • before the original commit, so the patch is the same as the original.
  • #34684: cherry-picked from its head commit, listed below. #34684 is not

  • merged to master yet.
    The test file matches #34684's version exactly. If
    #34684 changes before it merges, this backport needs the same change.

    Original commits:

  • 88bb500829f5f01854232a82696933b9c64e692e / #34374

  • 458cfa0c4b90c39a26f2cf34e8c051f2854fbbc8 / #34684
  • Upgrade/Rollback safety

    Client-side only: no wire-format, RPC, or C ABI change. The tserver needs no change.

    Test plan

  • ./build-support/lint.sh --rev origin/2026.1: 0 errors, 0 warnings.

  • CI: yb_thin_client-itest, including the failover tests added by the

  • original change:
    - PgThinClientFailoverTest.OneConnectionPoolMovesOffAStoppedTserver
    - PgThinClientFailoverTest.CreateSkipsAnUnreachableTserver
    - PgThinClientExternalFailoverTest.WritesMoveOffAFrozenTserver
    - PgThinClientExternalFailoverTest.PagedScanAcrossAFrozenTserver and
    PageInFlightWhenItsTserverDies, which #34684 deflakes

    <!-- Reviewable:start -->

  • - -

  • This change is <img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>
    <!-- Reviewable:end -->

    Diff: 477 lines (+357 / -120) across 5 files Reviewer: arpang Review duration: 639m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.46) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 477 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.369
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #34678"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.8% (MEDIUM) · Higher = larger blast radius
    45.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.8% · Safe to merge
    19.8%