comparison tests/test-clone-stream-revlog-split.t @ 50626:9b0fe2b075b5

stream-clone: add a test that highlight crash on revlog splitting This has been a long running problem, we should have a tests for it.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 29 May 2023 02:22:20 +0200
parents
children 9caa860dcbec
comparison
equal deleted inserted replaced
50625:1a554956af84 50626:9b0fe2b075b5
1 Test stream cloning while a revlog split happens
2 ------------------------------------------------
3
4 #testcases stream-bundle2-v2 stream-bundle2-v3
5
6 #if stream-bundle2-v3
7 $ cat << EOF >> $HGRCPATH
8 > [experimental]
9 > stream-v3 = yes
10 > EOF
11 #endif
12
13 setup a repository for tests
14 ----------------------------
15
16 $ cat >> $HGRCPATH << EOF
17 > [format]
18 > # skip compression to make it easy to trigger a split
19 > revlog-compression=none
20 > EOF
21
22 $ hg init server
23 $ cd server
24 $ file="some-file"
25 $ printf '%20d' '1' > $file
26 $ hg commit -Aqma
27 $ printf '%1024d' '1' > $file
28 $ hg commit -Aqmb
29 $ printf '%20d' '1' > $file
30 $ hg commit -Aqmc
31
32 check the revlog is inline
33
34 $ f -s .hg/store/data/some-file*
35 .hg/store/data/some-file.i: size=1259
36 $ hg debug-revlog-index some-file
37 rev linkrev nodeid p1-nodeid p2-nodeid
38 0 0 ed70cecbc103 000000000000 000000000000
39 1 1 7241018db64c ed70cecbc103 000000000000
40 2 2 fa1120531cc1 7241018db64c 000000000000
41 $ cd ..
42
43 setup synchronisation file
44
45 $ HG_TEST_STREAM_WALKED_FILE_1="$TESTTMP/sync_file_walked_1"
46 $ export HG_TEST_STREAM_WALKED_FILE_1
47 $ HG_TEST_STREAM_WALKED_FILE_2="$TESTTMP/sync_file_walked_2"
48 $ export HG_TEST_STREAM_WALKED_FILE_2
49 $ HG_TEST_STREAM_WALKED_FILE_3="$TESTTMP/sync_file_walked_3"
50 $ export HG_TEST_STREAM_WALKED_FILE_3
51
52
53 Test stream-clone raced by a revlog-split
54 =========================================
55
56 Test stream-clone where the file is split right after the lock section is done
57
58 Start the server
59
60 $ hg serve -R server \
61 > -p $HGPORT1 -d --error errors.log --pid-file=hg.pid \
62 > --config extensions.stream_steps="$RUNTESTDIR/testlib/ext-stream-clone-steps.py"
63 $ cat hg.pid >> $DAEMON_PIDS
64
65 Start a client doing a streaming clone
66
67 $ (hg clone -q --stream -U http://localhost:$HGPORT1 clone-while-split > client.log 2>&1; touch "$HG_TEST_STREAM_WALKED_FILE_3") &
68
69 Wait for the server to be done collecting data
70
71 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_1
72
73 trigger a split
74
75 $ dd if=/dev/zero of=server/$file bs=1k count=128 > /dev/null 2>&1
76 $ hg -R server ci -m "triggering a split" --config ui.timeout.warn=-1
77
78 unlock the stream generation
79
80 $ touch $HG_TEST_STREAM_WALKED_FILE_2
81
82 wait for the client to be done cloning.
83
84 $ $RUNTESTDIR/testlib/wait-on-file 10 $HG_TEST_STREAM_WALKED_FILE_3
85
86 Check everything is fine
87
88 $ cat client.log
89 remote: abort: unexpected error: clone could only read 256 bytes from data/some-file.i, but expected 1259 bytes (known-bad-output !)
90 abort: pull failed on remote (known-bad-output !)
91 $ tail -2 errors.log
92 mercurial.error.Abort: clone could only read 256 bytes from data/some-file.i, but expected 1259 bytes (known-bad-output !)
93 (known-bad-output !)
94 $ hg -R clone-while-split verify
95 checking changesets (missing-correct-output !)
96 checking manifests (missing-correct-output !)
97 crosschecking files in changesets and manifests (missing-correct-output !)
98 checking files (missing-correct-output !)
99 checking dirstate (missing-correct-output !)
100 checked 3 changesets with 3 changes to 1 files (missing-correct-output !)
101 abort: repository clone-while-split not found (known-bad-output !)
102 [255]
103 $ hg -R clone-while-split tip
104 changeset: 2:dbd9854c38a6 (missing-correct-output !)
105 tag: tip (missing-correct-output !)
106 user: test (missing-correct-output !)
107 date: Thu Jan 01 00:00:00 1970 +0000 (missing-correct-output !)
108 summary: c (missing-correct-output !)
109 (missing-correct-output !)
110 abort: repository clone-while-split not found (known-bad-output !)
111 [255]
112 $ hg -R clone-while-split debug-revlog-index some-file
113 rev linkrev nodeid p1-nodeid p2-nodeid (missing-correct-output !)
114 0 0 ed70cecbc103 000000000000 000000000000 (missing-correct-output !)
115 1 1 7241018db64c ed70cecbc103 000000000000 (missing-correct-output !)
116 2 2 fa1120531cc1 7241018db64c 000000000000 (missing-correct-output !)
117 abort: repository clone-while-split not found (known-bad-output !)
118 [255]
119
120 subsequent pull work
121
122 $ hg -R clone-while-split pull
123 pulling from http://localhost:$HGPORT1/ (missing-correct-output !)
124 searching for changes (missing-correct-output !)
125 adding changesets (missing-correct-output !)
126 adding manifests (missing-correct-output !)
127 adding file changes (missing-correct-output !)
128 added 1 changesets with 1 changes to 1 files (missing-correct-output !)
129 new changesets df05c6cb1406 (missing-correct-output !)
130 (run 'hg update' to get a working copy) (missing-correct-output !)
131 abort: repository clone-while-split not found (known-bad-output !)
132 [255]
133
134 $ hg -R clone-while-split debug-revlog-index some-file
135 rev linkrev nodeid p1-nodeid p2-nodeid (missing-correct-output !)
136 0 0 ed70cecbc103 000000000000 000000000000 (missing-correct-output !)
137 1 1 7241018db64c ed70cecbc103 000000000000 (missing-correct-output !)
138 2 2 fa1120531cc1 7241018db64c 000000000000 (missing-correct-output !)
139 3 3 a631378adaa3 fa1120531cc1 000000000000 (missing-correct-output !)
140 abort: repository clone-while-split not found (known-bad-output !)
141 [255]
142 $ hg -R clone-while-split verify
143 checking changesets (missing-correct-output !)
144 checking manifests (missing-correct-output !)
145 crosschecking files in changesets and manifests (missing-correct-output !)
146 checking files (missing-correct-output !)
147 checking dirstate (missing-correct-output !)
148 checked 4 changesets with 4 changes to 1 files (missing-correct-output !)
149 abort: repository clone-while-split not found (known-bad-output !)
150 [255]