Skip to content

Stop Jdbi pinning virtual threads (backport 2.0 #35374, #35469, #35429) - #38520

Merged
manerow merged 3 commits into
2.0from
fix-jdbi-vt-pinning-2.0
Nov 23, 2026
Merged

manerow merged 3 commits into
2.0from
fix-jdbi-vt-pinning-2.0

Conversation

@manerow

@manerow manerow commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Cherry-pick of PR #35374 (Fixes #35373), PR #35469 and PR #35429 (Fixes #35428) to 2.0.

Collate counterpart (same Jdbi version, must merge right after this): open-metadata/openmetadata-collate#8900

What

2.0 still runs Jdbi 3.37.1. These three changes from main move it to Jdbi 3.49.5 and stop the server's virtual threads from getting stuck on a database call:

Two test files needed small edits for 2.0, and no production code differs from main:

  • LazySqlObjectFactoryTest: on 2.0, TableDAO lives in CollectionDAO, not EntityDataDAOs.
  • EntityCacheVirtualThreadTest: on 2.0, the epoch lookup is exposed to tests as writeEpochById(String, UUID).

Why

A 2-CPU production server on 2.0.9 stopped all background work during its post-upgrade reindex. Every queued async job sat there with nothing running, and some page loads hung until the pod was restarted. Its thread dump matched ADR:2026-10-13-jdbi-never-pins-virtual-threads-and-collate-runs-the-same-version exactly:

  • both virtual-thread carriers were busy;
  • 44 threads were waiting on the lock of Hikari's leak-detection scheduler;
  • their stacks held the monitor of Jdbi's MemoizingSupplier.init.

On Java 21, a virtual thread that waits inside synchronized keeps its carrier. With 2 CPUs there are only 2 carriers, so two such waits stop every virtual thread in the server. main and 2.1 have had the fix since October, but 2.0 never got it.

Verification

All run locally on this branch, on Java 21:

  • Reproduction, before and after. A standalone program with the same shape as the server (Hikari 7.0.2, 60 s leak detection, on-demand Jdbi DAOs called from virtual threads, -XX:ActiveProcessorCount=2, Postgres 16, 208 workers, 2,080 calls):
    • Jdbi 3.37.1: 25 calls succeeded, then none. Every 30 s, 10 calls failed with a connection timeout. JFR recorded 19 pinned waits in MemoizingSupplier.init by 160 s, when I stopped it.
    • Jdbi 3.49.5: all 2,080 calls succeeded in 16 s, with 0 failures and 0 pinned waits.
  • Guard tests: JdbiVirtualThreadPinningTest, LazySqlObjectFactoryTest, EntityCacheVirtualThreadTest, TestSuiteRepositoryTest and ConnectionAwareAnnotationSqlLocatorTest: 22 passed.
  • Unit tests: full openmetadata-service suite: 9,818 run, 0 failures, 0 errors, 1 skipped.
  • Integration tests with the test JVM limited to 2 CPUs (-XX:ActiveProcessorCount=2): TestCaseResourceIT, TestSuiteResourceIT, GlossaryTermMoveApprovalIT, TestSuiteReindexIT and ReindexAliasSwapIT:
    • Postgres: 558 run, 0 failures, 0 errors, 32 skipped.
    • MySQL: 558 run, 0 failures, 0 errors, 32 skipped.
  • Not run locally: the rest of the integration suite. It runs in CI on this PR.

RetriggerView in GreptileConfidence Score: 4/5

The Java guide requirements need to be satisfied before merging; the SQL test improvement is non-blocking.

Findings

  1. P2 New helpers break Java rules ▶
  2. P2 SQL tests can pass empty ▶

Summary

This PR backports the virtual-thread fixes to 2.0.

  • Database calls can wait without tying up a virtual-thread carrier.
  • DAO method handlers are built when a call first needs them.
  • Entity-cache misses load without holding the cache lock.
  • Test-suite summaries leave out cases deleted after results were listed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[DAO call] --> B[Lazy SQL object proxy]
  B --> C[Build called method's handler]
  C --> D[Jdbi opens connection without old monitor]
  E[Entity cache miss] --> F[Read write epoch]
  F --> G[Load outside cache lock]
  G --> H[Put result in cache]
  H --> I{Epoch changed?}
  I -->|No| J[Return result]
  I -->|Yes| K[Evict and read without cache]
Loading

Reviews (1) · Last reviewed commit: "Fixes #35428: Stop cache-miss loads pinn..." · Reviewed by Greptile

@manerow
manerow requested a review from a team as a code owner November 23, 2026 16:53
@manerow
manerow requested review from TeddyCr and removed request for a team November 23, 2026 16:53
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@gitar-bot

gitar-bot Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

The Jdbi upgrade, lazy handler factory, and unlocked cache-miss loads change database access paths; regressions could disrupt reads or background work.

Backports three Jdbi virtual-thread fixes to 2.0: bumps Jdbi from 3.37.1 to 3.49.5, builds SQL object handlers on first call, and moves cache-miss database reads outside the cache lock so virtual threads no longer pin carriers. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@manerow manerow added the skip-pr-checks Bypass PR metadata validation check label Nov 23, 2026
@manerow
manerow merged commit 8d3dabd into 2.0 Nov 23, 2026
82 of 85 checks passed
@manerow
manerow deleted the fix-jdbi-vt-pinning-2.0 branch November 23, 2026 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-pr-checks Bypass PR metadata validation check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants