fix(rivetkit-core): fail closed sqlite during shutdown#4921
Conversation
Code ReviewOverviewThis PR fixes a shutdown-ordering race where "late callbacks" from a dying actor generation could issue SQLite work after the final state was serialized. The fix has two parts:
The core logic is correct, well-reasoned, and consistent with the project's fail-by-default and fail-closed design principles. CorrectnessDouble-check in
All DB paths go through guarded helpers. Local operations call
Potential Issues
pub(crate) async fn cleanup(&self) -> Result<()> {
self.close().await
}Since both
Shutdown Sequence OrderingThe new sequence is: The rationale is sound: step 1 ensures any late DB callback from this generation fails immediately, preventing a corrupt write that could race with step 2's state serialization. The parallelization in step 3 is safe because the three tasks are independent. One thing to verify: does Test CoverageThe Minor Style Notes
SummaryThe fix is correct and addresses a real bug. The |

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: