Commit Graph

105 Commits

Author SHA1 Message Date
Arun Kulshreshtha
8cc3939f35 revisionstore: do not swallow errors from EdenAPI stores
Summary:
Previously, the EdenAPI stores would not report errors returned from the remote store. The intention behind this pattern in other stores is to prevent `KeyError`s from aborting the operation since the local store might still have the key.

However, in the case of the EdenAPI store, EdenAPI will simply omit missing keys in its response rather than returning an error. Instead, any error returned by the EdenAPI store indicates a more fundamental problem (e.g., unable to reach the server, connection reset, etc) which should cause an abort and return the error.

Reviewed By: quark-zju

Differential Revision: D22544031

fbshipit-source-id: e01e8d88b75e46dcebd2eef5203e3a0edde69fc7
2020-07-15 15:07:51 -07:00
Arun Kulshreshtha
9a536eb3b0 revisionstore: Add EdenApiHistoryStore
Summary: Add an EdenAPI-backed history store. Notably, thanks to the strongly-typed remote store design from the previous diff, it is not possible to construct an `EdenApiHistoryStore` for trees, even when the underlying remote store is behind a trait object. (This is because EdenAPI does not support fetching history for trees.)

Reviewed By: quark-zju

Differential Revision: D22492162

fbshipit-source-id: 23f1393919c4e8ac0918d2009a16f482d90df15c
2020-07-13 17:35:31 -07:00
Arun Kulshreshtha
670ed17ba6 revisionstore: add EdenApiFileStore and EdenApiTreeStore
Summary: Reimplement `EdenApiHgIdRemoteStore` as `EdenApiRemoteStore<T>`, where `T` is a marker type indicating whether this store fetches files or trees. This allows working with the stores in a more strongly-typed way, and avoid having to check what kind of store this is at runtime when fetching data.

Reviewed By: quark-zju

Differential Revision: D22492160

fbshipit-source-id: e17556093fa9b81d2301f281da36d75a03e33c5e
2020-07-13 17:35:31 -07:00
Arun Kulshreshtha
73765b649b revisionstore: move edenapi module into directory
Summary: Move `src/edenapi.rs` to `src/edenapi/mod.rs` in anticipation of adding more files to this module.

Reviewed By: quark-zju

Differential Revision: D22492161

fbshipit-source-id: f6252ea9a9e32d94029b8e6e76be5d9d1754f63d
2020-07-13 17:35:31 -07:00
Durham Goode
6774dfe154 packs: flush history packs every 10 million adds
Summary:
We're seeing cases were cloning can take 10's of GB of memory because
we pend all the history information in memory. Let's flush the history info
every 10 million adds to bound the memory usage.

10 million was chosen somewhat arbitrarily, but it results in pack files that
are 800MB, which corresponds roughly with 8GB of memory usage.

This requires updating repack to be aware that a single flush could produce
multiple packs. Note, since repack writes via this same path, it may result in
repack producing multiple pack files. In the degenerate case repack could
produce the same number (or more) of pack files than was inputted. If we set the
threshold high enough I think we'll be fine though. 800MB is probably
sufficient.

Reviewed By: xavierd

Differential Revision: D22438569

fbshipit-source-id: 425d5d3b7999b81e44d1dbe1f2a4ea453ab6ca4f
2020-07-13 08:10:14 -07:00
Arun Kulshreshtha
cb16831e6d revisionstore: add add_entry method to HgIdMutableDeltaStore
Summary: Add an `add_entry` convenience method to `HgIdMutableDeltaStore`, similar to the one present in `HgIdMutableHistoryStore`.

Reviewed By: quark-zju

Differential Revision: D22443031

fbshipit-source-id: 84fdaae9fbd51e6f2df466b0441ec5f7ce6715f7
2020-07-09 19:05:55 -07:00
Arun Kulshreshtha
d1d3224ba1 revisionstore: use new EdenAPI crate
Summary: Update the `revisionstore` and `backingstore` crates to use the new EdenAPI crate.

Reviewed By: quark-zju

Differential Revision: D22378330

