| 1 |
Test that, when an hg push is interrupted and the remote side receives SIGPIPE, |
| 2 |
the remote hg is able to successfully roll back the transaction. |
| 3 |
|
| 4 |
$ hg init -q remote |
| 5 |
$ hg clone -q ssh://user@dummy/`pwd`/remote local |
| 6 |
$ SIGPIPE_REMOTE_DEBUG_FILE="$TESTTMP/DEBUGFILE" |
| 7 |
$ SYNCFILE1="$TESTTMP/SYNCFILE1" |
| 8 |
$ SYNCFILE2="$TESTTMP/SYNCFILE2" |
| 9 |
$ export SIGPIPE_REMOTE_DEBUG_FILE |
| 10 |
$ export SYNCFILE1 |
| 11 |
$ export SYNCFILE2 |
| 12 |
$ PYTHONUNBUFFERED=1 |
| 13 |
$ export PYTHONUNBUFFERED |
| 14 |
|
| 15 |
On the remote end, run hg, piping stdout and stderr through processes that we |
| 16 |
know the PIDs of. We will later kill these to simulate an ssh client |
| 17 |
disconnecting. |
| 18 |
|
| 19 |
$ remotecmd="$RUNTESTDIR/testlib/sigpipe-remote.py" |
| 20 |
|
| 21 |
In the pretxnchangegroup hook, kill the PIDs recorded above to simulate ssh |
| 22 |
disconnecting. Then exit nonzero, to force a transaction rollback. |
| 23 |
|
| 24 |
|
| 25 |
$ cat >remote/.hg/hgrc <<EOF |
| 26 |
> [hooks] |
| 27 |
> pretxnchangegroup.00-break-things=sh "$RUNTESTDIR/testlib/wait-on-file" 10 "$SYNCFILE2" "$SYNCFILE1" |
| 28 |
> pretxnchangegroup.01-output-things=echo "some remote output to be forward to the closed pipe" |
| 29 |
> pretxnchangegroup.02-output-things=echo "some more remote output" |
| 30 |
> EOF |
| 31 |
|
| 32 |
$ hg --cwd ./remote tip -T '{node|short}\n' |
| 33 |
000000000000 |
| 34 |
$ cd local |
| 35 |
$ echo foo > foo ; hg commit -qAm "commit" |
| 36 |
|
| 37 |
(use quiet to avoid flacky output from the server) |
| 38 |
|
| 39 |
$ hg push --quiet --remotecmd "$remotecmd" |
| 40 |
abort: stream ended unexpectedly (got 0 bytes, expected 4) |
| 41 |
[255] |
| 42 |
$ cat $SIGPIPE_REMOTE_DEBUG_FILE |
| 43 |
SIGPIPE-HELPER: Starting |
| 44 |
SIGPIPE-HELPER: Redirection in place |
| 45 |
SIGPIPE-HELPER: pipes closed in main |
| 46 |
SIGPIPE-HELPER: SYNCFILE1 detected |
| 47 |
SIGPIPE-HELPER: worker killed |
| 48 |
SIGPIPE-HELPER: creating SYNCFILE2 |
| 49 |
SIGPIPE-HELPER: Shutting down |
| 50 |
SIGPIPE-HELPER: Server process terminated with status 255 (no-windows !) |
| 51 |
SIGPIPE-HELPER: Server process terminated with status 1 (windows !) |
| 52 |
SIGPIPE-HELPER: Shut down |
| 53 |
|
| 54 |
The remote should be left in a good state |
| 55 |
$ hg --cwd ../remote tip -T '{node|short}\n' |
| 56 |
000000000000 |
| 57 |
|
| 58 |
#if windows |
| 59 |
|
| 60 |
XXX-Windows Broken behavior to be fixed |
| 61 |
|
| 62 |
Behavior on Windows is broken and should be fixed. However this is a fairly |
| 63 |
corner case situation and no data are being corrupted. This would affect |
| 64 |
central repository being hosted on a Windows machine and accessed using ssh. |
| 65 |
|
| 66 |
This was catch as we setup new CI for Windows. Making the test pass on Windows |
| 67 |
was enough of a pain that fixing the behavior set aside for now. Dear and |
| 68 |
honorable reader, feel free to fix it. |
| 69 |
|
| 70 |
$ hg --cwd ../remote recover |
| 71 |
rolling back interrupted transaction |
| 72 |
(verify step skipped, run `hg verify` to check your repository content) |
| 73 |
|
| 74 |
#else |
| 75 |
|
| 76 |
$ hg --cwd ../remote recover |
| 77 |
no interrupted transaction available |
| 78 |
[1] |
| 79 |
|
| 80 |
#endif |