comparison tests/test-dirstate-status-write-race.t @ 50223:3f34d800cc69 stable

dirstate: tests racing status with both dirstate-v2 append and rewrite The way the racing process touches the dirstate results in different challenges for the raced process. We now test each variant in the `test-dirstate-status-race.t` tests.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 24 Feb 2023 01:19:37 +0100
parents ecd28d89c29e
children e30b9e43be7e
comparison
equal deleted inserted replaced
50222:ecd28d89c29e 50223:3f34d800cc69
1 ===================================================================== 1 =====================================================================
2 Check potential race conditions between a status and other operations 2 Check potential race conditions between a status and other operations
3 ===================================================================== 3 =====================================================================
4 4
5 #testcases dirstate-v1 dirstate-v2 5 #testcases dirstate-v1 dirstate-v2-append dirstate-v2-rewrite
6 6
7 The `hg status` command can run without the wlock, however it might end up 7 The `hg status` command can run without the wlock, however it might end up
8 having to update the on-disk dirstate files, for example to mark ambiguous 8 having to update the on-disk dirstate files, for example to mark ambiguous
9 files as clean, or to update directory caches information with dirstate-v2. 9 files as clean, or to update directory caches information with dirstate-v2.
10 10
28 $ cat >> $HGRCPATH << EOF 28 $ cat >> $HGRCPATH << EOF
29 > [storage] 29 > [storage]
30 > dirstate-v2.slow-path=allow 30 > dirstate-v2.slow-path=allow
31 > EOF 31 > EOF
32 32
33 #if dirstate-v2 33 #if no-dirstate-v1
34 $ cat >> $HGRCPATH << EOF 34 $ cat >> $HGRCPATH << EOF
35 > [format] 35 > [format]
36 > use-dirstate-v2=yes 36 > use-dirstate-v2=yes
37 > EOF 37 > EOF
38 #else 38 #else
39 $ cat >> $HGRCPATH << EOF 39 $ cat >> $HGRCPATH << EOF
40 > [format] 40 > [format]
41 > use-dirstate-v2=no 41 > use-dirstate-v2=no
42 > EOF 42 > EOF
43 #endif
44
45 #if dirstate-v2-rewrite
46 $ d2args="--config devel.dirstate.v2.data_update_mode=force-new"
47 #endif
48 #if dirstate-v2-append
49 $ d2args="--config devel.dirstate.v2.data_update_mode=force-append"
43 #endif 50 #endif
44 51
45 $ directories="dir dir/nested dir2" 52 $ directories="dir dir/nested dir2"
46 $ first_files="dir/nested/a dir/b dir/c dir/d dir2/e f" 53 $ first_files="dir/nested/a dir/b dir/c dir/d dir2/e f"
47 $ second_files="g dir/nested/h dir/i dir/j dir2/k dir2/l dir/nested/m" 54 $ second_files="g dir/nested/h dir/i dir/j dir2/k dir2/l dir/nested/m"
226 > & 233 > &
227 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting 234 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
228 235
229 Add a file 236 Add a file
230 237
231 $ hg add dir/n 238 $ hg $d2args add dir/n
232 $ touch $TESTTMP/status-race-lock 239 $ touch $TESTTMP/status-race-lock
233 $ wait 240 $ wait
234 241
235 The file should in a "added" state 242 The file should in a "added" state
236 243
237 $ hg status 244 $ hg status
238 A dir/n (no-rhg !) 245 A dir/n (no-rhg !)
239 A dir/n (rhg no-dirstate-v1 !) 246 A dir/n (rhg dirstate-v2-rewrite !)
240 A dir/n (missing-correct-output rhg dirstate-v1 !) 247 A dir/n (missing-correct-output rhg dirstate-v1 !)
241 A dir/o 248 A dir/o
242 R dir/nested/m 249 R dir/nested/m
243 ? dir/n (known-bad-output rhg dirstate-v1 !) 250 ? dir/n (known-bad-output rhg no-dirstate-v2-rewrite !)
244 ? p 251 ? p
245 ? q 252 ? q
246 253
247 The status process should return a consistent result and not crash. 254 The status process should return a consistent result and not crash.
248 255
251 R dir/nested/m 258 R dir/nested/m
252 ? dir/n 259 ? dir/n
253 ? p 260 ? p
254 ? q 261 ? q
255 $ cat $TESTTMP/status-race-lock.log 262 $ cat $TESTTMP/status-race-lock.log
256 abort: when writing $TESTTMP/race-with-add/.hg/dirstate.*: $ENOENT$ (glob) (known-bad-output rhg dirstate-v2 !) 263 abort: when writing $TESTTMP/race-with-add/.hg/dirstate.*: $ENOENT$ (glob) (known-bad-output rhg dirstate-v2-rewrite !)
257 264
258 final cleanup 265 final cleanup
259 266
260 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting 267 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
261 $ cd .. 268 $ cd ..
275 > & 282 > &
276 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting 283 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
277 284
278 Add a file and force the data file rewrite 285 Add a file and force the data file rewrite
279 286
280 $ hg commit -m created-during-status dir/o 287 $ hg $d2args commit -m created-during-status dir/o
281 $ touch $TESTTMP/status-race-lock 288 $ touch $TESTTMP/status-race-lock
282 $ wait 289 $ wait
283 290
284 The parent must change and the status should be clean 291 The parent must change and the status should be clean
285 292
320 R dir/nested/m 327 R dir/nested/m
321 ? dir/n 328 ? dir/n
322 ? p 329 ? p
323 ? q 330 ? q
324 $ cat $TESTTMP/status-race-lock.log 331 $ cat $TESTTMP/status-race-lock.log
325 abort: when removing $TESTTMP/race-with-commit/.hg/dirstate.*: $ENOENT$ (glob) (known-bad-output rhg dirstate-v2 !) 332 abort: when removing $TESTTMP/race-with-commit/.hg/dirstate.*: $ENOENT$ (glob) (known-bad-output rhg dirstate-v2-rewrite !)
326 333
327 final cleanup 334 final cleanup
328 335
329 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting 336 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
330 $ cd .. 337 $ cd ..
344 > & 351 > &
345 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting 352 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
346 353
347 Add a file and force the data file rewrite 354 Add a file and force the data file rewrite
348 355
349 $ hg update ".~1" 356 $ hg $d2args update ".~1"
350 0 files updated, 0 files merged, 6 files removed, 0 files unresolved 357 0 files updated, 0 files merged, 6 files removed, 0 files unresolved
351 $ touch $TESTTMP/status-race-lock 358 $ touch $TESTTMP/status-race-lock
352 $ wait 359 $ wait
353 360
354 The parent must change and the status should be clean 361 The parent must change and the status should be clean
398 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting 405 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
399 406
400 touch g 407 touch g
401 408
402 $ touch -t 200001010025 g 409 $ touch -t 200001010025 g
403 $ hg status 410 $ hg $d2args status
404 A dir/o 411 A dir/o
405 R dir/nested/m 412 R dir/nested/m
406 ? dir/n 413 ? dir/n
407 ? p 414 ? p
408 ? q 415 ? q
423 R dir/nested/m 430 R dir/nested/m
424 ? dir/n 431 ? dir/n
425 ? p 432 ? p
426 ? q 433 ? q
427 $ cat $TESTTMP/status-race-lock.log 434 $ cat $TESTTMP/status-race-lock.log
428 abort: when removing $TESTTMP/race-with-status/.hg/dirstate.*: $ENOENT$ (glob) (known-bad-output rhg dirstate-v2 !) 435 abort: when removing $TESTTMP/race-with-status/.hg/dirstate.*: $ENOENT$ (glob) (known-bad-output rhg dirstate-v2-rewrite !)
429 436
430 final cleanup 437 final cleanup
431 438
432 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting 439 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
433 $ cd .. 440 $ cd ..