fbshipit-source-id: 989f34827b744ff4b4ac0aa10d004f03dbe9058f
2020-07-09 13:08:27 -07:00
Xavier Deguillard
48d97384d0 revisionstore: fix typo in memcache trace
Summary:
The key is "hit_count" not "hits". This typo caused the trace to always claim
that no data was fetched from memcache, which is obviously not true as the
getpack trace that follows listed significantly less requested keys.

Reviewed By: kulshrax

Differential Revision: D22401592

fbshipit-source-id: ab2ea3e7f8ff3a9c7322678afc8a174e09d6dc09
2020-07-06 17:57:16 -07:00
Arun Kulshreshtha
fdba0b98c2 edenapi: rename to edenapi_old
Summary: Move old EdenAPI crate to `scm/lib/edenapi/old` to make room for the new crate. This old code will eventually been deleted once all references to it are removed from the codebase.

Reviewed By: quark-zju

Differential Revision: D22305173

fbshipit-source-id: 45d211340900192d0488543ba13d9bf84909ce53
2020-06-30 21:10:41 -07:00
Xavier Deguillard
31d831bfaf revisionstore: manually set the Content-Length for empty lfs requests
Summary:
We've had a case where a client sent a bundle that contained an LFS pointer to
Sandcastle. On that original repo, the LFS blob and pointer were in the
hgcache, which signified that the server has it. When that bundle gets applied
on Sandcastle, the pointer then makes its way onto the local lfs pointer store
and the blob will be fetched from the LFS server itself properly.

Where it gets tricky is that Sandcastle then tried to re-bundle the change and
thus tried to re-upload it. The expectation from the client perspective is that
since the blob was fetched from the server in the first place, the server will
just not ask for the blob to be re-uploaded. The asumption proved to be
semi-inacurate in the case where the LFS server mirrors all the writes to a
secondary LFS server. When that secondary LFS server is standalone and not
Mononoke, it may not have the blob in question, and thus the LFS server may
request the blob to be re-uploaded so it can write it to the secondary LFS
server.

Unfortunately, things start breaking down at this point. Since the blob isn't
present in the local store the client can't rely on being able to read it and
fetching it from the server to then upload it is silly and a bit too complex.
Instead, what we can do is teach the server of this specific scenario by
manually setting the Content-Length to 0 in the case of an upload where the
blob wasn't found in the local store. The server recognizes this and will
manually copy the blob to the secondary LFS server.

Reviewed By: krallin

Differential Revision: D22192718

fbshipit-source-id: 67c5ba1a751cc07d5d5d51e07703282d8175b010
2020-06-24 09:05:29 -07:00
Xavier Deguillard
275de2a00e revisionstore: add tracing spans to lfs code
Summary: This will help in debugging potential performance issues.

Reviewed By: DurhamG

Differential Revision: D22140035

fbshipit-source-id: d7403897fbb843a4eca874c1da3788190d181bc0
2020-06-19 19:54:21 -07:00
Xavier Deguillard
b8744c42cc revisionstore: add a timeout when sending lfs requests
Summary:
We've seen a handful of hangs in the LFS code, adding a timeout on the
connection request would help in surfacing issues when the client for some
reason doesn't get a reply from the server.

We unfortunately can't add a general timeout, as a user's connection speed
would need to be taken into account.

Reviewed By: krallin

Differential Revision: D22139560

fbshipit-source-id: 0118fb8a38af488e2f40bed0a09677bc68d666a8
2020-06-19 19:54:21 -07:00
Xavier Deguillard
c87a18ebae revisionstore: enable all tokio's features
Summary:
At least one mac user had a confirmed hang in the new LFS code that caused us
to rollback LFS for fbsource. One of the thing that was weird is that both
Sandcastle and devservers have several orders of magnitude higher request to
the LFS server and thus we would expect this issue to be widespread there. We
haven't seen this.

One of the difference between the package on the devservers/sandcastle and on
macs is how they are compiled. The former is with buck, while the later is with
cargo, and the package built with buck has all the tokio features enabled,
while cargo has no features enabled. What interest us here is the kind of
scheduler that is in use: on mac the basic scheduler, on devserver/sandcastle,
the threaded scheduler.

While I'm not entirely convinced that the difference in the scheduler is what
causes the hang, it's a good idea to make sure that both of our packages are
compiled the same way.

Reviewed By: krallin

