darcs

Issue 2705 intermittent bad index in "rebase-amend" test

Title intermittent bad index in "rebase-amend" test
Priority Status unknown
Milestone Resolved in
Superseder Nosy List ganesh
Assigned To
Topics

Created on 2023-06-21.00:59:14 by ganesh, last changed 2023-07-01.22:24:53 by ganesh.

Files
File name Uploaded Type Edit Remove
debugging-issue2705.dpatch ganesh, 2023-07-01.22:24:52 application/octet-stream
Messages
msg23338 (view) Author: ganesh Date: 2023-06-21.00:59:12
Using current 'reviewed', I'm seeing intermittent failures in the
'rebase-amend' test.

I tracked them down to this patch:

> * enable use of the index in the test suite by default

in http://bugs.darcs.net/patch2133

This has been accepted for quite a while, but I got a new laptop
fairly recently, and the failure is that 'darcs check'
intermittently reports a bad index, so it seems likely
to be timing related.
msg23341 (view) Author: ganesh Date: 2023-06-21.08:04:48
http://bugs.darcs.net/patch2319 appears to fix this for me but
I'm not really sure why it's needed for this specific test but
not others.
msg23352 (view) Author: ganesh Date: 2023-06-22.08:49:23
Log of failing test (it's not darcs-3 specific)

rebase-amend (Darcs3,Patience,WithIndex,WithCache): [Failed]
|
| rm -rf R
| + rm -rf R
| mkdir R
| + mkdir R
| cd R
| + cd R
| darcs init
| + darcs init
| ============================= WARNING =============================
| The `darcs-3` semantics is EXPERIMENTAL and new in version 2.16. It is included
| only as a technology preview and we do NOT recommend to use it for any serious
| work. The on-disk format is not yet finalized and we cannot and will not promise
| that later releases will work with darcs-3 repos created with any darcs version
| before 3.0.
| ===================================================================
| Getting pristine ... done
|
| echo 'wibble' > wibble
| + echo wibble
| darcs rec -lam 'wibble'
| + darcs rec -lam wibble
| Updating the index ... done
| Writing inventory ... done
| Updating the index ... done
| Defining set of chosen patches ... done
|
| echo 'wobble' > wibble
| + echo wobble
| darcs rec -am 'wobble'
| + darcs rec -am wobble
| Updating the index ... done
| Writing inventory ... done
| Updating the index ... done
| Defining set of chosen patches ... done
|
| echo 'yd' | darcs rebase suspend
| + echo yd
| + darcs rebase suspend
| Updating the index ... done
| Writing inventory ... done
| Updating the index ... done
| Writing inventory ... done
| Updating the index ... done
| Rebase in progress: 1 suspended patch
|
| echo 'wubble' > wibble
| + echo wubble
| echo 'ya' | darcs amend-record
| + echo ya
| + darcs amend-record
| Updating the index ... done
| Rebase in progress: 1 suspended patch
|
| darcs check
| + darcs check
| Replaying patch ... done
| Updating the index ... done
| Rebase in progress: 1 suspended patch
msg23353 (view) Author: ganesh Date: 2023-06-22.08:50:09
Rerunning darcs check manually on the test dir:

ganesh@abbey:~/temp/t1/Darcs3/Patience/WithIndex/WithCache/rebase-
amend/R$ ~/darcs/reviewed/dist-newstyle/build/x86_64-linux/ghc-
9.0.2/darcs-2.17.2/build/darcs/darcs check
Hash mismatch(es)!
wibble
    index: 
8f8c9b8df39f8c8be4a39378bece4ac01cba948f9b4ef7b90acad3f49d5358f2
  working: 
e9fc4666e21d1535858a4694131ff40482e2b1293cc833422946d73e8388fd18

Bad index.
Rebase in progress: 1 suspended patch
msg23354 (view) Author: ganesh Date: 2023-06-22.08:50:41
Index from broken repo:

ganesh@abbey:~/temp/t1/Darcs3/Patience/WithIndex/WithCache/rebase-
amend/R$ ~/darcs/reviewed/dist-newstyle/build/x86_64-linux/ghc-
9.0.2/darcs-2.17.2/build/darcs/darcs show index
HASH                                                             T         
SIZE                  AUX       FILEID PATH
34fa4295f0ebbd09925de393b817453f7ebabd587df3adbbf5def571a1a0faf4 D            
0                  140       465837 .
8f8c9b8df39f8c8be4a39378bece4ac01cba948f9b4ef7b90acad3f49d5358f2 F            
7  1687423722346814330       465881 wibble
msg23356 (view) Author: ganesh Date: 2023-06-22.10:19:25
ganesh@abbey:~/temp/t1/Darcs3/Patience/WithIndex/WithCache/rebase-amend/R$ cd _darcs/
ganesh@abbey:~/temp/t1/Darcs3/Patience/WithIndex/WithCache/rebase-amend/R/_darcs$ mv index index.new
ganesh@abbey:~/temp/t1/Darcs3/Patience/WithIndex/WithCache/rebase-amend/R/_darcs$ mv index.old index
ganesh@abbey:~/temp/t1/Darcs3/Patience/WithIndex/WithCache/rebase-amend/R/_darcs$ cd ..
ganesh@abbey:~/temp/t1/Darcs3/Patience/WithIndex/WithCache/rebase-amend/R$ ~/darcs/reviewed/dist-
newstyle/build/x86_64-linux/ghc-9.0.2/darcs-2.17.2/build/darcs/darcs show index
HASH                                                             T         SIZE                  AUX       
FILEID PATH
34fa4295f0ebbd09925de393b817453f7ebabd587df3adbbf5def571a1a0faf4 D            0                  140       
465837 .
8f8c9b8df39f8c8be4a39378bece4ac01cba948f9b4ef7b90acad3f49d5358f2 F            7  1687423722346814330       
465847 wibble
Rebase in progress: 1 suspended patch
ganesh@abbey:~/temp/t1/Darcs3/Patience/WithIndex/WithCache/rebase-amend/R$ ~/darcs/reviewed/dist-
newstyle/build/x86_64-linux/ghc-9.0.2/darcs-2.17.2/build/darcs/darcs check
Hash mismatch(es)!
wibble
    index: 8f8c9b8df39f8c8be4a39378bece4ac01cba948f9b4ef7b90acad3f49d5358f2
  working: e9fc4666e21d1535858a4694131ff40482e2b1293cc833422946d73e8388fd18

Bad index.
Rebase in progress: 1 suspended patch
msg23360 (view) Author: bfrk Date: 2023-06-23.23:16:17
Copied over from patch2319:

The issue seems to be fixed by this patch (in screened):

    patch 9af249013964d18a07dcf371a258b58e771e27d2
    Author: Ben Franksen <ben.franksen@online.de>
    Date:   Sun Feb 26 21:43:17 GMT 2023
      * rebase: take applyToWorking out of doSuspend

What this does is to "normalize" how we treat changes to the working 
tree when we suspend patches: the standard way is to first finalize the 
"internal" repo changes (i.e. update inventory and pristine tree), then 
afterwards apply changes to the working tree. Whereas before this patch, we 
changed working inside doSuspend, and finalized afterwards.

Note that finalizeRepositoryChanges also updates the index. It seems that when 
we first change the working tree and then update the index, it can (depending on 
timing) happen that we update the index with an outdated hash; but it is still 
unclear how and why exactly.
msg23482 (view) Author: ganesh Date: 2023-07-01.22:24:52
I've done a bit more narrowing down of the problem. It seems
that just swapping the order of `applyToWorking` and 
`finalizeRepositoryChanges` in `doSuspend` is enough to trigger it.

The attached bundle has three patches:
- A tag 'baseline' which is a subset of screened where everything is 
fine. It's a subset to avoid conflicts in patch.
- A patch "debugging issue2705" which is enough, on its own, to break 
the test. I made it by rolling back "rebase: take applyToWorking out of 
doSuspend" and then simplifying.
- A patch "scripting failure" that makes it a bit easier for me to check 
whether a state is broken or not.
Attachments
History
Date User Action Args
2023-06-21 00:59:14ganeshcreate
2023-06-21 08:04:48ganeshsetmessages: + msg23341
2023-06-22 08:49:24ganeshsetmessages: + msg23352
2023-06-22 08:50:09ganeshsetmessages: + msg23353
2023-06-22 08:50:41ganeshsetmessages: + msg23354
2023-06-22 10:19:25ganeshsetmessages: + msg23356
2023-06-23 23:16:18bfrksetmessages: + msg23360
2023-07-01 22:24:53ganeshsetfiles: + debugging-issue2705.dpatch
messages: + msg23482