Mercurial > hg
annotate tests/test-pushvars.t @ 46607:e9901d01d135
revlog: add a mechanism to verify expected file position before appending
If someone uses `hg debuglocks`, or some non-hg process writes to the .hg
directory without respecting the locks, or if the repo's on a networked
filesystem, it's possible for the revlog code to write out corrupted data.
The form of this corruption can vary depending on what data was written and how
that happened. We are in the "networked filesystem" case (though I've had users
also do this to themselves with the "`hg debuglocks`" scenario), and most often
see this with the changelog. What ends up happening is we produce two items
(let's call them rev1 and rev2) in the .i file that have the same linkrev,
baserev, and offset into the .d file, while the data in the .d file is appended
properly. rev2's compressed_size is accurate for rev2, but when we go to
decompress the data in the .d file, we use the offset that's recorded in the
index file, which is the same as rev1, and attempt to decompress
rev2.compressed_size bytes of rev1's data. This usually does not succeed. :)
When using inline data, this also fails, though I haven't investigated why too
closely. This shows up as a "patch decode" error. I believe what's happening
there is that we're basically ignoring the offset field, getting the data
properly, but since baserev != rev, it thinks this is a delta based on rev
(instead of a full text) and can't actually apply it as such.
For now, I'm going to make this an optional component and default it to entirely
off. I may increase the default severity of this in the future, once I've
enabled it for my users and we gain more experience with it. Luckily, most of my
users have a versioned filesystem and can roll back to before the corruption has
been written, it's just a hassle to do so and not everyone knows how (so it's a
support burden). Users on other filesystems will not have that luxury, and this
can cause them to have a corrupted repository that they are unlikely to know how
to resolve, and they'll see this as a data-loss event. Refusing to create the
corruption is a much better user experience.
This mechanism is not perfect. There may be false-negatives (racy writes that
are not detected). There should not be any false-positives (non-racy writes that
are detected as such). This is not a mechanism that makes putting a repo on a
networked filesystem "safe" or "supported", just *less* likely to cause
corruption.
Differential Revision: https://phab.mercurial-scm.org/D9952
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Wed, 03 Feb 2021 16:33:10 -0800 |
parents | d7304434390f |
children | 7e5be4a7cda7 |
rev | line source |
---|---|
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
1 Setup |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
2 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
3 $ PYTHONPATH=$TESTDIR/..:$PYTHONPATH |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
4 $ export PYTHONPATH |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
5 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
6 $ cat > $TESTTMP/pretxnchangegroup.sh << EOF |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
7 > #!/bin/sh |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
8 > env | egrep "^HG_USERVAR_(DEBUG|BYPASS_REVIEW)" | sort |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
9 > exit 0 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
10 > EOF |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
11 $ cat >> $HGRCPATH << EOF |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
12 > [hooks] |
33796
4f8c241b2bfa
test-pushvars: invoke shell script hook via `sh` for Windows
Matt Harbison <matt_harbison@yahoo.com>
parents:
33693
diff
changeset
|
13 > pretxnchangegroup = sh $TESTTMP/pretxnchangegroup.sh |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
14 > EOF |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
15 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
16 $ hg init repo |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
17 $ hg clone -q repo child |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
18 $ cd child |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
19 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
20 Test pushing vars to repo with pushvars.server not set |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
21 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
22 $ echo b > a |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
23 $ hg commit -Aqm a |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
24 $ hg push --pushvars "DEBUG=1" --pushvars "BYPASS_REVIEW=true" |
35393
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
33885
diff
changeset
|
25 pushing to $TESTTMP/repo |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
26 searching for changes |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
27 adding changesets |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
28 adding manifests |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
29 adding file changes |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
30 added 1 changesets with 1 changes to 1 files |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
31 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
32 Setting pushvars.sever = true and then pushing. |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
33 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
34 $ echo [push] >> $HGRCPATH |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
35 $ echo "pushvars.server = true" >> $HGRCPATH |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
36 $ echo b >> a |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
37 $ hg commit -Aqm a |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
38 $ hg push --pushvars "DEBUG=1" --pushvars "BYPASS_REVIEW=true" |
35393
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
33885
diff
changeset
|
39 pushing to $TESTTMP/repo |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
40 searching for changes |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
41 adding changesets |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
42 adding manifests |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
43 adding file changes |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
44 HG_USERVAR_BYPASS_REVIEW=true |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
45 HG_USERVAR_DEBUG=1 |
42897
d7304434390f
changegroup: move message about added changes to transaction summary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
36157
diff
changeset
|
46 added 1 changesets with 1 changes to 1 files |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
47 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
48 Test pushing var with empty right-hand side |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
49 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
50 $ echo b >> a |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
51 $ hg commit -Aqm a |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
52 $ hg push --pushvars "DEBUG=" |
35393
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
33885
diff
changeset
|
53 pushing to $TESTTMP/repo |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
54 searching for changes |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
55 adding changesets |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
56 adding manifests |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
57 adding file changes |
42897
d7304434390f
changegroup: move message about added changes to transaction summary
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
36157
diff
changeset
|
58 HG_USERVAR_DEBUG= |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
59 added 1 changesets with 1 changes to 1 files |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
60 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
61 Test pushing bad vars |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
62 |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
63 $ echo b >> a |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
64 $ hg commit -Aqm b |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
65 $ hg push --pushvars "DEBUG" |
35393
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
33885
diff
changeset
|
66 pushing to $TESTTMP/repo |
33885 | 67 searching for changes |
33693
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
68 abort: unable to parse variable 'DEBUG', should follow 'KEY=VALUE' or 'KEY=' format |
db3dc11356ed
pushvars: move fb extension pushvars to core
Pulkit Goyal <7895pulkit@gmail.com>
parents:
diff
changeset
|
69 [255] |