Skip to content

fix: release the GVL while recording activity heartbeats - #699

Closed
viamin wants to merge 1 commit into
temporalio:mainfrom
viamin:fix/heartbeat-custom-slot-gvl
Closed

viamin wants to merge 1 commit into
temporalio:mainfrom
viamin:fix/heartbeat-custom-slot-gvl

Conversation

@viamin

@viamin viamin commented Nov 27, 2026

Copy link
Copy Markdown

Activity heartbeats can freeze an entire Ruby worker when custom activity slot suppliers are enabled. Core holds its outstanding-activity mutex while synchronously waiting for mark_slot_used; a Ruby heartbeat can retain the GVL while waiting for that same mutex, preventing the callback from running.

Decode the payload and clone the Core worker under the GVL, then use the existing without_gvl helper around record_activity_heartbeat. No Ruby objects are accessed in the unlocked section. Add concurrent heartbeat/GC coverage with custom slot suppliers in thread and fiber modes.

Validation on Linux arm64, Ruby 3.4.13, SDK v1.12.0 plus commit 9c06319:

  • Native release build, Rust formatting, and changed Ruby-file RuboCop passed.
  • New regression: 2 runs, 32 assertions, no failures.
  • All custom-slot cases: 8 runs, 82 assertions passed on an unchanged repeat. An initial run hit the existing simple test's transient reservation/release count assertion (19 versus 18).
  • An independent Paid acceptance subprocess completed 32 workflows with remote/local activities, GC and heartbeat contention, workflow cancellation, and exclusive admission-lock recovery.
  • The same acceptance workload against released 1.12.0 stalled in the native heartbeat call and exceeded its 120-second process deadline. Native backtraces from a live 1.9.0 worker showed the same mutex/GVL cycle.

The full SDK suite and Rust Clippy have not been run. No public API or workflow-command changes.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants