Repository navigation
Stop Jdbi pinning virtual threads (backport 2.0 #35374, #35469, #35429) - #38520
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
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 |
Code Review ✅ Approved 🟡 Medium riskThe 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 VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
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.0still runs Jdbi 3.37.1. These three changes frommainmove it to Jdbi 3.49.5 and stop the server's virtual threads from getting stuck on a database call:synchronizedblock), registers the connection-aware SQL annotations through@UseExtensionHandler, and addsJdbiVirtualThreadPinningTest. It also carries the test suite summary fix from that PR.Two test files needed small edits for
2.0, and no production code differs frommain:LazySqlObjectFactoryTest: on2.0,TableDAOlives inCollectionDAO, notEntityDataDAOs.EntityCacheVirtualThreadTest: on2.0, the epoch lookup is exposed to tests aswriteEpochById(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:
MemoizingSupplier.init.On Java 21, a virtual thread that waits inside
synchronizedkeeps its carrier. With 2 CPUs there are only 2 carriers, so two such waits stop every virtual thread in the server.mainand2.1have had the fix since October, but2.0never got it.Verification
All run locally on this branch, on Java 21:
-XX:ActiveProcessorCount=2, Postgres 16, 208 workers, 2,080 calls):MemoizingSupplier.initby 160 s, when I stopped it.JdbiVirtualThreadPinningTest,LazySqlObjectFactoryTest,EntityCacheVirtualThreadTest,TestSuiteRepositoryTestandConnectionAwareAnnotationSqlLocatorTest: 22 passed.openmetadata-servicesuite: 9,818 run, 0 failures, 0 errors, 1 skipped.-XX:ActiveProcessorCount=2):TestCaseResourceIT,TestSuiteResourceIT,GlossaryTermMoveApprovalIT,TestSuiteReindexITandReindexAliasSwapIT:The Java guide requirements need to be satisfied before merging; the SQL test improvement is non-blocking.
Findings
Summary
This PR backports the virtual-thread fixes to
2.0.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]Reviews (1) · Last reviewed commit: "Fixes #35428: Stop cache-miss loads pinn..." · Reviewed by Greptile