Fix attachment retention test lifecycle race - #2337
Open
baixiaohang wants to merge 1 commit into
Open
Conversation
yuezengwu
approved these changes
Aug 14, 2026
yuezengwu
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the lifecycle fix. createTestApp() now disables the retention sweep by default while production remains enabled unless explicitly opted out; active retention sweeps are tracked and awaited before the database pool closes. The helper-level and in-flight shutdown regressions cover both failure boundaries. No schema or core data-structure changes. No blocking findings.
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
Main CI run 31784141632 failed when the per-test
TRUNCATE ... CASCADEdeadlocked with the startup attachment-retention query. The retention sweep was launched fire-and-forget frombackgroundTasks.start(), so a test app could return fromready()while the sweep was still using the same worker database.The failed
me-multi-orgtest was only the cleanup victim. PR #2334 did not change the test harness, background task, retention service, or failed test.Validation
Passed locally:
--maxWorkers=2--maxWorkers=2pnpm --filter @first-tree/server typecheckgit diff --checkMutation checks also proved both regressions are effective:
stop()wait changes the settlement race fromsweep-pendingtostoppedcreateTestApp()default-disable wiring starts the mocked retention sweep and fails the helper-level test