Skip to content

Prevent orphan actors from interrupted create requests#371

Open
level09 wants to merge 1 commit into
mainfrom
fix/atomic-actor-create
Open

Prevent orphan actors from interrupted create requests#371
level09 wants to merge 1 commit into
mainfrom
fix/atomic-actor-create

Conversation

@level09

@level09 level09 commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Production incident: a DB stall during actor save left an actor row committed with no actor_profile and no creation history. Text search inner-joins profiles, so the orphan was invisible to search while still reachable by ID; the user retried and produced a duplicate.

Two changes:

  • Actor.from_json now processes actor_profiles before events/medias/relations. Those blocks call save() mid-flow, committing the half-built actor via session cascade; with profiles wired first, any such commit persists the actor together with its profiles, so a search-invisible actor can no longer be created.
  • api_actor_create wraps the create flow and, on failure, deletes the partially committed actor before returning 500, so a client retry cannot leave duplicates behind.

Test plan

  • New test: TestActorCreateAtomic forces a failure after save and asserts no actor row survives
  • uv run pytest tests/test_core_entities.py tests/test_specialized.py (439 passed, 4 skipped)

@level09
level09 requested a review from apodacaduron as a code owner July 19, 2026 10:38
@level09 level09 self-assigned this Jul 19, 2026
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c9a70e83-1aab-473f-bb72-8daf626ffd56

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/atomic-actor-create

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.

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.

1 participant