tests/test-update-names.t
author Matt Harbison <matt_harbison@yahoo.com>
Tue, 21 Jan 2020 11:32:33 -0500
changeset 44320 43eea17ae7b3
parent 39609 c8514f858788
permissions -rw-r--r--
lfs: fix the stall and corruption issue when concurrently uploading blobs We've avoided the issue up to this point by gating worker usage with an experimental config. See 10e62d5efa73, and the thread linked there for some of the initial diagnosis, but essentially some data was being read from the blob before an error occurred and `keepalive` retried, but didn't rewind the file pointer. So the leading data was lost from the blob on the server, and the connection stalled, trying to send more data than available. In trying to recreate this, I was unable to do so uploading from Windows to CentOS 7. But it reproduced every time going from CentOS 7 to another CentOS 7 over https. I found recent fixes in the FaceBook repo to address this[1][2]. The commit message for the first is: The KeepAlive HTTP implementation is bugged in it's retry logic, it supports reading from a file pointer, but doesn't support rewinding of the seek cursor when it performs a retry. So it can happen that an upload fails for whatever reason and will then 'hang' on the retry event. The sequence of events that get triggered are: - Upload file A, goes OK. Keep-Alive caches connection. - Upload file B, fails due to (for example) failing Keep-Alive, but LFS file pointer has been consumed for the upload and fd has been closed. - Retry for file B starts, sets the Content-Length properly to the expected file size, but since file pointer has been consumed no data will be uploaded, causing the server to wait for the uploaded data until either client or server reaches a timeout, making it seem as our mercurial process hangs. This is just a stop-gap measure to prevent this behavior from blocking Mercurial (LFS has retry logic). A proper solutions need to be build on top of this stop-gap measure: for upload from file pointers, we should support fseek() on the interface. Since we expect to consume the whole file always anyways, this should be safe. This way we can seek back to the beginning on a retry. I ported those two patches, and it works. But I see that `url._sendfile()` does a rewind on `httpsendfile` objects[3], so maybe it's better to keep this all in one place and avoid a second seek. We may still want the first FaceBook patch as extra protection for this problem in general. The other two uses of `httpsendfile` are in the wire protocol to upload bundles, and to upload largefiles. Neither of these appear to use a worker, and I'm not sure why workers seem to trigger this, or if this could have happened without a worker. Since `httpsendfile` already has a `close()` method, that is dropped. That class also explicitly says there's no `__len__` attribute, so that is removed too. The override for `read()` is necessary to avoid the progressbar usage per file. [1] https://github.com/facebookexperimental/eden/commit/c350d6536d90c044c837abdd3675185644481469 [2] https://github.com/facebookexperimental/eden/commit/77f0d3fd0415e81b63e317e457af9c55c46103ee [3] https://www.mercurial-scm.org/repo/hg/file/5.2.2/mercurial/url.py#l176 Differential Revision: https://phab.mercurial-scm.org/D7962
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29480
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
     1
Test update logic when there are renames or weird same-name cases between dirs
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
     2
and files
10874
4f11978ae45d copies: properly visit file context ancestors on working file contexts
Henrik Stuart <henrik.stuart@edlund.dk>
parents:
diff changeset
     3
12328
b63f6422d2a7 tests: fix a bunch of pointless #s in unified tests
Matt Mackall <mpm@selenic.com>
parents: 12316
diff changeset
     4
Update with local changes across a file rename
12299
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
     5
29480
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
     6
  $ hg init r1 && cd r1
12299
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
     7
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
     8
  $ echo a > a
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
     9
  $ hg add a
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    10
  $ hg ci -m a
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    11
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    12
  $ hg mv a b
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    13
  $ hg ci -m rename
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    14
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    15
  $ echo b > b
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    16
  $ hg ci -m change
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    17
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    18
  $ hg up -q 0
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    19
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    20
  $ echo c > a
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    21
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    22
  $ hg up
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    23
  merging a and b to b
26614
ef1eb6df7071 simplemerge: move conflict warning message to filemerge
Siddharth Agarwal <sid0@fb.com>
parents: 16911
diff changeset
    24
  warning: conflicts while merging b! (edit, then use 'hg resolve --mark')