Differential Revision: D22138593

fbshipit-source-id: ce9e64a6a930d2b0cccb634a1af9c3b5b8816a21
2020-06-19 19:54:21 -07:00
Arun Kulshreshtha
cde0436ca9 edenapi_types: move EdenAPI types into separate crate
Summary:
Several of the structs used by EdenAPI were previously defined in Mercurial's
`types` crate. This is not ideal since these structs are used for data interchange
between the client and server, and changes to them can break Mononoke, Mercurial,
or both. As such, they are more fragile than other types and their use should be
limited to the EdenAPI server and client to avoid the need for extensive breaking
changes or costly refactors down the line.

I'm about to make a series of breaking changes to these types as part of the
migration to the new EdenAPI server, so this seemed like an ideal time to split
these types into their own crate.

Reviewed By: krallin

Differential Revision: D21857425

fbshipit-source-id: 82dedc4a2d597532e58072267d8a3368c3d5c9e7
2020-06-10 19:29:44 -07:00
Durham Goode
713fbeec24 datastore: support indexedlog as the hgcache write store
Summary:
Adds a remotefilelog.write-hgcache-to-indexedlog config which directs
all hgcache writes to the indexedlog.

This change also removes remotefilelog.indexedlogdatastore as it's on by default
now.

Reviewed By: xavierd

Differential Revision: D21772132

fbshipit-source-id: a71e188df2958fb4f8c4776da23ba87deccb3b79
2020-06-01 11:18:44 -07:00
Thomas Orozco
006864a6ce lfs v2: don't send empty batch requests
Summary:
We can skip the round trip to the server if we have nothing to ask or tell the
server.

Reviewed By: xavierd

Differential Revision: D21763025

fbshipit-source-id: 7f199c12ccaa0f66ce765dd976723e4002c5dd4e
2020-06-01 03:45:30 -07:00
Xavier Deguillard
ee81495b3d revisionstore: handle empty proxy
Summary:
If either the config, or the environment variable is empty, the URL parsing
would raise an error, while the intent is to not have proxy. Let's handle it
properly.

Reviewed By: DurhamG

Differential Revision: D21669922

fbshipit-source-id: 84c8d09242ac8d5571f7592d874f4954692110f5
2020-05-20 14:03:50 -07:00
Xavier Deguillard
97a90e7de9 revisionstore: add doc comment
Summary:
We didn't have a high level overview of the types and traits and their
purposes, add that.

Reviewed By: DurhamG

Differential Revision: D21599759

fbshipit-source-id: 18e8d23ed00134f9d662778eddaee4a9451f7c2c
2020-05-18 12:11:52 -07:00
Xavier Deguillard
99f74f0155 lfs: move uploaded blobs to the shared store
Summary:
As a developpers is working on large blobs and iterating on them, the local LFS
store will be growing significantly over time, and that growth is unfortunately
unbounded and will never be cleaned up. Thankfully, one the guarantee that the
server is making is that an uploaded LFS blob will never be removed[0]. By using
this property, we can simply move blobs from the local store to the shared
store after uploading the blob is complete.

[0]: As long as it is not censored.

Reviewed By: DurhamG

Differential Revision: D21134191

fbshipit-source-id: ca43ddeb2322a953aca023b49589baa0237bbbc5
2020-05-13 12:50:20 -07:00
Xavier Deguillard
dc589c38e5 revisionstore: don't import unused format_err
Summary: The compiler is warning about it.

Reviewed By: singhsrb

Differential Revision: D21550266

fbshipit-source-id: 4e66b0dda0e443ed63aeccd888d38a8fcb5e4066
2020-05-13 10:44:07 -07:00
Ellis Hoag
1d0d626a36 Pass config object down to repack
Summary:
Pass `configparser::config::ConfigSet` to `repack` in
`revisionstore/src/repack.rs` so that we can use various config values in `filter_incrementalpacks`.

* `repack.maxdatapacksize`, `repack.maxhistpacksize`
  * The overall max pack size
* `repack.sizelimit`
  * The size limit for any individual pack
* `repack.maxpacks`
  * The maximum number of packs we want to have after repack (overrides sizelimit)

Reviewed By: xavierd

Differential Revision: D21484836

