Show More
@@ -1,198 +1,253 | |||
|
1 | 1 | ============================================================================== |
|
2 | 2 | Check potential race conditions between a dirstate's read and other operations |
|
3 | 3 | ============================================================================== |
|
4 | 4 | |
|
5 | 5 | Some commands, like `hg status`, do not need to take the wlock but need to |
|
6 | 6 | access dirstate data. |
|
7 | 7 | Other commands might update the dirstate data while this happens. |
|
8 | 8 | |
|
9 | 9 | This can create issues if repository data is read in the wrong order, or for |
|
10 | 10 | the dirstate-v2 format where the data is contained in multiple files. |
|
11 | 11 | |
|
12 | 12 | This test file is meant to test various cases where such parallel operations |
|
13 | 13 | happen and make sure the reading process behaves fine. We do so with a `hg |
|
14 | 14 | status` command since it is probably the most advanced of such read-only |
|
15 | 15 | command. |
|
16 | 16 | |
|
17 | 17 | It bears simililarity with `tests/test-dirstate-status-race.t ` but tests a |
|
18 | 18 | different type of race. |
|
19 | 19 | |
|
20 | 20 | Setup |
|
21 | 21 | ===== |
|
22 | 22 | |
|
23 | 23 | $ directories="dir dir/nested dir2" |
|
24 | 24 | $ first_files="dir/nested/a dir/b dir/c dir/d dir2/e f" |
|
25 | 25 | $ second_files="g dir/nested/h dir/i dir/j dir2/k dir2/l dir/nested/m" |
|
26 | 26 | $ extra_files="dir/n dir/o p q" |
|
27 | 27 | |
|
28 | 28 | $ hg init reference-repo |
|
29 | 29 | $ cd reference-repo |
|
30 | 30 | $ mkdir -p dir/nested dir2 |
|
31 | 31 | $ touch -t 200001010000 $first_files $directories |
|
32 | 32 | $ hg commit -Aqm "recreate a bunch of files to facilitate dirstate-v2 append" |
|
33 | 33 | $ touch -t 200001010010 $second_files $directories |
|
34 | 34 | $ hg commit -Aqm "more files to have two commit" |
|
35 | 35 | $ hg log -G -v |
|
36 | 36 | @ changeset: 1:9a86dcbfb938 |
|
37 | 37 | | tag: tip |
|
38 | 38 | | user: test |
|
39 | 39 | | date: Thu Jan 01 00:00:00 1970 +0000 |
|
40 | 40 | | files: dir/i dir/j dir/nested/h dir/nested/m dir2/k dir2/l g |
|
41 | 41 | | description: |
|
42 | 42 | | more files to have two commit |
|
43 | 43 | | |
|
44 | 44 | | |
|
45 | 45 | o changeset: 0:4f23db756b09 |
|
46 | 46 | user: test |
|
47 | 47 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
48 | 48 | files: dir/b dir/c dir/d dir/nested/a dir2/e f |
|
49 | 49 | description: |
|
50 | 50 | recreate a bunch of files to facilitate dirstate-v2 append |
|
51 | 51 | |
|
52 | 52 | |
|
53 | 53 | $ hg manifest |
|
54 | 54 | dir/b |
|
55 | 55 | dir/c |
|
56 | 56 | dir/d |
|
57 | 57 | dir/i |
|
58 | 58 | dir/j |
|
59 | 59 | dir/nested/a |
|
60 | 60 | dir/nested/h |
|
61 | 61 | dir/nested/m |
|
62 | 62 | dir2/e |
|
63 | 63 | dir2/k |
|
64 | 64 | dir2/l |
|
65 | 65 | f |
|
66 | 66 | g |
|
67 | 67 | |
|
68 | 68 | Add some unknown files and refresh the dirstate |
|
69 | 69 | |
|
70 | 70 | $ touch -t 200001010020 $extra_files |
|
71 | 71 | $ hg add dir/o |
|
72 | 72 | $ hg remove dir/nested/m |
|
73 | 73 | |
|
74 | 74 | $ hg st --config devel.dirstate.v2.data_update_mode=force-new |
|
75 | 75 | A dir/o |
|
76 | 76 | R dir/nested/m |
|
77 | 77 | ? dir/n |
|
78 | 78 | ? p |
|
79 | 79 | ? q |
|
80 | 80 | $ hg debugstate |
|
81 | 81 | n 644 0 2000-01-01 00:00:00 dir/b |
|
82 | 82 | n 644 0 2000-01-01 00:00:00 dir/c |
|
83 | 83 | n 644 0 2000-01-01 00:00:00 dir/d |
|
84 | 84 | n 644 0 2000-01-01 00:10:00 dir/i |
|
85 | 85 | n 644 0 2000-01-01 00:10:00 dir/j |
|
86 | 86 | n 644 0 2000-01-01 00:00:00 dir/nested/a |
|
87 | 87 | n 644 0 2000-01-01 00:10:00 dir/nested/h |
|
88 | 88 | r ?????????????????????????????????? dir/nested/m (glob) |
|
89 | 89 | a ?????????????????????????????????? dir/o (glob) |
|
90 | 90 | n 644 0 2000-01-01 00:00:00 dir2/e |
|
91 | 91 | n 644 0 2000-01-01 00:10:00 dir2/k |
|
92 | 92 | n 644 0 2000-01-01 00:10:00 dir2/l |
|
93 | 93 | n 644 0 2000-01-01 00:00:00 f |
|
94 | 94 | n 644 0 2000-01-01 00:10:00 g |
|
95 | 95 | $ hg debugstate > ../reference |
|
96 | 96 | $ cd .. |
|
97 | 97 | |
|
98 | 98 | Actual Testing |
|
99 | 99 | ============== |
|
100 | 100 | |
|
101 | 101 | Race with a `hg add` |
|
102 | 102 | ------------------- |
|
103 | 103 | |
|
104 | 104 | $ cp -a reference-repo race-with-add |
|
105 | 105 | $ cd race-with-add |
|
106 | 106 | |
|
107 | 107 | spin a `hg status` with some caches to update |
|
108 | 108 | |
|
109 | 109 | $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \ |
|
110 | 110 | > --config rhg.on-unsupported=abort \ |
|
111 | 111 | > --config devel.sync.dirstate.pre-read-file=$TESTTMP/status-race-lock \ |
|
112 | 112 | > & |
|
113 | 113 | $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting |
|
114 | 114 | |
|
115 | 115 | Add a file |
|
116 | 116 | |
|
117 | 117 | $ hg add dir/n $d2args |
|
118 | 118 | $ touch $TESTTMP/status-race-lock |
|
119 | 119 | $ wait |
|
120 | 120 | |
|
121 | 121 | The file should in a "added" state |
|
122 | 122 | |
|
123 | 123 | $ hg status |
|
124 | 124 | A dir/n |
|
125 | 125 | A dir/o |
|
126 | 126 | R dir/nested/m |
|
127 | 127 | ? p |
|
128 | 128 | ? q |
|
129 | 129 | |
|
130 | 130 | The status process should return a consistent result and not crash. |
|
131 | 131 | |
|
132 | 132 | $ cat $TESTTMP/status-race-lock.out |
|
133 | 133 | A dir/n |
|
134 | 134 | A dir/o |
|
135 | 135 | R dir/nested/m |
|
136 | 136 | ? p |
|
137 | 137 | ? q |
|
138 | 138 | $ cat $TESTTMP/status-race-lock.log |
|
139 | 139 | |
|
140 | 140 | final cleanup |
|
141 | 141 | |
|
142 | 142 | $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting |
|
143 | 143 | $ cd .. |
|
144 | 144 | |
|
145 | 145 | Race with a `hg commit` |
|
146 | 146 | ----------------------- |
|
147 | 147 | |
|
148 | 148 | $ cp -a reference-repo race-with-commit |
|
149 | 149 | $ cd race-with-commit |
|
150 | 150 | |
|
151 | 151 | spin a `hg status with some cache to update |
|
152 | 152 | |
|
153 | 153 | $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \ |
|
154 | 154 | > --config rhg.on-unsupported=abort \ |
|
155 | 155 | > --config devel.sync.dirstate.pre-read-file=$TESTTMP/status-race-lock \ |
|
156 | 156 | > & |
|
157 | 157 | $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting |
|
158 | 158 | |
|
159 | 159 | Add a do a commit |
|
160 | 160 | |
|
161 | 161 | $ hg status |
|
162 | 162 | A dir/o |
|
163 | 163 | R dir/nested/m |
|
164 | 164 | ? dir/n |
|
165 | 165 | ? p |
|
166 | 166 | ? q |
|
167 | 167 | $ hg commit -m 'racing commit' |
|
168 | 168 | $ touch $TESTTMP/status-race-lock |
|
169 | 169 | $ wait |
|
170 | 170 | |
|
171 | 171 | commit was created, and status is now clean |
|
172 | 172 | |
|
173 | 173 | $ hg log -GT '{node|short} {desc}\n' |
|
174 | 174 | @ 02a67a77ee9b racing commit |
|
175 | 175 | | |
|
176 | 176 | o 9a86dcbfb938 more files to have two commit |
|
177 | 177 | | |
|
178 | 178 | o 4f23db756b09 recreate a bunch of files to facilitate dirstate-v2 append |
|
179 | 179 | |
|
180 | 180 | $ hg status |
|
181 | 181 | ? dir/n |
|
182 | 182 | ? p |
|
183 | 183 | ? q |
|
184 | 184 | |
|
185 | 185 | The status process should return a consistent result and not crash. |
|
186 | 186 | |
|
187 | 187 | $ cat $TESTTMP/status-race-lock.out |
|
188 | 188 | M dir/o (known-bad-output no-rhg !) |
|
189 | 189 | ? dir/n |
|
190 | 190 | ? p |
|
191 | 191 | ? q |
|
192 | 192 | $ cat $TESTTMP/status-race-lock.log |
|
193 | 193 | warning: ignoring unknown working parent 02a67a77ee9b! (known-bad-output no-rhg !) |
|
194 | 194 | |
|
195 | 195 | final cleanup |
|
196 | 196 | |
|
197 | 197 | $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting |
|
198 | 198 | $ cd .. |
|
199 | ||
|
200 | Race with a `hg update` | |
|
201 | ----------------------- | |
|
202 | ||
|
203 | $ cp -a reference-repo race-with-update | |
|
204 | $ cd race-with-update | |
|
205 | ||
|
206 | spin a `hg status` with some caches to update | |
|
207 | ||
|
208 | $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \ | |
|
209 | > --config rhg.on-unsupported=abort \ | |
|
210 | > --config devel.sync.dirstate.pre-read-file=$TESTTMP/status-race-lock \ | |
|
211 | > & | |
|
212 | $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting | |
|
213 | do an update | |
|
214 | ||
|
215 | $ hg status | |
|
216 | A dir/o | |
|
217 | R dir/nested/m | |
|
218 | ? dir/n | |
|
219 | ? p | |
|
220 | ? q | |
|
221 | $ hg log -GT '{node|short} {desc}\n' | |
|
222 | @ 9a86dcbfb938 more files to have two commit | |
|
223 | | | |
|
224 | o 4f23db756b09 recreate a bunch of files to facilitate dirstate-v2 append | |
|
225 | ||
|
226 | $ hg update --merge .^ | |
|
227 | 0 files updated, 0 files merged, 6 files removed, 0 files unresolved | |
|
228 | $ touch $TESTTMP/status-race-lock | |
|
229 | $ wait | |
|
230 | $ hg log -GT '{node|short} {desc}\n' | |
|
231 | o 9a86dcbfb938 more files to have two commit | |
|
232 | | | |
|
233 | @ 4f23db756b09 recreate a bunch of files to facilitate dirstate-v2 append | |
|
234 | ||
|
235 | $ hg status | |
|
236 | A dir/o | |
|
237 | ? dir/n | |
|
238 | ? p | |
|
239 | ? q | |
|
240 | ||
|
241 | The status process should return a consistent result and not crash. | |
|
242 | ||
|
243 | $ cat $TESTTMP/status-race-lock.out | |
|
244 | A dir/o | |
|
245 | ? dir/n | |
|
246 | ? p | |
|
247 | ? q | |
|
248 | $ cat $TESTTMP/status-race-lock.log | |
|
249 | ||
|
250 | final cleanup | |
|
251 | ||
|
252 | $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting | |
|
253 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now