Repository navigation
Serialise sleep-state writers and reject corrupt state - #320
Ryan Duguid (ryanduguid) wants to merge 3 commits into
Conversation
|
The locking change has useful production evidence: two real processes sharing state reject overlap before model work, a retry preserves both nights, and abrupt process exit releases the lock. Both existing state-writing entry points refuse contention before loading. The full Linux suite has 1,720 passes and 13 skips; its only failure is this audit sandbox's unavailable POSIX semaphore used by multiprocessing.Event. Independent subprocess tests avoid that facility and pass all three cases. Please address the reader upgrade boundary before merge. The real existing writer can produce valid GBK/cp1252 state; this head's new UTF-8-only loader rejects both with UnicodeDecodeError on the same simulated locale. It does preserve the file, so this is not a data-overwrite report. Coordinate with #302 to retain legacy migration, or provide a deliberate, actionable migration diagnostic naming the state file. Keep the non-object rejection and transaction-lock tests. The current five-PR proposed subset merges with this head cleanly; text conflicts are not the reason for this hold. CLA and official CI remain separate gates. |
State written before this change used the locale codec. Fall back to it when the file is not UTF-8, and name the file in the error when neither codec decodes it.
|
Thanks for testing this against real processes. b19ccff keeps the legacy migration: This overlaps #302's reader. Happy to rebase onto it if that lands first. |
|
@microsoft-github-policy-service agree |
|
Thank you for restoring legacy-codec compatibility in #302 is now merged on main |
microsoft#302 now provides the state reader with path-bearing diagnostics, so drop this branch's separate reader and its duplicate legacy-codec tests. The lock and the unique-tempfile save remain.
|
Thanks. f49e15b merges main (with #302) instead of rebasing, so the review history stays intact. The branch now uses #302's |
Summary
Acquire one process lock before either state-writing entry point loads state. Save through unique temporary files and refuse corrupt state rather than silently replacing it. A competing cycle stops before model work and can retry after the lock is released.
Evidence
After: All eight focused Windows state/process-lock cases pass using fabricated state. They cover competing writers, lock release and abrupt process exit.
Risk
A concurrent cycle now fails explicitly instead of continuing with stale state.
Unverified
The full current engine suite, live transcript handling and real backend integrations were not rerun. No live home/session data was used.