You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SimpleStateMachine.DisposeAsync leaves a completed snapshot writer open #313
SimpleStateMachine.DisposeAsync() can leave the temporary snapshot writer open when a snapshot has finished writing but no later log entry has applied it. This is reproducible with the unmodified DotNext.Net.Cluster 6.12.0 package and is still present on develop at 8d81cad5ce29baafb88cab9be4b15b1c2f14f766.
Expected: disposing the state machine releases its writer and discards any unpublished temporary snapshot, preserving the last published snapshot and the WAL.
Observed on Windows x64 (.NET 10.0.14): disposal returns, but the temporary file remains open with exclusive sharing and directory cleanup throws IOException. Disposing the WAL before the state machine and calling state disposal a second time do not fix it.
The standalone diagnostic produced these results (10 runs per scenario):
Scenario
Writer/cleanup failure
Correct state recovery
Snapshot creation disabled
0/10
10/10
Completed, unpublished snapshot
10/10
10/10
Same, with WAL flush and a 250 ms wait
10/10
10/10
Another committed entry publishes the prior snapshot
0/10
10/10
This is a shutdown resource-cleanup defect; these tests do not show state loss. A borrowed writer reference is retained in the diagnostic so garbage collection cannot hide a missing deterministic disposal.
The source path appears to be:
BeginSnapshottingAsync returns a successfully written/flushed SnapshotWriter that is still open.
The next ApplyCoreAsync normally installs the snapshot, closing that writer.
DisposeImplAsync instead waits for the snapshot task with SuppressThrowing and discards its successful result. The existing rollback path is not called.
Fix and regression tests: #314. SimpleStateMachineTests is included in the normal xUnit test project. The completed-snapshot cases assert the public writer is disposed and the temporary files are gone, including preservation of an existing published snapshot; cancellation/failure/no-snapshot cases are controls. On the unchanged implementation, exactly the two completed-snapshot cases fail and the other three pass.
Test command:
dotnet test --project src/DotNext.Tests/DotNext.Tests.csproj --filter-class "*.SimpleStateMachineTests"
Prepared with AI assistance; the reproduction and source path were independently reviewed.
Activity
sakno commentedon Nov 9, 2026
Fixed in 6.12.1.