Skip to content

fix: avoid remote lock stale bind hangs - #24232

Merged
mergify[bot] merged 3 commits into
matrixorigin:mainfrom
LeftHandCold:backport/pr24206-main
Apr 29, 2026
Merged

mergify[bot] merged 3 commits into
matrixorigin:mainfrom
LeftHandCold:backport/pr24206-main

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

fixes #24205

What this PR does / why we need it:

This backports #24206 to main.

The remote lock / forward lock response path could still leave the requester hung in morpc.Future.Get() after the owner had already taken the lock, and remote keepalive tracking at service granularity could leave stale remote holders behind after one bind was lost.

This backport switches the remote lock result path to bounded synchronous writes, keeps the lock outcome separate from response write failures, tracks remote keepalive at bind granularity during orphan detection, and sends KeepRemoteLock heartbeats per bind so multiple remote tables on the same peer are all refreshed.

Also included:

  • regression coverage for bounded response writes
  • stale-bind orphan cleanup coverage adapted to main's current lockservice test helpers
  • multi-bind keepalive refresh coverage

Validation

  • go test ./pkg/common/morpc ./pkg/lockservice -count=1

Copilot AI 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.

Pull request overview

This PR backports fixes for remote/forward lock hangs caused by broken response paths and stale remote lock bind tracking by switching response writes to bounded synchronous writes and tracking keepalives at bind granularity.

Changes:

  • Use bounded synchronous response writes for remote/forward lock responses to avoid requesters hanging in morpc.Future.Get().
  • Track remote keepalive per (remote service + bind) and update orphan detection/cleanup accordingly.
  • Add/adjust regression tests covering bounded response writes, stale-bind orphan cleanup, and multi-bind keepalive refresh.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/lockservice/waiter_events.go Add bind-level heartbeat check during orphan detection using configured remote lock timeout.
pkg/lockservice/txn_test.go Update newWaiterEvents call signature in tests.
pkg/lockservice/service_remote.go Switch remote/forward lock response path to writeResponseWithDeadline; update remote keepalive tracking and remoteService attribution.
pkg/lockservice/service_forward_test.go Assert forwarded txn records remote service and bind heartbeat presence.
pkg/lockservice/service.go Add bind-level keepalive tracking to activeTxnHolder; implement bind heartbeat map + keying and safe-unlock checks.
pkg/lockservice/rpc_test.go Add tests ensuring response writes use sync Write with deadlines.
pkg/lockservice/rpc.go Introduce defaultRPCWriteTimeout; implement writeResponseWithDeadline and route writeResponse through it.
pkg/lockservice/orphan_txn_test.go Add tests for missing bind heartbeat unlock behavior and multi-bind keepalive refresh; add canUnlockRemoteTxn unit tests.
pkg/lockservice/lock_table_local_test.go Update newWaiterEvents call signature in tests.
pkg/lockservice/lock_table_keeper_test.go Update newWaiterEvents call signature in tests.
pkg/lockservice/lock_table_keeper.go Change remote keepalive to send heartbeats per bind (not per service).
pkg/common/morpc/server_test.go Add tests for bounded ClientSession.Write, message release on queue-full, and write-loop failure handling.
pkg/common/morpc/server.go Add server option to release dropped responses; make write loop complete/close futures on failures and release messages on non-delivery paths.
pkg/common/morpc/cfg.go Wire new server option to provide response release callback to the server write loop.

Comment thread pkg/lockservice/lock_table_keeper.go Resolved
Comment thread pkg/lockservice/service_remote.go Resolved
@mergify mergify Bot added the queued label Apr 29, 2026
@mergify

mergify Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-04-29 03:47 UTC · Rule: main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-04-29 04:46 UTC · at c7a4c05fffaac7d2274e946e6b4dd01c031a823a · squash

This pull request spent 59 minutes 49 seconds in the queue, including 59 minutes 27 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI / Compatibility Test With Target on Linux/x64(LAUNCH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage

@mergify
mergify Bot merged commit 02a4376 into matrixorigin:main Apr 29, 2026
23 of 25 checks passed
@mergify mergify Bot removed the queued label Apr 29, 2026
@LeftHandCold
LeftHandCold deleted the backport/pr24206-main branch April 29, 2026 07:08
fengttt pushed a commit to fengttt/matrixone that referenced this pull request May 7, 2026
This backports matrixorigin#24206 to `main`.

The remote lock / forward lock response path could still leave the requester hung in `morpc.Future.Get()` after the owner had already taken the lock, and remote keepalive tracking at service granularity could leave stale remote holders behind after one bind was lost.

This backport switches the remote lock result path to bounded synchronous writes, keeps the lock outcome separate from response write failures, tracks remote keepalive at bind granularity during orphan detection, and sends `KeepRemoteLock` heartbeats per bind so multiple remote tables on the same peer are all refreshed.

Also included:
- regression coverage for bounded response writes
- stale-bind orphan cleanup coverage adapted to `main`'s current lockservice test helpers
- multi-bind keepalive refresh coverage

Approved by: @iamlinjunhong, @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
This backports matrixorigin#24206 to `main`.

The remote lock / forward lock response path could still leave the requester hung in `morpc.Future.Get()` after the owner had already taken the lock, and remote keepalive tracking at service granularity could leave stale remote holders behind after one bind was lost.

This backport switches the remote lock result path to bounded synchronous writes, keeps the lock outcome separate from response write failures, tracks remote keepalive at bind granularity during orphan detection, and sends `KeepRemoteLock` heartbeats per bind so multiple remote tables on the same peer are all refreshed.

Also included:
- regression coverage for bounded response writes
- stale-bind orphan cleanup coverage adapted to `main`'s current lockservice test helpers
- multi-bind keepalive refresh coverage

Approved by: @iamlinjunhong, @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
This backports matrixorigin#24206 to `main`.

The remote lock / forward lock response path could still leave the requester hung in `morpc.Future.Get()` after the owner had already taken the lock, and remote keepalive tracking at service granularity could leave stale remote holders behind after one bind was lost.

This backport switches the remote lock result path to bounded synchronous writes, keeps the lock outcome separate from response write failures, tracks remote keepalive at bind granularity during orphan detection, and sends `KeepRemoteLock` heartbeats per bind so multiple remote tables on the same peer are all refreshed.

Also included:
- regression coverage for bounded response writes
- stale-bind orphan cleanup coverage adapted to `main`'s current lockservice test helpers
- multi-bind keepalive refresh coverage

Approved by: @iamlinjunhong, @XuPeng-SH
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
This backports matrixorigin#24206 to `main`.

The remote lock / forward lock response path could still leave the requester hung in `morpc.Future.Get()` after the owner had already taken the lock, and remote keepalive tracking at service granularity could leave stale remote holders behind after one bind was lost.

This backport switches the remote lock result path to bounded synchronous writes, keeps the lock outcome separate from response write failures, tracks remote keepalive at bind granularity during orphan detection, and sends `KeepRemoteLock` heartbeats per bind so multiple remote tables on the same peer are all refreshed.

Also included:
- regression coverage for bounded response writes
- stale-bind orphan cleanup coverage adapted to `main`'s current lockservice test helpers
- multi-bind keepalive refresh coverage

Approved by: @iamlinjunhong, @XuPeng-SH

This branch was previously deployed

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

Labels

kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: lockservice can hang on stale remote lock binds

5 participants