##// END OF EJS Templates
revlog: demonstrate a bug where transaction can be aborted partially...
Arseniy Alekseyev -
r49422:f38ae2d7 stable
parent child Browse files
Show More
@@ -1,172 +1,194 b''
1 Test correctness of revlog inline -> non-inline transition
1 Test correctness of revlog inline -> non-inline transition
2 ----------------------------------------------------------
2 ----------------------------------------------------------
3
3
4 Helper extension to intercept renames.
4 Helper extension to intercept renames.
5
5
6 $ cat > $TESTTMP/intercept_rename.py << EOF
6 $ cat > $TESTTMP/intercept_rename.py << EOF
7 > import os
7 > import os
8 > import sys
8 > import sys
9 > from mercurial import extensions, util
9 > from mercurial import extensions, util
10 >
10 >
11 > def extsetup(ui):
11 > def extsetup(ui):
12 > def close(orig, *args, **kwargs):
12 > def close(orig, *args, **kwargs):
13 > path = util.normpath(args[0]._atomictempfile__name)
13 > path = util.normpath(args[0]._atomictempfile__name)
14 > if path.endswith(b'/.hg/store/data/file.i'):
14 > if path.endswith(b'/.hg/store/data/file.i'):
15 > os._exit(80)
15 > os._exit(80)
16 > return orig(*args, **kwargs)
16 > return orig(*args, **kwargs)
17 > extensions.wrapfunction(util.atomictempfile, 'close', close)
17 > extensions.wrapfunction(util.atomictempfile, 'close', close)
18 > EOF
18 > EOF
19
19
20 Test offset computation to correctly factor in the index entries themselve.
20 Test offset computation to correctly factor in the index entries themselves.
21 Also test that the new data size has the correct size if the transaction is aborted
21 Also test that the new data size has the correct size if the transaction is aborted
22 after the index has been replaced.
22 after the index has been replaced.
23
23
24 Test repo has one small, one moderate and one big change. The clone has
24 Test repo has commits a, b, c, D, where D is large (grows the revlog enough that it
25 the small and moderate change and will transition to non-inline storage when
25 transitions to non-inline storage). The clone initially has changes a, b
26 adding the big change.
26 and will transition to non-inline storage when adding c, D.
27
28 If the transaction adding c, D is rolled back, then we don't undo the revlog split,
29 but truncate the index and the data to remove both c and D.
27
30
28 $ hg init troffset-computation --config format.revlog-compression=none
31 $ hg init troffset-computation --config format.revlog-compression=none
29 $ cd troffset-computation
32 $ cd troffset-computation
30 $ printf '%20d' '1' > file
33 $ printf '%20d' '1' > file
31 $ hg commit -Aqm_
34 $ hg commit -Aqma
32 $ printf '%1024d' '1' > file
35 $ printf '%1024d' '1' > file
33 $ hg commit -Aqm_
36 $ hg commit -Aqmb
37 $ printf '%20d' '1' > file
38 $ hg commit -Aqmc
34 $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1
39 $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1
35 $ hg commit -Aqm_
40 $ hg commit -AqmD
41
36 $ cd ..
42 $ cd ..
37
43
38 $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q
44 $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q
39 $ cd troffset-computation-copy
45 $ cd troffset-computation-copy
40
46
41 Reference size:
47 Reference size:
42
48
43 $ f -s .hg/store/data/file*
49 $ f -s .hg/store/data/file*
44 .hg/store/data/file.i: size=1174
50 .hg/store/data/file.i: size=1174
45
51
46 $ cat > .hg/hgrc <<EOF
52 $ cat > .hg/hgrc <<EOF
47 > [hooks]
53 > [hooks]
48 > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
54 > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
49 > EOF
55 > EOF
50 #if chg
56 #if chg
51 $ hg pull ../troffset-computation
57 $ hg pull ../troffset-computation
52 pulling from ../troffset-computation
58 pulling from ../troffset-computation
53 [255]
59 [255]
54 #else
60 #else
55 $ hg pull ../troffset-computation
61 $ hg pull ../troffset-computation
56 pulling from ../troffset-computation
62 pulling from ../troffset-computation
57 [80]
63 [80]
58 #endif
64 #endif
59 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1
65 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1
60 data/file.i 128
66 data/file.i 192
61
67
62 The first file.i entry should match the size above.
68 The first file.i entry should match the "Reference size" above.
63 The first file.d entry is the temporary record during the split,
69 The first file.d entry is the temporary record during the split,
64 the second entry after the split happened. The sum of the second file.d
70 the second entry after the split happened. The sum of the second file.d
65 and the second file.i entry should match the first file.i entry.
71 and the second file.i entry should match the first file.i entry.
66
72
67 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
73 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
68 data/file.i 1174
74 data/file.i 1174
69 data/file.d 0
75 data/file.d 0
70 data/file.d 1046
76 data/file.d 1067
71 data/file.i 128
77 data/file.i 192
72 $ hg recover
78 $ hg recover
73 rolling back interrupted transaction
79 rolling back interrupted transaction
74 (verify step skipped, run `hg verify` to check your repository content)
80 (verify step skipped, run `hg verify` to check your repository content)
75 $ f -s .hg/store/data/file*
81 $ f -s .hg/store/data/file*
76 .hg/store/data/file.d: size=1046
82 .hg/store/data/file.d: size=1067
77 .hg/store/data/file.i: size=128
83 .hg/store/data/file.i: size=192
78 $ hg tip
84 $ hg tip
79 changeset: 1:3ce491143aec
85 changeset: 1:cfa8d6e60429
80 tag: tip
86 tag: tip
81 user: test
87 user: test
82 date: Thu Jan 01 00:00:00 1970 +0000
88 date: Thu Jan 01 00:00:00 1970 +0000
83 summary: _
89 summary: b
84
90
85 $ hg verify -q
91 $ hg verify -q
86 warning: revlog 'data/file.d' not in fncache!
92 warning: revlog 'data/file.d' not in fncache!
87 1 warnings encountered!
93 file@?: rev 2 points to nonexistent changeset 2
94 (expected )
95 file@?: fa1120531cc1 not in manifests
96 2 warnings encountered!
88 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
97 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
98 2 integrity errors encountered!
99 [1]
89 $ hg debugrebuildfncache --only-data
100 $ hg debugrebuildfncache --only-data
90 adding data/file.d
101 adding data/file.d
91 1 items added, 0 removed from fncache
102 1 items added, 0 removed from fncache
92 $ hg verify -q
103 $ hg verify -q
104 file@?: rev 2 points to nonexistent changeset 2
105 (expected )
106 file@?: fa1120531cc1 not in manifests
107 1 warnings encountered!
108 2 integrity errors encountered!
109 [1]
93 $ cd ..
110 $ cd ..
94
111
95
112
96 Now retry the procedure but intercept the rename of the index and check that
113 Now retry the procedure but intercept the rename of the index and check that
97 the journal does not contain the new index size. This demonstrates the edge case
114 the journal does not contain the new index size. This demonstrates the edge case
98 where the data file is left as garbage.
115 where the data file is left as garbage.
99
116
100 $ hg clone -r 1 troffset-computation troffset-computation-copy2 --config format.revlog-compression=none -q
117 $ hg clone -r 1 troffset-computation troffset-computation-copy2 --config format.revlog-compression=none -q
101 $ cd troffset-computation-copy2
118 $ cd troffset-computation-copy2
102 $ cat > .hg/hgrc <<EOF
119 $ cat > .hg/hgrc <<EOF
103 > [extensions]
120 > [extensions]
104 > intercept_rename = $TESTTMP/intercept_rename.py
121 > intercept_rename = $TESTTMP/intercept_rename.py
105 > [hooks]
122 > [hooks]
106 > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
123 > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
107 > EOF
124 > EOF
108 #if chg
125 #if chg
109 $ hg pull ../troffset-computation
126 $ hg pull ../troffset-computation
110 pulling from ../troffset-computation
127 pulling from ../troffset-computation
111 [255]
128 [255]
112 #else
129 #else
113 $ hg pull ../troffset-computation
130 $ hg pull ../troffset-computation
114 pulling from ../troffset-computation
131 pulling from ../troffset-computation
115 [80]
132 [80]
116 #endif
133 #endif
117 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
134 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
118 data/file.i 1174
135 data/file.i 1174
119 data/file.d 0
136 data/file.d 0
120 data/file.d 1046
137 data/file.d 1067
121
138
122 $ hg recover
139 $ hg recover
123 rolling back interrupted transaction
140 rolling back interrupted transaction
124 (verify step skipped, run `hg verify` to check your repository content)
141 (verify step skipped, run `hg verify` to check your repository content)
125 $ f -s .hg/store/data/file*
142 $ f -s .hg/store/data/file*
126 .hg/store/data/file.d: size=1046
143 .hg/store/data/file.d: size=1067
127 .hg/store/data/file.i: size=1174
144 .hg/store/data/file.i: size=1174
128 $ hg tip
145 $ hg tip
129 changeset: 1:3ce491143aec
146 changeset: 1:cfa8d6e60429
130 tag: tip
147 tag: tip
131 user: test
148 user: test
132 date: Thu Jan 01 00:00:00 1970 +0000
149 date: Thu Jan 01 00:00:00 1970 +0000
133 summary: _
150 summary: b
134
151
135 $ hg verify -q
152 $ hg verify -q
136 $ cd ..
153 $ cd ..
137
154
138
155
139 Repeat the original test but let hg rollback the transaction.
156 Repeat the original test but let hg rollback the transaction.
140
157
141 $ hg clone -r 1 troffset-computation troffset-computation-copy-rb --config format.revlog-compression=none -q
158 $ hg clone -r 1 troffset-computation troffset-computation-copy-rb --config format.revlog-compression=none -q
142 $ cd troffset-computation-copy-rb
159 $ cd troffset-computation-copy-rb
143 $ cat > .hg/hgrc <<EOF
160 $ cat > .hg/hgrc <<EOF
144 > [hooks]
161 > [hooks]
145 > pretxnchangegroup = false
162 > pretxnchangegroup = false
146 > EOF
163 > EOF
147 $ hg pull ../troffset-computation
164 $ hg pull ../troffset-computation
148 pulling from ../troffset-computation
165 pulling from ../troffset-computation
149 searching for changes
166 searching for changes
150 adding changesets
167 adding changesets
151 adding manifests
168 adding manifests
152 adding file changes
169 adding file changes
153 transaction abort!
170 transaction abort!
154 rollback completed
171 rollback completed
155 abort: pretxnchangegroup hook exited with status 1
172 abort: pretxnchangegroup hook exited with status 1
156 [40]
173 [40]
157 $ f -s .hg/store/data/file*
174 $ f -s .hg/store/data/file*
158 .hg/store/data/file.d: size=1046
175 .hg/store/data/file.d: size=1067
159 .hg/store/data/file.i: size=128
176 .hg/store/data/file.i: size=192
160 $ hg tip
177 $ hg tip
161 changeset: 1:3ce491143aec
178 changeset: 1:cfa8d6e60429
162 tag: tip
179 tag: tip
163 user: test
180 user: test
164 date: Thu Jan 01 00:00:00 1970 +0000
181 date: Thu Jan 01 00:00:00 1970 +0000
165 summary: _
182 summary: b
166
183
167 $ hg verify -q
184 $ hg verify -q
168 warning: revlog 'data/file.d' not in fncache!
185 warning: revlog 'data/file.d' not in fncache!
169 1 warnings encountered!
186 file@?: rev 2 points to nonexistent changeset 2
187 (expected )
188 file@?: fa1120531cc1 not in manifests
189 2 warnings encountered!
170 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
190 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
191 2 integrity errors encountered!
192 [1]
171 $ cd ..
193 $ cd ..
172
194
General Comments 0
You need to be logged in to leave comments. Login now