Skip to content

Fix LangGraph registration ownership during cleanup - #1941

Draft
priscilla-leang1 wants to merge 1 commit into
temporalio:mainfrom
priscilla-leang1:fix/langgraph-registration-cleanup
Draft

priscilla-leang1 wants to merge 1 commit into
temporalio:mainfrom
priscilla-leang1:fix/langgraph-registration-cleanup

Conversation

@priscilla-leang1

Copy link
Copy Markdown

Summary

A retired LangGraph workflow coroutine can be garbage-collected after another workflow instance has registered its graphs and functional entrypoints. Its cleanup currently reads the active workflow context and unconditionally removes that run's registration. This can unregister a replacement instance, unregister a different workflow, or raise when no workflow context exists.

Capture the run ID at registration and give each inbound instance an ownership token. Cleanup removes registration and store-warning state only if that instance still owns it. A reentrant lock keeps registration and conditional removal atomic across threads while allowing cleanup triggered by same-thread garbage collection. Checking graph-object identity alone would not cover instances sharing the same plugin.

Regression coverage

The included tests cover replacement with a fresh or reused plugin, cleanup under another workflow's context, cleanup outside a workflow context, and ordinary completion. Closing a suspended coroutine makes the cleanup ordering deterministic without depending on GC timing.

Validation

  • Published SDK 1.28.0 and 1.34.0: four regression cases fail before the patch; the ordinary-completion case passes.
  • SDK 1.34.0 wheel with the modified interceptor loaded: all five regression cases and seven existing plugin-validation cases pass (12 total).
  • SDK 1.28.0 with the exact modified interceptor: five real local Temporal worker-replacement runs pass with garbage collection forced before replacement execution.
  • Ruff lint, format check, and git diff --check pass.

Validation used published wheel bridges with the modified Python interceptor. The upstream Rust bridge was not rebuilt, and the full upstream lint and test suites have not been run. This draft is ready for maintainer feedback and upstream CI.

@CLAassistant

CLAassistant commented Oct 7, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
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