12299
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    25
  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
a73684df0f8a tests: unify test-update-renames
Adrian Buehlmann <adrian@cadifra.com>
parents: 10874
diff changeset
    26
  use 'hg resolve' to retry unresolved file merges
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12299
diff changeset
    27
  [1]
29480
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    28
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    29
Test update when local untracked directory exists with the same name as a
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    30
tracked file in a commit we are updating to
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    31
  $ hg init r2 && cd r2
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    32
  $ echo root > root && hg ci -Am root  # rev 0
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    33
  adding root
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    34
  $ echo text > name && hg ci -Am "name is a file"  # rev 1
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    35
  adding name
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    36
  $ hg up 0
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    37
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    38
  $ mkdir name
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    39
  $ hg up 1
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    40
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    41
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    42
Test update when local untracked directory exists with some files in it and has
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    43
the same name a tracked file in a commit we are updating to. In future this
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    44
should be updated to give an friendlier error message, but now we should just
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    45
make sure that this does not erase untracked data
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    46
  $ hg up 0
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    47
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    48
  $ mkdir name
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    49
  $ echo text > name/file
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    50
  $ hg st
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    51
  ? name/file
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    52
  $ hg up 1
39609
c8514f858788 tests: stabilize change for handling not quoting non-empty-directory
Matt Harbison <matt_harbison@yahoo.com>
parents: 39593
diff changeset
    53
  abort: Unlinking directory not permitted: *$TESTTMP/r1/r2/name* (glob) (windows !)
39593
cb1329738d64 tests: handle Python 3 not quoting non-empty-directory error
Augie Fackler <augie@google.com>
parents: 39495
diff changeset
    54
  abort: Directory not empty: '?\$TESTTMP/r1/r2/name'? (re) (no-windows !)
38775
8c6775e812d8 merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents: 34942
diff changeset
    55
  [255]
8c6775e812d8 merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents: 34942
diff changeset
    56
  $ cat name/file
8c6775e812d8 merge: do not delete untracked files silently (issue5962)
Yuya Nishihara <yuya@tcha.org>
parents: 34942
diff changeset
    57
  text
29480
1e4512eac59e update: teach hg to override untracked dir with a tracked file on update
Kostia Balytskyi <ikostia@fb.com>
parents: 26614
diff changeset
    58
  $ cd ..
29629
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    59
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    60
#if symlink
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    61
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    62
Test update when two commits have symlinks that point to different folders
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    63
  $ hg init r3 && cd r3
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    64
  $ echo root > root && hg ci -Am root
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    65
  adding root
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    66
  $ mkdir folder1 && mkdir folder2
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    67
  $ ln -s folder1 folder
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    68
  $ hg ci -Am "symlink to folder1"
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    69
  adding folder
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    70
  $ rm folder
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    71
  $ ln -s folder2 folder
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    72
  $ hg ci -Am "symlink to folder2"
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    73
  $ hg up 1
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    74
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    75
  $ cd ..
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    76
b33c0c38d68f update: fix bug when update tries to modify folder symlink
Kostia Balytskyi <ikostia@fb.com>
parents: 29480
diff changeset
    77
#endif
30172
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    78
30230
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 30172
diff changeset
    79
#if rmcwd
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 30172
diff changeset
    80
30172
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    81
Test that warning is printed if cwd is deleted during update
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    82
  $ hg init r4 && cd r4
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    83
  $ mkdir dir
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    84
  $ cd dir
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    85
  $ echo a > a
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    86
  $ echo b > b
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    87
  $ hg add a b
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    88
  $ hg ci -m "file and dir"
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    89
  $ hg up -q null
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    90
  current directory was removed
90a6c18a7c1d update: warn if cwd was deleted
Stanislau Hlebik <stash@fb.com>
parents: 29629
diff changeset
    91
  (consider changing to repo root: $TESTTMP/r1/r4)
30230
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 30172
diff changeset
    92
46a0203dfb89 tests: run "cwd was removed" test only if cwd can actually be removed
Yuya Nishihara <yuya@tcha.org>
parents: 30172
diff changeset
    93
#endif