fbshipit-source-id: 0407d50dfd69f23694fb736e729819b7285f480f
2020-05-11 16:41:30 -07:00
Xavier Deguillard
1cd0bba3fa revisionstore: enable use of proxies for LFS
Summary:
If http_proxy.no is set, we should respect it to avoid sending traffic to it
whenever required.

Reviewed By: wez

Differential Revision: D21383138

fbshipit-source-id: 4c8286aaaf51cbe19402bcf8e4ed03e0d167228b
2020-05-11 10:36:11 -07:00
Xavier Deguillard
2001c3fd69 revisionstore: add translate_lfs_missing to remote store get
Summary:
When Qing implemented all the get method, the translate_lfs_missing function
didn't exist, and I forgot to add them in the right places when landing the
diff that added it. Fix this.

Reviewed By: sfilipco

Differential Revision: D21418043

fbshipit-source-id: baf67b0fe60ed20aeb2c1acd50a209d04dc91c5e
2020-05-11 10:34:01 -07:00
Xavier Deguillard
4e7303efd9 lfs: only upload when LFS blobs are present
Summary: If no LFS blobs needs uploading, then don't try to connect to the LFS server in the first place.

Reviewed By: DurhamG

Differential Revision: D21478243

fbshipit-source-id: 81fa960d899b14f47aadf2fc90485747889041e1
2020-05-08 13:24:21 -07:00
Meyer Jacobs
d49ac73f4c datastore: remove HgIdDataStore ::get_delta and ::get_delta_chain
Summary:
Remove HgIdDataStore::get_delta and all implementations. Remove HgIdDataStore::get_delta_chain from trait, remove all unnecessary implentations, remove all implementations from public Rust API. Leave Python API and introduce "delta-wrapping".

MutableDataPack::get_delta_chain must remain in some form, as it necessary to implement get using a sequence of Deltas. It has been moved to a private inherent impl.

DataPack::get_delta_chain must remain in some form for the same reasons, and in fact both implenetations can probably be merged, but it is also used in repack.rs for the free function repack_datapack. There are a few ways to address this without making DataPack::get_delta_chain part of the public API. I've currently chosen to make the method pub(crate), ie visible only within the revisionstore crate. Alternatively, we could move the repack_datapack function to a method on DataPack, or use a trait in a private module, or some other technique to restrict visibility to only where necessary.

UnionDataStore::get has been modified to call get on it's sub-stores and return the first which matches the given key.

MultiplexDeltaStore has been modified to implement get similarly to UnionDataStore.

Reviewed By: xavierd

Differential Revision: D21356420

fbshipit-source-id: d04e18a0781374a138395d1c21c3687897223d15
2020-05-07 11:04:01 -07:00
Zeyi (Rice) Fan
da28f5a5b1 revisionstore: create directory with group share permission in correct places
Summary: When we create directory at certain places, we want these directories to be shared between different users on the same machine. This Diff uses the previously added `create_shared_dir` function to create these directories.

Reviewed By: xavierd

Differential Revision: D21322776

fbshipit-source-id: 5af01d0fc79c8d2bc5f946c105d74935ff92daf2
2020-05-04 19:21:33 -07:00
Xavier Deguillard
86965b2f80 revisionstore: query store before fetching
Summary:
While the change looks fairly mechanical and simple, the why is a bit tricky.
If we follow the calls of `ContentStore::get`, we can see that it first goes
through every on-disk stores, and then switches to the remote ones, thanks to
that, when we reach the remote stores there is no reason to believe that the
local store attached to them contains the data we're fetching. Thus the
code used to always prefetch the data, before reading from the store what was
just written.

While this is true for regular stores (packstore, indexedlog, etc), it starts
to break down for the LFS store. The reason being that the LFS store is
internally represented as 2 halves: a pointer store, and a blob store.  It is
entirely possible that the LFS store contains a pointer, but not the actual
blob. In that case, the `get` executed on the LFS store will simply return
`Ok(None)` as the blob just isn't present, which will cause us to fallback to
the remote stores. Since we do have the pointer locally, we shouldn't try to
refetch it from the remote store, and thus why a `get_missing` needs to be run
before fetching from the remote store.

