← Back to Pull requests

fix(java): preserve shared sessions when opening namespace datasets #10239

Merged
jischeng merged 2 files (31 lines) on Oct 23, 2026 02:26 UTC
View on GitHub
jischeng jischeng commented on Oct 22, 2026 12:20 UTC
Author

Problem

OpenDatasetBuilder.buildFromNamespaceClient() rebuilds ReadOptions when applying namespace-resolved storage options, but drops the caller's optional Session. Each dataset open then creates an independent session, preventing metadata and index cache reuse across opens. Direct URI opens preserve the supplied session.

This affects callers such as Spark readers that supply a shared session through ReadOptions and repeatedly open datasets through a namespace.

Fix and regression coverage

Copy the optional session into the rebuilt options. The existing session-selection logic still gives an explicit builder session precedence, and caller-provided sessions remain owned by the caller.

Add one focused DirectoryNamespaceTest case that opens a small table twice using a session supplied through ReadOptions, verifies session identity and metadata-cache reuse, and checks that closing the dataset leaves the caller's session open.

Supporting observations

In a local probe with a temporary BTREE dataset, three repeated opens at a fixed version and filter returned identical results. Index loads changed from 1/1/1 before the fix to 1/0/0 after the fix, matching direct URI opens.

In one production Spark replay of an indexed query over approximately 2,400 fragments, both variants used the same catalog SQL, pinned data versions, resource policy, and 64 executors. Query duration decreased from approximately 1,359 seconds to 85 seconds, and index-partition loads decreased from 38,784 to 1,024. Results matched and both runs completed without failed tasks. The fixed variant ran first.

These are single-run observations, not a general performance guarantee. A separate workload without an index predicate showed no improvement. Reported byte/request counters did not establish a reduction in network I/O, and S3 performance was not benchmarked.

Validation

Validated locally with JDK 17 and the repository-pinned Rust toolchain:

  • ./mvnw -Dskip.build.jni=true spotless:check — passed.

  • ./mvnw -Dskip.build.jni=true test-compile — passed.

  • ./mvnw -Dskip.build.jni=true '-Dtest=SessionTest,DirectoryNamespaceTest#testRepeatedOpensShareReadOptionsSession' test — passed after simplifying the regression test: 23 Java tests, using JNI previously built from this checkout.

  • The initial JNI source build also passed 27 JNI Rust unit tests.

  • Before simplification, a negative control removing only the session-copy line made the shared-session regression fail; restoring the line passed.
  • Related work

    Related to #6536, which proposed the same fix with a regression test and was closed due to inactivity.

    Diff: 31 lines (+31 / -0) across 2 files Reviewer: zhangyue19921010 Review duration: 845m
    All Vouch review confidence checks passed
    Residual risk 0.03 = Change Risk (0.25) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.25 · 31 lines diff across 2 files
    0.25
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.93 · 3 substantive comment(s)
    0.93
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    88%
    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.207
    Real PR Conversation Timeline
    8 items
    claude[bot] claude[bot] commented on Oct 22, 2026 12:20 UTC
    Reviewer

    Claude Code Review

    This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

    lance-gatekeeper[bot] lance-gatekeeper[bot] commented on Oct 22, 2026 12:30 UTC
    Reviewer

    ✅ Gate recommendation: approve.

    Namespace opens now reuse the caller’s session, with explicit builder sessions retaining precedence and caller ownership preserved. No blocking issues found.

    jischeng jischeng commented on Oct 22, 2026 13:10 UTC
    Author

    @claude review

    zhangyue19921010 zhangyue19921010 commented on Oct 22, 2026 13:39 UTC
    Contributor

    Hi @jischeng Thanks for this PR. Can we simplify the test cases as much as possible?

    jischeng jischeng commented on Oct 22, 2026 14:12 UTC
    Author

    Thanks for the suggestion! Simplified in 811d8bb04: the three tests are now one focused 30-line regression test. It creates a small table and opens it twice with a ReadOptions session, checking session identity, metadata-cache reuse, and that closing the dataset leaves the caller's session open. The version/fragment setup and separate precedence/ownership tests have been removed.

    Formatting checks and all 23 relevant Java tests passed locally. The PR description has also been updated to match.

    lance-gatekeeper[bot] lance-gatekeeper[bot] commented on Oct 22, 2026 14:21 UTC
    Reviewer

    ✅ Gate recommendation: approve.

    The simplified regression still detects the dropped session and verifies cache reuse and caller ownership. Explicit builder sessions retain precedence. No blocking issues found.

    zhangyue19921010 zhangyue19921010 approved these changes on Oct 23, 2026 02:26 UTC
    Approved Reviewer

    LGTM. Thanks!

    Assignees
    jischeng jischeng
    Labels
    risk: low confidence: 88.3% 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: 25.2% (LOW) · Higher = larger blast radius
    25.2%
    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: 88.3% · Lower = rushed or shallow review
    88.3%
    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: 2.9% · Safe to merge
    2.9%