##// END OF EJS Templates
dirstate: deal with read-race for pure python code...
marmoute -
r51132:a3b1ab5f stable
parent child Browse files
Show More
@@ -37,6 +37,9 b' WRITE_MODE_FORCE_NEW = 1'
37 37 WRITE_MODE_FORCE_APPEND = 2
38 38
39 39
40 V2_MAX_READ_ATTEMPTS = 5
41
42
40 43 class _dirstatemapcommon:
41 44 """
42 45 Methods that are identical for both implementations of the dirstatemap
@@ -125,6 +128,21 b' class _dirstatemapcommon:'
125 128 return self._docket
126 129
127 130 def _read_v2_data(self):
131 data = None
132 attempts = 0
133 while attempts < V2_MAX_READ_ATTEMPTS:
134 attempts += 1
135 try:
136 data = self._opener.read(self.docket.data_filename())
137 except FileNotFoundError:
138 # read race detected between docket and data file
139 # reload the docket and retry
140 self._docket = None
141 if data is None:
142 assert attempts >= V2_MAX_READ_ATTEMPTS
143 msg = b"dirstate read race happened %d times in a row"
144 msg %= attempts
145 raise error.Abort(msg)
128 146 return self._opener.read(self.docket.data_filename())
129 147
130 148 def write_v2_no_append(self, tr, st, meta, packed):
@@ -217,8 +217,12 b' The status process should return a consi'
217 217 #endif
218 218 #else
219 219 $ cat $TESTTMP/status-race-lock.out
220 A dir/n
221 A dir/o
222 R dir/nested/m
223 ? p
224 ? q
220 225 $ cat $TESTTMP/status-race-lock.log
221 abort: $ENOENT$: '$TESTTMP/race-with-add/.hg/dirstate.* (glob)
222 226 #endif
223 227 #endif
224 228 #endif
@@ -318,8 +322,12 b' The status process should return a consi'
318 322 #endif
319 323 #else
320 324 $ cat $TESTTMP/status-race-lock.out
325 M dir/o
326 ? dir/n
327 ? p
328 ? q
321 329 $ cat $TESTTMP/status-race-lock.log
322 abort: $ENOENT$: '$TESTTMP/race-with-commit/.hg/dirstate.* (glob)
330 warning: ignoring unknown working parent 02a67a77ee9b!
323 331 #endif
324 332 #endif
325 333 #endif
@@ -452,8 +460,11 b' The status process should return a consi'
452 460 #endif
453 461 #else
454 462 $ cat $TESTTMP/status-race-lock.out
463 A dir/o
464 ? dir/n
465 ? p
466 ? q
455 467 $ cat $TESTTMP/status-race-lock.log
456 abort: $ENOENT$: '$TESTTMP/race-with-update/.hg/dirstate.* (glob)
457 468 #endif
458 469 #endif
459 470 #endif
@@ -542,8 +553,12 b' The status process should return a consi'
542 553 #endif
543 554 #else
544 555 $ cat $TESTTMP/status-race-lock.out
556 A dir/o
557 R dir/nested/m
558 ? dir/n
559 ? p
560 ? q
545 561 $ cat $TESTTMP/status-race-lock.log
546 abort: $ENOENT$: '$TESTTMP/race-with-status/.hg/dirstate.* (glob)
547 562 #endif
548 563 #endif
549 564 #endif
General Comments 0
You need to be logged in to leave comments. Login now