As I was writing this, I realized that all of this subtle behavior is basically
the same between all the stores, but unfortunately, doing a:
  impl<T: RemoteDataStore + ?Sized> HgIdDataStore for T
Conflicts with the one for `Deref<Target=HgIdDataStore>`. Macros could be used
to avoid code duplication, but for now let's not stray into them.

Reviewed By: DurhamG

Differential Revision: D21132667

fbshipit-source-id: 67a2544c36c2979dbac70dac5c1d055845509746
2020-04-27 12:53:11 -07:00
Qing Dong
b4edb7ff7f revisionstore: implement the get() functions on the various LocalDataStore interface
Summary: implement the get() functions on the various LocalDataStore interface implementations

Reviewed By: quark-zju

Differential Revision: D21220723

fbshipit-source-id: d69e805c40fb47db6970934e53a7cc8ac057b62b
2020-04-27 12:35:24 -07:00
Xavier Deguillard
39d49b694a revisionstore: remove memcache dependency on @mode/mac
Summary:
Memcache isn't available for Mac, but we can build the revisionstore with Buck
on macOS when building EdenFS. Let's only use Memcache for fbcode builds on
Linux for now.

Reviewed By: chadaustin

Differential Revision: D21235247

fbshipit-source-id: 5943ad84f6442e4dabbd2a44ae105457f5bb9d21
2020-04-24 17:29:36 -07:00
Xavier Deguillard
19bfd35298 revisionstore: multiplex stores should return a path on flush
Summary:
On repack, when the Rust stores are in use, the repack code relies on
ContentStore::commit_pending to return the path of a newly created packfile, so
it won't delete it when going over the repacked ones. When LFS is enabled, both
the shared and the local stores are behind the LfsMultiplexer store that
unfortunately would always return `Ok(None)`. In this situation, the repack
code would delete all the repacked packfiles, which usually is the expected
behvior, unless only one packfile is being repacked, in which case the repack
code effectively re-creates the same packfile, and is then subsequently
deleted.

The solution is for the multiplex stores to properly return a path if one was
returned from the underlying stores.

Reviewed By: DurhamG

Differential Revision: D21211981

fbshipit-source-id: 74e4b9e5d2f5d9409ce732935552a02bdde85b93
2020-04-23 15:14:28 -07:00
Durham Goode
faced01356 tracing: add more trace values
Summary: This will help us debug slow commands

Reviewed By: xavierd

Differential Revision: D21075895

fbshipit-source-id: 3e7667bb0e4426d743841d8fda00fa4a315f0120
2020-04-22 15:35:17 -07:00
Xavier Deguillard
51438d13e7 revisionstore: write data to store when reading from memcache
Summary:
The Memcache store is voluntarily added to the ContentStore read store, first
as a regular store, and then as a remote one. The regular store is added to
enable the slower remote store to write to it so that blobs are uploaded to
Memcache as we read them from the network. The subtle part of this is that the
HgIdDataStore methods should not do anything, or the data fetched won't be
written to any on-disk store, forcing a refetch next time the blob is needed.

Reviewed By: DurhamG

Differential Revision: D21132669

fbshipit-source-id: 96e963c7bb4209add5a51a5fc48bc38f6bcd2cd9
2020-04-21 18:35:38 -07:00
Xavier Deguillard
1d231ebac7 revisionstore: return non-uploaded keys
Summary:
Ideally, either the ContentStore, or the upper layer should verify that we
haven't missed uploading a blob, which could lead to weird behavior down the
line. For now, all the stores will return the keys of the blobs that weren't
uploaded, which allows us to return these keys to Python.

Reviewed By: DurhamG

Differential Revision: D21103998

fbshipit-source-id: 5bab0bbec32244291c65a07aa2a13aec344e715e
2020-04-20 21:02:35 -07:00
Lukas Piatkowski
6afe62eeaa eden/scm: split revisionstore into types and rest of logic
Summary:
The revisionstore is a large crate with many dependencies, split out the types part which is most likely to be shared between different pieces of eden/mononoke infrastructure.

With this split it was easy to get eden/mononoke/mercurial/bundles

Reviewed By: farnz

Differential Revision: D20869220

