dirstate: check dirstate race condition around status stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 26 Feb 2023 08:17:23 +0100
branchstable
changeset 50232 5bf6b8015035
parent 50231 0f483a2c29e7
child 50233 cf0d7cd6a6fa
dirstate: check dirstate race condition around status More problems to solve.
tests/test-dirstate-read-race.t
--- a/tests/test-dirstate-read-race.t	Sun Feb 26 07:08:16 2023 +0100
+++ b/tests/test-dirstate-read-race.t	Sun Feb 26 08:17:23 2023 +0100
@@ -251,3 +251,45 @@
 
   $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
   $ cd ..
+
+Race with a cache updating `hg status`
+--------------------------------------
+
+It is interesting to race with "read-only" operation (that still update its cache)
+
+  $ cp -a reference-repo race-with-status
+  $ cd race-with-status
+
+spin a `hg status` with some caches to update
+
+  $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
+  > --config rhg.on-unsupported=abort \
+  > --config devel.sync.dirstate.pre-read-file=$TESTTMP/status-race-lock \
+  > &
+  $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
+do an update
+
+  $ touch -t 200001020006 f
+  $ hg status
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ touch $TESTTMP/status-race-lock
+  $ wait
+
+The status process should return a consistent result and not crash.
+
+  $ cat $TESTTMP/status-race-lock.out
+  A dir/o
+  R dir/nested/m
+  ? dir/n
+  ? p
+  ? q
+  $ cat $TESTTMP/status-race-lock.log
+
+final cleanup
+
+  $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
+  $ cd ..