Commit Graph

29 Commits

Author SHA1 Message Date
Durham Goode
d56fa342f0 Improve error message when fallback server isn't configured
Summary:
If the remotefilelog server was not specified in the hgrc, or if the project
hgrc wasn't trusted, it would throw an obtuse error about a NoneType string.
This fixes it to give a more informative error explaining the problem.

Test Plan: Added a test

Reviewers: sid0, pyd, mitrandir, ericsumner, rmcelroy

Reviewed By: rmcelroy

Differential Revision: https://phabricator.fb.com/D1774743

Signature: t1:1774743:1420830544:5122a8e11f668ee8c35996e0f4395883a31ce8b0
2015-01-09 09:43:14 -08:00
Durham Goode
4d92ad3ed7 Add optional cache validation
Summary:
There are reports of the local cache becoming invalid when stored on disk. This
adds an option that will do some basic validation and remediation for those
entries, and log some data to disk.

This is optional, since it incurs some performance overhead. We just want to use
it long enough to track down the issue.

Test Plan: Added a test

Reviewers: sid0, pyd, ericsumner, rmcelroy, mitrandir

Reviewed By: mitrandir

Differential Revision: https://phabricator.fb.com/D1774724

Signature: t1:1774724:1420827432:06ace9d1dc078f469e0f61ebd7f604fc3b606f6d
2015-01-08 18:59:04 -08:00
Durham Goode
d985df868c Atomically write local cache files
Summary:
We're seeing some weird cache corruption errors when writing the cache to disk.
My best bet is there's multiple writes colliding and causing bad data, so let's
do atomic renames.

Test Plan: Ran the test suite

Reviewers: sid0, pyd, davidsp, rmcelroy

Reviewed By: rmcelroy

Subscribers: ericsumner, mitrandir

Differential Revision: https://phabricator.fb.com/D1747190

Signature: t1:1747190:1418865586:0a07e5243dfe9c1d5ea24f81874910d1080f24e2
2014-12-17 16:36:40 -08:00
Durham Goode
8a5a5330c1 Fix pullprefetch for recently landed commits
Summary:
Pull-prefetch would not download file versions from the server if the file
version already existed in the local cache or the local store data.
Unfortunately, if someone landed their commit, then later stripped their local
version, the local store data file version might become invalid and no local
cache version would exist. Meaning things like 'commit' might fail when offline.

This changes prefetch to always fetch from the server when dealing with files it
knows are from revs on the server.

Test Plan:
Added a test that makes local commits that already exist on the
server, and verifies that a pull-prefetch fetches the server file version,
despite that same version existing locally.

Reviewers: sid0, pyd, davidsp

Subscribers: orip

Differential Revision: https://phabricator.fb.com/D1607260
2014-10-09 15:20:54 -07:00
Pierre-Yves David
548b8af8b5 client: add a second argument to ResponseError
Summary:
The ResponseError exception expect a second argument. Otherwise the code
handling it crashes.

Test Plan: The handling of the response error stop crashing.

Reviewers: durham

Differential Revision: https://phabricator.fb.com/D1581574
2014-09-11 20:30:16 +02:00
Durham Goode
e6bee07496 Expand environment variables in cacheprocess and cachepath
Summary:
Expands environment variables in the cacheprocess and cachepath config options,
so users can specify something like remotefilelog.cachepath=$HOME/.hgcache

Test Plan:
Set my cachepath to $HOME/.hgcache on my laptop and manually
performed a shallow clone.  Verified data was put in ~/.hgcache

Reviewers: sid0

Differential Revision: https://phabricator.fb.com/D1342174
2014-05-21 12:28:03 -07:00
Durham Goode
0301f9f129 Move local cache logic into it's own class
The current local cache is just files on disk, and this implementation detail
was spread across the extension. This change refactors it to hide the
implementation inside a class so that we can replace it with other
implementations (such as a sqlite local cache) later.
2014-02-11 16:25:55 -08:00
Durham Goode
bdea38dd56 Move fileservice to be per repo instead of global
Previously the file service client was a global object that all repos could
share. This was a bit hacky and is no longer needed. Now the file service
client exists per repo instance.

This is part of a series of changes to abstract the local caching and remote
file service in such a way that we can plug and play implementations.
2014-02-11 14:41:56 -08:00
Durham Goode
9eda4f7a0f Fix fallback when memcache process exits unexpectedly
If the memcache process exited early, remotefilelog was throwing an exception
instead of falling back to the server. This change makes it fall back to the
server, and also print a warning that the cache connection closed early.
2014-01-09 11:41:12 -08:00
Durham Goode
16a7f940d5 Increase batch request size
When falling back to the master server for cache misses, we only kept two
requests in flight at any time. Over high latency connections (like across
oceans) this resulted in very slow downloads.