fbshipit-source-id: e9ee4144e7f6250af44802e43221a5b6521d965d
2020-04-14 07:50:19 -07:00
Xavier Deguillard
018e33237a revisionstore: upload local blobs
Summary:
On upload, read all the local blobs and upload them to the LFS server. This is
necessary to support `hg push` or `hg cloud sync` for local LFS blobs.

One of the change made here is to switch from having the batch method return an
Iterator to having them take a callback. This made it easier to write the gut
of the batch implementation in a more generic way.

A future change will also take care of moving local blobs to the shared store
after upload.

Reviewed By: DurhamG

Differential Revision: D20843136

fbshipit-source-id: 92d34a0971263829ff58e137e9905b527e18358d
2020-04-07 16:53:34 -07:00
Xavier Deguillard
0dca734464 revisionstore: add upload to RemoteDataStore
Summary: This method will be used to upload local LFS blobs to the LFS server.

Reviewed By: DurhamG

Differential Revision: D20843137

fbshipit-source-id: 33a331c42687c47442189ee329da33cb5ce4d376
2020-04-07 16:53:34 -07:00
Xavier Deguillard
80b222c01b revisionstore: use loose files for file backed LFS remote
Summary:
Loose files makes it easier to interact with a Mercurial server for tests, use
it instead of an IndexedLog.

Reviewed By: DurhamG

Differential Revision: D20786432

fbshipit-source-id: 61c1fc601d9a6ed157c5add9748e40840b081870
2020-04-07 16:53:34 -07:00
Xavier Deguillard
2ce3c6784b revisionstore: make ContentStore::sha256 infallible
Summary:
Instead of using Sha256::from_slice, just use Sha256::from with a correctly
sized array.

Reviewed By: quark-zju

Differential Revision: D20756181

fbshipit-source-id: 17c869325025078e4c91a564fc57ac1d9345dd15
2020-03-31 08:12:45 -07:00
Xavier Deguillard
22f524664e revisionstore: use Arc<Self> as receiver for remote store traits
Summary:
All of the callers are already using an Arc, so instead of forcing the remote
store to be cloneable, and thus wrap an inner self with an Arc, let's just pass
self as an Arc.

Reviewed By: DurhamG

Differential Revision: D20715580

fbshipit-source-id: 1bef23ae7da7b314d99cb3436a94d04134f1c0e4
2020-03-30 14:45:49 -07:00
Xavier Deguillard
6b1940f294 revisionstore: add fallback if LFS server is down
Summary:
When LFS will be enabled on fbsource, the enablement will rolled out server,
with the server serving pointers (or not). In the catastrophic scenario where
Mononoke has to be rolled out, the Mononoke LFS server will be unable to serve
blobs, but some clients may still have LFS pointers locally but not the
corresponding blob. For this, we need to be able to fallback to fetching the
blob via the getpackv2 protocol.

Reviewed By: DurhamG

Differential Revision: D20662667

fbshipit-source-id: 4ac45558f6d205cbd1db33c21c6fb137a81bdbd5
2020-03-30 14:45:48 -07:00
Xavier Deguillard
e7b5eb81d9 remotefilelog: add lfs fetching retry logic
Summary:
The LFS server might be temporarily having issues, let's retry a bit before
giving up.

Reviewed By: DurhamG

Differential Revision: D20686659

fbshipit-source-id: 90dabd19e45a681d6eae5cd50c72b635d44c0517
2020-03-30 14:45:48 -07:00
Xavier Deguillard
15c81cd54f revisionstore: repack even when having one packfile
Summary:
When repacking for the purpose of file format changes, a single packfile may
contain data that needs to be moved out of it, and thus, we need to do a repack
then.

Reviewed By: DurhamG

Differential Revision: D20677442

fbshipit-source-id: c621dd2e657f5a4565b37d4b029731415b899117
2020-03-30 14:45:47 -07:00
Xavier Deguillard
e0cfd08e7f revisionstore: properly implement get_missing for remote stores
Summary:
Remotestores can implement get_missing properly by simply querying the
underlying store that they will be writing to. This may prevent double fetching
some blobs in `hg prefetch` that we already have.

Reviewed By: DurhamG

Differential Revision: D20662668

fbshipit-source-id: 22140b5b7200c687e0ec723dd8879dc8fbea6fb9
2020-03-30 14:45:47 -07:00
Xavier Deguillard
e1ccc29eec revisionstore: add an is_local method to the IndexedLog abstraction
Summary:
There are cases where the user of the abstraction needs to know if this is a
local store, this will simplify the caller code.

Reviewed By: DurhamG

Differential Revision: D20662666

fbshipit-source-id: e0bde7eb0dc3484979732a7c4cdf888fedc70e13
2020-03-30 14:45:46 -07:00
Xavier Deguillard
8ed454845a revisionstore: auto-sync the LFS blobs store
Summary:
By regularly flushing the blob store, we avoid keeping too many LFS blobs in
memory, which could cause OOM issues.

The default size is chosen to be 1GB, but is configurable for more control.

Reviewed By: DurhamG

Differential Revision: D20646213

fbshipit-source-id: 12c06fd0212ef3974bea10c82026b6e74fb5bf21
2020-03-30 14:45:46 -07:00
Xavier Deguillard
5ea2e581c6 revisionstore: store LFS blobs in an IndexedLog
Summary:
In the legacy lfs extension, LFS blobs were stored as loosefiles on disk, and
as we saw with loosefiles for remotefilelog, they can incur a significant
overhead to maintain. Due to LFS blobs being large by definition, the number of
loose LFS blobs should be reasonable for repack to walk over all of them to
chose which one to throw away.

A different approach would be to simply store the blobs in an on-disk format
that allows automatic size management, and simple indexing. That format is an
IndexedLog. This of course doesn't come without drawbacks, the main one being
that the IndexedLog API mandate that the full blob is present on insertion,
preventing streaming writes to it, the solution is to simply chunk the blobs
before writing them to it. While proper streaming is not done just yet, the
storage format no longer prevent it from being implemented.

Reviewed By: DurhamG

Differential Revision: D20633783

fbshipit-source-id: 37a88331e747cf22511aa348da2d30edfa481a60
2020-03-30 14:45:46 -07:00
Xavier Deguillard
fd72344578 revisionstore: feature gate the Mononoke LFS tests
Summary:
Due to the Mononoke LFS server only being available on FB's network, the tests
using them cannot run outside of FB, including in the github workflows.

Reviewed By: quark-zju

Differential Revision: D20698062

fbshipit-source-id: f780c35665cf8dc314d1f20a637ed615705fd6cf
2020-03-30 08:40:43 -07:00
Xavier Deguillard
179caf60dd revisionstore: pass the config when building the LFS stores
Summary: Instead of hardcoding some values, use configured ones.

Reviewed By: DurhamG

Differential Revision: D20633784

fbshipit-source-id: d17657b1fca29280f2d07e8cf824e553ad3704f7
2020-03-26 19:02:49 -07:00
Xavier Deguillard
d404b0a228 revisionstore: revamp repack to ease file format migration
Summary:
One of the main drawback of the current version of repack is that it writes
back the data to a packfile, making it hard to change file format. Currently, 2
file format changes are ongoing: moving away from packfiles entirely, and
moving from having LFS pointers stored in the packfiles, to a separate storage.

While an ad-hoc solution could be designed for this purpose, repack can
fullfill this goal easily by simply writing to the ContentStore, the
configuration of the ContentStore will then decide where this data will
be written into.

The main drawback of this code is the unfortunate added duplication of code.
I'm sure there is a way to avoid it by having new traits, I decided against it
for now from a code readability point of view.

Reviewed By: DurhamG

Differential Revision: D20567118

fbshipit-source-id: d67282dae31db93739e50f8cc64f9ecce92d2d30
2020-03-26 19:02:48 -07:00
Xavier Deguillard
d4780ee322 revisionstore: store a HashMap of ContentHash in LFS pointer
Summary:
While the primary (for now) way of addressing an LFS blob is via its sha256,
being able to address them via different hash schemes (sha1 for Eden/Buck,
blake2, etc) will be helpful down the line. Thus, let's store a HashMap of
ContentHash in the pointer store.

Reviewed By: DurhamG

Differential Revision: D20560197

fbshipit-source-id: 8bdc4fc4cd7fc19c7eed6a27d11953c4eedf9195
2020-03-26 19:02:47 -07:00