Skip to content

crossks: add runtime handles and support aquire/release - #68890

Merged
ti-chi-bot[bot] merged 13 commits into
pingcap:masterfrom
D3Hunter:crossks-bookkeep
Jun 4, 2026
Merged

ti-chi-bot[bot] merged 13 commits into
pingcap:masterfrom
D3Hunter:crossks-bookkeep

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #68883

Problem Summary:

This PR is a partial step for reclaiming NextGen cross-keyspace runtimes. Current crossKS consumers can obtain raw stores and session pools, but the manager does not know which task-level owner is holding a target-keyspace runtime. That makes duplicate ownership checks and release bookkeeping unavailable.

What changed and how does it work?

  • Add sqlsvrapi.KSRuntime and sqlsvrapi.KSRuntimeHandle, and expose AcquireKSRuntime through sqlsvrapi.Server.
  • Implement Domain.AcquireKSRuntime by delegating to the crossKS manager.
  • Replace the crossKS manager's keyspace-to-session-manager map with runtime entries that track the session manager, active bookkeepers, and the last release time.
  • Add Manager.Acquire to require non-empty bookkeepers, reject duplicate active bookkeepers for the same keyspace, and return an idempotent release handle.
  • Keep existing GetOrCreate, Get, CloseKS, and Close behavior working through the new runtime entries.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Test commands:

  • make bazel_prepare
  • ./tools/check/failpoint-go-test.sh pkg/domain/crossks -run 'TestAcquireRuntimeHandle$' -count=1
  • ./tools/check/failpoint-go-test.sh pkg/domain/crossks -run 'Test(AcquireRuntimeHandle|DomainAcquireKSRuntimeHandle)$' -tags=intest,deadlock,nextgen -count=1
  • make lint

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Summary by CodeRabbit

  • New Features

    • Added a handle-based API for acquiring cross-keyspace runtimes that exposes storage and session-pool access and requires explicit Release; server surface updated to return these handles.
  • Bug Fixes

    • Prevent duplicate acquisitions by the same holder, track multiple owners correctly, and make Release idempotent to avoid premature session teardown.
  • Tests

    • Expanded tests covering acquisition rules, concurrent acquisitions, release behavior, and end-to-end runtime handle scenarios.

@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label Jun 2, 2026
@pantheon-ai

pantheon-ai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

@D3Hunter I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jun 2, 2026
@tiprow

tiprow Bot commented Jun 2, 2026

Copy link
Copy Markdown

Hi @D3Hunter. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds KSRuntime and KSRuntimeHandle interfaces; refactors cross-keyspace Manager to runtimeEntry-based Acquire/Release with per-holder bookkeeping and idempotent handles; exposes Domain.AcquireKSRuntime; updates Bazel tests; and adds unit and integration tests validating handle behavior.

Changes

Cross-keyspace runtime acquisition system

Layer / File(s) Summary
KSRuntime interface contract
pkg/domain/sqlsvrapi/server.go
Defines KSRuntime and KSRuntimeHandle (adds Release()), and updates Server.AcquireKSRuntime to return KSRuntimeHandle.
Manager refactor and Acquire semantics
pkg/domain/crossks/cross_ks.go
Refactors Manager to store runtimeEntry per keyspace (SessionManager, active-holder set, lastReleaseAt), implements Acquire() with non-empty holder validation and duplicate-acquire prevention, adds Manager.release, and introduces runtimeHandle with idempotent Release().
Domain AcquireKSRuntime entry point
pkg/domain/domain.go
Adds Domain.AcquireKSRuntime delegating to crossKSSessMgr.Acquire and removes the test-only CloseKSSessMgr.
Build and test infra
pkg/domain/crossks/BUILD.bazel
Adds //pkg/domain/sqlsvrapi dep to crossks library; expands crossks_test sources to include cross_ks_internal_test.go, sets embed = [\":crossks\"], increases shard_count to 4, and extends test deps.
Unit tests for Manager.Acquire/Release
pkg/domain/crossks/cross_ks_internal_test.go
Adds TestAcquireRuntimeHandle and test helpers exercising empty-holder and classic-kernel rejection, active-holder tracking, duplicate-acquire error, concurrent acquisition path, and Release() bookkeeping and pool close checks.
Integration tests and test helpers
pkg/domain/crossks/cross_ks_test.go
Centralizes UniStore registration via sync.Once, updates cleanup to use GetCrossKSMgr().CloseKS(...), and adds TestDomainAcquireKSRuntimeHandle (nextgen-only) validating handle/store/pool identity.
Test export helpers
pkg/domain/crossks/export_test.go
Adds test-only Manager.Get and Manager.CloseKS to access and close runtime entries in tests.

Sequence Diagram

sequenceDiagram
  participant Domain
  participant Manager
  participant runtimeEntry
  participant SessionManager
  participant runtimeHandle

  Domain->>Manager: Acquire(targetKS, holderID)
  Manager->>Manager: getOrCreateEntryWithoutLock(targetKS)
  Manager->>runtimeEntry: add/check activeHolders(holderID)
  alt duplicate holder
    Manager-->>Domain: error
  else success
    Manager->>runtimeHandle: create(handle -> runtimeEntry)
    runtimeHandle->>SessionManager: delegate Store()/SessPool()
    Manager-->>Domain: return runtimeHandle
  end

  Domain->>runtimeHandle: Store() / SessPool()
  runtimeHandle->>SessionManager: return storage / pool

  Domain->>runtimeHandle: Release()
  runtimeHandle->>Manager: release(holderID)
  Manager->>runtimeEntry: Remove holder, set lastReleaseAt if empty
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Suggested labels

size/XXL, ok-to-test

Suggested reviewers

  • tiancaiamao
  • yudongusa

Poem

🐰 I hop through runtimes, keys in paw,
tracking holders, keeping law.
I hand a handle, soft and neat—
Release returns the session seat.
carrots, pools, and sleeps complete.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title identifies the main change (runtime handles and acquire/release) in the crossks package, clearly summarizing the PR's core feature addition.
Description check ✅ Passed The PR description includes the required issue reference (ref #68883), a detailed problem summary, comprehensive implementation details, and completed test checklist with test commands. All main sections are adequately addressed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/domain/crossks/cross_ks_test.go (1)

47-55: 💤 Low value

Optional: surface a previously failed registration to later callers.

err is only assigned inside the Once, so any caller after the first always observes nil. If the one-time Register ever fails, only the first test reports it while every subsequent registerUnistore silently passes. Caching the error outside the closure makes the failure deterministic for all callers.

♻️ Cache registration result
 var registerUnistoreOnce sync.Once
+var registerUnistoreErr error
 
 func registerUnistore(t *testing.T) {
-	var err error
 	registerUnistoreOnce.Do(func() {
-		err = kvstore.Register(config.StoreTypeUniStore, mockstore.EmbedUnistoreDriver{})
+		registerUnistoreErr = kvstore.Register(config.StoreTypeUniStore, mockstore.EmbedUnistoreDriver{})
 	})
-	require.NoError(t, err)
+	require.NoError(t, registerUnistoreErr)
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/domain/crossks/cross_ks_test.go` around lines 47 - 55, The one-time
registration error is stored in a local variable inside the sync.Once closure so
subsequent callers always see nil; declare a package-level error variable (e.g.
registerUnistoreErr) and assign it inside registerUnistoreOnce.Do when calling
kvstore.Register(config.StoreTypeUniStore, mockstore.EmbedUnistoreDriver{}),
then have registerUnistore call require.NoError(t, registerUnistoreErr) so any
registration failure is observable by all callers of registerUnistore.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/domain/crossks/cross_ks_test.go`:
- Around line 47-55: The one-time registration error is stored in a local
variable inside the sync.Once closure so subsequent callers always see nil;
declare a package-level error variable (e.g. registerUnistoreErr) and assign it
inside registerUnistoreOnce.Do when calling
kvstore.Register(config.StoreTypeUniStore, mockstore.EmbedUnistoreDriver{}),
then have registerUnistore call require.NoError(t, registerUnistoreErr) so any
registration failure is observable by all callers of registerUnistore.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4d07ff42-06ff-47fc-899f-a9649cdee94c

📥 Commits

Reviewing files that changed from the base of the PR and between 41f830f and 3ff13a5.

📒 Files selected for processing (6)
  • pkg/domain/crossks/BUILD.bazel
  • pkg/domain/crossks/cross_ks.go
  • pkg/domain/crossks/cross_ks_internal_test.go
  • pkg/domain/crossks/cross_ks_test.go
  • pkg/domain/domain.go
  • pkg/domain/sqlsvrapi/server.go

@D3Hunter D3Hunter changed the title domain: add cross-keyspace runtime handles crossks: add runtime handles and support bookkeeping Jun 2, 2026
@codecov

codecov Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 1.94175% with 101 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.7276%. Comparing base (6c43104) to head (e5f6c1f).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #68890        +/-   ##
================================================
+ Coverage   76.3138%   76.7276%   +0.4137%     
================================================
  Files          2041       2054        +13     
  Lines        562941     573044     +10103     
================================================
+ Hits         429602     439683     +10081     
+ Misses       132425     131534       -891     
- Partials        914       1827       +913     
Flag Coverage Δ
integration 46.3719% <1.9417%> (+6.6332%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 60.4610% <ø> (ø)
parser ∅ <ø> (∅)
br 66.1422% <ø> (+3.3453%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ingress-bot

Copy link
Copy Markdown

🔍 Starting code review for this PR...

@ingress-bot ingress-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.

Summary

  • Total findings: 13
  • Inline comments: 12
  • Summary-only findings (no inline anchor): 0
Findings (highest risk first)

⚠️ [Major] (1)

  1. New AcquireKSRuntime / KSRuntimeHandle surface documents no lifecycle or error contract (pkg/domain/sqlsvrapi/server.go:38, pkg/domain/sqlsvrapi/server.go:30, pkg/domain/sqlsvrapi/server.go:32)

🟡 [Minor] (10)

  1. runtimeEntry.lastReleaseAt is written but never read outside tests (pkg/domain/crossks/cross_ks.go:56, pkg/domain/crossks/cross_ks.go:336)
  2. bookkeeper parameter name does not convey caller-identity / uniqueness semantics (pkg/domain/crossks/cross_ks.go:125, pkg/domain/sqlsvrapi/server.go:38, pkg/domain/domain.go:304)
  3. crossks now depends on sqlsvrapi only to name Acquire's return type (pkg/domain/crossks/cross_ks.go:127, pkg/domain/crossks/cross_ks.go:33, pkg/domain/crossks/BUILD.bazel:9)
  4. Acquire creates the runtime under the global write lock, serializing all cross-keyspace handle operations behind blocking store/etcd init (pkg/domain/crossks/cross_ks.go:135, pkg/domain/crossks/cross_ks.go:173, pkg/domain/crossks/cross_ks.go:193, pkg/domain/crossks/cross_ks.go:327)
  5. New concurrent Acquire/Release reference-counting protocol has no concurrent (race) regression coverage (pkg/domain/crossks/cross_ks.go:142, pkg/domain/crossks/cross_ks.go:192, pkg/domain/crossks/cross_ks.go:326, pkg/domain/crossks/cross_ks_internal_test.go:91)
  6. Stale-handle identity guard in Manager.release has no rationale comment (pkg/domain/crossks/cross_ks.go:331)
  7. Acquire/Release handle pair performs no runtime teardown; released cross-keyspace runtimes are never reclaimed (pkg/domain/crossks/cross_ks.go:326, pkg/domain/crossks/cross_ks.go:388, pkg/domain/crossks/cross_ks.go:345, pkg/domain/domain.go:885)
  8. New runtime reference-counting has no test covering the close-while-acquired and stale-handle release paths (pkg/domain/crossks/cross_ks.go:348, pkg/domain/crossks/cross_ks.go:326, pkg/domain/crossks/cross_ks_internal_test.go:79)
  9. KSRuntime name now denotes two differently-shaped keyspace-runtime types (pkg/domain/sqlsvrapi/server.go:24, tests/realtikvtest/testkit.go:161)
  10. Server now exposes two parallel keyspace-access contracts (tracked Acquire vs untracked GetKS*) over the same runtimeEntry (pkg/domain/sqlsvrapi/server.go:38, pkg/domain/crossks/cross_ks.go:142, pkg/domain/crossks/cross_ks.go:192, pkg/domain/domain.go:885)

🧹 [Nit] (2)

  1. release sync.Once field name collides with the Release() method and Manager.release (pkg/domain/crossks/cross_ks.go:377)
  2. tracks bookkeepers subtest bundles several distinct behaviors, reducing failure isolation (pkg/domain/crossks/cross_ks_internal_test.go:91)

Comment thread pkg/domain/sqlsvrapi/server.go Outdated
Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/sqlsvrapi/server.go
Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/crossks/cross_ks_internal_test.go Outdated

@ingress-bot ingress-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.

Summary

  • Total findings: 13
  • Inline comments: 12
  • Summary-only findings (no inline anchor): 0
Findings (highest risk first)

⚠️ [Major] (3)

  1. Acquire/Release bookkeeping does not gate runtime teardown (pkg/domain/crossks/cross_ks.go:345, pkg/domain/crossks/cross_ks.go:355, pkg/domain/crossks/cross_ks.go:123, pkg/domain/crossks/cross_ks.go:326)
  2. Release() name signals resource teardown but only updates bookkeeping (pkg/domain/sqlsvrapi/server.go:32, pkg/domain/crossks/cross_ks.go:388, pkg/domain/crossks/cross_ks.go:326)
  3. Public AcquireKSRuntime exposes undocumented, non-domain bookkeeper parameter (pkg/domain/sqlsvrapi/server.go:38, pkg/domain/crossks/cross_ks.go:123, pkg/domain/domain.go:304)

🟡 [Minor] (8)

  1. lastReleaseAt is written but never read (pkg/domain/crossks/cross_ks.go:56, pkg/domain/crossks/cross_ks.go:336)
  2. Bookkeeper accounting is bypassed by the existing GetKSStore/GetKSSessPool paths (pkg/domain/crossks/cross_ks.go:123, pkg/domain/crossks/cross_ks.go:173, pkg/domain/domain.go:867, pkg/domain/domain.go:885)
  3. Acquire/Release serialize on the global mutex held through a multi-second keyspace cold start (pkg/domain/crossks/cross_ks.go:138, pkg/domain/crossks/cross_ks.go:326, pkg/domain/crossks/cross_ks.go:193)
  4. Reference-counted Acquire/Release model runs in parallel with unmanaged GetKSStore/GetKSSessPool over the same runtimeEntry (pkg/domain/crossks/cross_ks.go:149, pkg/domain/crossks/cross_ks.go:173, pkg/domain/crossks/cross_ks.go:344, pkg/domain/sqlsvrapi/server.go:38)
  5. Stale-entry guard in Manager.release has no rationale comment for a non-obvious invariant (pkg/domain/crossks/cross_ks.go:330)
  6. New runtime-handle lifecycle-race paths are untested (Release after CloseKS, stale-entry guard, Close-while-acquired) (pkg/domain/crossks/cross_ks.go:331, pkg/domain/crossks/cross_ks.go:348, pkg/domain/crossks/cross_ks_internal_test.go:379)
  7. CloseKS/Close tear down a runtime while bookkeepers are still active (pkg/domain/crossks/cross_ks.go:349, pkg/domain/crossks/cross_ks.go:359, pkg/domain/crossks/cross_ks.go:384)
  8. Newly exported KSRuntime interface is only ever embedded once, growing public surface without a standalone consumer (pkg/domain/sqlsvrapi/server.go:24)

ℹ️ [Info] (1)

  1. Release records lastReleaseAt but never reclaims the idle runtime (pkg/domain/crossks/cross_ks.go:336, pkg/domain/crossks/cross_ks.go:56)

🧹 [Nit] (1)

  1. runtimeHandle.release field name collides with Release() and Manager.release (pkg/domain/crossks/cross_ks.go:377)

Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/sqlsvrapi/server.go
Comment thread pkg/domain/sqlsvrapi/server.go Outdated
Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/sqlsvrapi/server.go
Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks.go Outdated
@D3Hunter D3Hunter changed the title crossks: add runtime handles and support bookkeeping crossks: add runtime handles and support aquire/release Jun 3, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/domain/crossks/cross_ks.go (1)

122-159: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Close partially initialized runtime state on failed acquire.

Acquire is now the public entry point into createSessionManager, but that failure path still only tears down etcdCli and store. If cold start fails after sessPool is built—e.g. schemaVerSyncer.Init() or isSyncer.Reload() returns an error—the pool (and a successfully initialized syncer) stays open, so repeated failed acquires can leak sessions/background state.

Suggested fix in createSessionManager
 func (*Manager) createSessionManager(
 	ks string,
 	ksSessFactoryGetter func(string, validatorapi.Validator) pools.Factory,
 ) (_ *SessionManager, err error) {
 	startTime := time.Now()
 	getStoreFn := getOrCreateStore
 	failpoint.InjectCall("beforeGetStore", &getStoreFn)
+	var schemaVerSyncer schemaver.Syncer
 	var store kv.Storage
 	store, err = getStoreFn(ks)
 	if err != nil {
 		return nil, err
 	}
@@
 	sessPool := util.NewSessionPool(
 		crossKSSessPoolSize, ksSessFactoryGetter(ks, isValidator),
@@
 	)
+	defer func() {
+		if err != nil {
+			sessPool.Close()
+			if schemaVerSyncer != nil {
+				schemaVerSyncer.Close()
+			}
+		}
+	}()
@@
-	schemaVerSyncer := schemaver.NewEtcdSyncer(etcdCli, virtualSvrID)
+	schemaVerSyncer = schemaver.NewEtcdSyncer(etcdCli, virtualSvrID)
 	if err = schemaVerSyncer.Init(ctx); err != nil {
 		return nil, errors.Trace(err)
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/domain/crossks/cross_ks.go` around lines 122 - 159, The
createSessionManager path currently only cleans etcdCli and store on error,
leaking sessPool and syncer state; update createSessionManager (used by
getOrCreateEntryWithoutLock and Acquire) to perform full cleanup on any error
after partial initialization: explicitly Close/Stop the session pool (sessPool),
stop/schema/version syncers (e.g., schemaVerSyncer, isSyncer), and release any
other resources attached to the entry (etcdCli/store already handled) before
returning the error, and ensure entry.activeHolders or other maps are not left
in a partially populated state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@pkg/domain/crossks/cross_ks.go`:
- Around line 122-159: The createSessionManager path currently only cleans
etcdCli and store on error, leaking sessPool and syncer state; update
createSessionManager (used by getOrCreateEntryWithoutLock and Acquire) to
perform full cleanup on any error after partial initialization: explicitly
Close/Stop the session pool (sessPool), stop/schema/version syncers (e.g.,
schemaVerSyncer, isSyncer), and release any other resources attached to the
entry (etcdCli/store already handled) before returning the error, and ensure
entry.activeHolders or other maps are not left in a partially populated state.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e6f6d98f-39c5-4fdc-a146-42017af2009e

📥 Commits

Reviewing files that changed from the base of the PR and between 57c76c1 and f2ef0d0.

📒 Files selected for processing (3)
  • pkg/domain/crossks/BUILD.bazel
  • pkg/domain/crossks/cross_ks.go
  • pkg/domain/crossks/export_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/domain/crossks/BUILD.bazel

@ingress-bot ingress-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.

Summary

  • Total findings: 8
  • Inline comments: 8
  • Summary-only findings (no inline anchor): 0
Findings (highest risk first)

🟡 [Minor] (8)

  1. runtimeEntry.lastReleaseAt invariant is undocumented and the name reads as a per-release timestamp (pkg/domain/crossks/cross_ks.go:56, pkg/domain/crossks/cross_ks.go:341)
  2. lastReleaseAt is not cleared when an idle runtime entry is re-acquired (pkg/domain/crossks/cross_ks.go:148, pkg/domain/crossks/cross_ks.go:342)
  3. Acquire surfaces "session manager" error text despite returning a runtime handle (pkg/domain/crossks/cross_ks.go:167)
  4. Acquire/release docs promise resource cleanup that is not implemented (pkg/domain/crossks/cross_ks.go:326, pkg/domain/crossks/cross_ks.go:120)
  5. Global manager lock is held across keyspace creation, stalling the new Release() path and all other keyspace ops (pkg/domain/crossks/cross_ks.go:329, pkg/domain/crossks/cross_ks.go:134, pkg/domain/crossks/cross_ks.go:192)
  6. New runtime-handle test leaves process-global config.KeyspaceName mutated with no restore (pkg/domain/crossks/cross_ks_test.go:317)
  7. KSRuntimeHandle.Release contract omits the idempotency that callers and tests rely on (pkg/domain/sqlsvrapi/server.go:32, pkg/domain/crossks/cross_ks.go:374)
  8. AcquireKSRuntime adds a holder-tracked path parallel to the untracked GetKSStore/GetKSSessPool (pkg/domain/sqlsvrapi/server.go:44, pkg/domain/domain.go:867, pkg/domain/domain.go:885, pkg/domain/crossks/cross_ks.go:328)

Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks.go Outdated
Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks.go
Comment thread pkg/domain/crossks/cross_ks_test.go
Comment thread pkg/domain/sqlsvrapi/server.go
Comment thread pkg/domain/sqlsvrapi/server.go
@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 3, 2026
@D3Hunter

D3Hunter commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Jun 3, 2026

Copy link
Copy Markdown

@D3Hunter: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Comment thread pkg/domain/crossks/cross_ks.go Outdated
func (m *Manager) getOrCreateEntryWithoutLock(
ks string,
ksSessFactoryGetter func(string, validatorapi.Validator) pools.Factory,
) (_ *runtimeEntry, err error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
) (_ *runtimeEntry, err error) {
) (*runtimeEntry, error) {

Comment thread pkg/domain/sqlsvrapi/server.go Outdated
KSRuntime
// Release releases the holding of the runtime handle. After calling Release,
// the handle should not be used anymore.
// the underlying runtime have different lifecycle, the handle is just a view

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// the underlying runtime have different lifecycle, the handle is just a view
// the underlying runtime has different lifecycle, the handle is just a view

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 3, 2026
@D3Hunter

D3Hunter commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Jun 4, 2026

Copy link
Copy Markdown

@D3Hunter: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wuhuizuo

wuhuizuo commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

/retest

@tiprow

tiprow Bot commented Jun 4, 2026

Copy link
Copy Markdown

@wuhuizuo: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@D3Hunter

D3Hunter commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Jun 4, 2026

Copy link
Copy Markdown

@D3Hunter: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot

ti-chi-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joechenrh, wjhuang2016

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 4, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-03 07:32:18.118972542 +0000 UTC m=+340439.189289922: ☑️ agreed by joechenrh.
  • 2026-06-04 08:29:29.407737881 +0000 UTC m=+430270.478055261: ☑️ agreed by wjhuang2016.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants