fix(actor): do not false-orphan the current process own running actors on registry init#1724
Merged
Conversation
…s on registry init Root cause: Layer.effect's make body unconditionally UPDATEd ALL pending/running actors to idle+failure on every registry layer construction (L403-417). This killed actors that were registered by the very same process, not leftover rows from a dead one. Fix: each layer instance generates a unique instanceID on construction. Actors registered during that instance carry its ID. Orphan recovery now only touches rows whose instance_id != current instanceID, so actors belonging to the live process are left alone. Changes: - Add instance_id column to actor_registry (migration + schema) - Store instance_id in register() - Rewrite orphan recovery WHERE clause to filter by instance_id != current - Add test: same-instance running actor is NOT orphaned - Existing cross-instance orphan test continues to pass
…e orphaning on layer rebuild Move PROCESS_INSTANCE_ID out of Layer.effect to module level so it is computed once per process (from process.pid + hrtime) rather than regenerated on each layer construction. This prevents layer rebuilds within the same process from false-orphaning their own running children. Add tests verifying: - Same-process layer rebuild does NOT orphan running children - Rows from different instanceIDs ARE correctly orphaned
…omUUID for PROCESS_INSTANCE_ID
…t isolation #1724 changed orphan recovery to only mark rows whose instance_id differs from the current process. Since PROCESS_INSTANCE_ID is a process-level constant, same-process test leftovers survive orphan recovery. This causes listActive() to return stale rows, breaking assertions in: - 'listActive > returns empty list when no active tasks' - 'renderRebuildContext v3 > returns empty when no memory or tasks' (Both fail only when run after other actor tests, not in isolation.) Fix: add beforeEach hooks that delete all actor_registry rows, restoring the test isolation that the unconditional orphan recovery previously provided.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause:
Layer.effectinregistry.tsunconditionally UPDATEd ALLpending/runningactors toidle+failureon every registry layer construction (lines 403-417). This killed actors that were registered by the very same process, not leftover rows from a dead one.Fix: each layer instance now generates a unique
instanceIDon construction. Actors registered during that instance carry its ID in theinstance_idcolumn. Orphan recovery now only touches rows whoseinstance_id != current instanceID, so actors belonging to the live process are left alone.Changes
instance_idcolumn toactor_registry(migration + schema)instance_idinregister()WHEREclause to filter byinstance_id != currentVerification
bun typecheckexits 0