Repository navigation
Investigate DeviceIdentityStore minting under contention #526
Description
While running the FileSystem unit-test assembly six times concurrently to reproduce a CI flake, one run had DeviceIdentityStoreTests.A_reader_arriving_while_the_name_is_rewritten_never_mints_over_it fail with a second device id minted, and PackagedAppDataTests.What_the_person_kept_beside_the_backlog_stays_where_it_was report Failed instead of Adopted. The first is the store's core "never mint over the id on disk" guarantee, so it may be a product bug rather than test noise. This session should reproduce under load and decide.
Context
Two tests in tests/Backlog.Infrastructure.FileSystem.UnitTests failed once in six concurrent Release runs of the whole assembly (each process on its own GUID temp root, so not a cross-process path collision):
-
DeviceIdentityStoreTests.A_reader_arriving_while_the_name_is_rewritten_never_mints_over_it (DeviceIdentityStoreTests.cs ~line 129):
Assert.Equal([original], ids.Distinct())saw two distinct GUIDs. The test runs Parallel.For(0, 100) constructing DeviceIdentityStore(IdentityPath, alternating names) and asserts every reader comes away with the one id on disk. A second id means a reader saw a half-written or empty file and minted over it ΓÇö the exact failure the store (src/Infrastructure/Backlog.Infrastructure.FileSystem, DeviceIdentityStore) is documented to prevent. Investigate whether the rewrite path is genuinely non-atomic under contention (e.g. File.WriteAllText truncate-then-write without a temp-file + File.Move/Replace) and fix in the store if so, with a regression test that fails reliably under load. -
PackagedAppDataTests.What_the_person_kept_beside_the_backlog_stays_where_it_was (PackagedAppDataTests.cs ~line 98): expected Adopted, got Failed. Lower confidence; check whether it depends on timing or on disk state under load.
Reproduce with concurrent full-assembly runs (memory note: sequential repeats pass on unfixed code; use three or more concurrent runs of the built test exe with stdin closed and a timeout). This repository's CLAUDE.md orchestration gate applies to any write under src/ or tests/ ΓÇö route through orch-bug.
Filed automatically from a Claude Code suggested task.
Activity
JSdotNet commentedon Sep 28, 2026
The issue sweep needs two answers before this can be fixed:
PackagedAppDataTests, did the adoption result carry an error or a message that explains why the outcome wasFailed?The temp-file plus
File.Movewrite this issue asks for already landed in bcc7b01, the day before the issue was filed. Without these answers the failure has no known cause.JSdotNet commentedon Oct 15, 2026
The issue sweep (2026-10-15) opened draft pull request #1289. Told to decide without waiting, it fixed the store (a 2 s adoption window instead of 5 × 20 ms) rather than loosening the test; the pull request names the alternative and what following it would change.
JSdotNet commentedon Oct 17, 2026
Closed by the issue sweep as already fixed: PR #1289 (merge fffd9f4, on main) replaced the fixed retry in DeviceIdentityStore.cs with a 2 s adoption window, adds the regression tests in DeviceIdentityStoreTests.cs, and makes PackagedAppDataTests report the adoption error.