This change increases the request size to 10,000 keys at once. This will keep
the size of the request lower than the tcp buffer size, while allowing us to
maximize our throughput.
2013-12-17 14:31:21 -08:00
Durham Goode
4d6f31837e Fix hang when manifest size is greater than tcp buffer
Previously we sent the entire list of files to the fallback repo in a single ssh
write/flush.  If the size of this write exceeded the tcp buffer on the receiving
end, the call would hang until the buffer had room.  The problem is that the
receiving end (the server) is hung trying to send data back to the
client. Therefore it deadlocked.

The fix is to send and receive requests one at a time. We always have the next
request in flight while receiving so we shouldn't be waiting on requests too
often.
2013-12-11 13:39:53 -08:00
Durham Goode
393958c76b Allow naming repos
Enables specifying a name for a repo that is used in the cache key.
This allows multiple repos on a machine to share a cache without the
risk of keys overlapping.
2013-08-15 11:00:51 -07:00
Durham Goode
b88d1b44d4 Replace linknode fallback algorithm
The previous algorithm thought that if the system cache had the file rev, it was
guaranteed to be valid. This isn't true in the case of a machine in which
multiple people share the cache (one person may have pulled a rev but the other
hasn't).

The new algorithm is more explicit. It checks:

- system cache
- local cache
- local cache fallbacks
- remote cache
- master server
2013-11-22 13:41:54 -08:00
Durham Goode
1275d15990 Add include and exclude configuration settings
The remotefilelog extension currently doesn't work with tags. Adding include and
exclude patterns allows users to specify which files they want to treat as
shallow and which the want to download the entire history for. By excluding
.hgtags from being shallow, this enables tags to work in a mostly shallow repo.

This also enables largefile like scenarios where most files are full and only a
few large ones are kept remote.
2013-09-26 10:46:06 -07:00
Durham Goode
7268e5b709 Refactor ancestormap linknode logic to handle a bug
A rare bug can occur where the local file blob might not exist, but a valid old
version of that blob does exist. This refactor the linknode logic in ancestormap
to check the old versions if the server fetch fails to find the blob.

It still prints an ugly warning message from the server, but this whole issue is
quite rare anyway.
2013-10-03 15:15:15 -07:00
Durham Goode
c17ec690c9 Change cache key to use a two character prefix for directories.
Some file systems can't handle having a ton of files/directories inside a
directory, so this splits up all our files amongst directories.
2013-09-06 13:28:15 -07:00
Durham Goode
29ba0e9bc1 If cacheprocess is not set, always use the fallback
This allows tests to run without a memcache process.
2013-09-03 20:03:24 -07:00
Durham Goode
d0738cc010 Make cache files owned by uid/svnuser 2013-08-20 12:59:33 -07:00
Durham Goode
96bbab8f7a Fix shared cache permissions to be g+w 2013-08-15 10:59:11 -07:00
Durham Goode
bf7491936d Fix hg diff with added or moved files.
A workingctx produces manifest entries with nullid+'a' or nullid+'m'
for any added or modified files. The extension was trying to prefetch
these but they didn't exist and caused an error. Luckily they are length
42 so we can check for them and not prefetch them.
2013-07-24 22:16:50 -07:00
Durham Goode
a5828ce7a3 Add newline to end of debug output 2013-07-24 18:49:14 -07:00
Durham Goode
9df6e83354 Prevent 'running ssh...' in stdout when run with -v 2013-07-24 13:20:13 -07:00
Durham Goode
3cbc732b42 Fix fallbackrepo not being present during the clone after update.
Make debug message get sent to stderr instead of stdout.
2013-07-23 19:06:40 -07:00
Durham Goode
77d31b12e4 Add hit/miss ratio to debug output 2013-07-01 17:37:55 -07:00
Durham Goode
9642a8a2d6 Add remotefilelog.fallbackrepo config 2013-07-01 16:28:34 -07:00
Durham Goode
027a1d4ab8 Set umask before writing files to shared cache 2013-06-28 17:12:20 -07:00
Durham Goode
8e037436cb Add gc command for cleaning up the cache 2013-06-28 15:57:15 -07:00
Durham Goode
bb32b111bf Change contract between extension and memcache process to allow arbitrary key lengths and customizable cache paths 2013-06-25 11:38:48 -07:00
Durham Goode
f16a3a4134 Rename to remotefilelog since shallowrepo is already taken 2013-06-21 10:14:29 -07:00