Commit Graph

315 Commits

Author SHA1 Message Date
Adam Simpkins
d128becee7 add a few additional operations to eden_store_util
Summary:
Change eden_store_util to take a subcommand argument, and define 3 separate
subcommands: "gc", "clear", and "compact"

The "gc" was the old default behavior.  The "clear" and "compact" subcommands
simply clear cached entries and compact the storage, respectively.
This also adds a `--keySpace` argument.  If this argument is specified the
command will process only this single key space, instead of all key spaces.

Reviewed By: chadaustin

Differential Revision: D15043207

fbshipit-source-id: 7e76bc89862d9647edde631ed3d82c9afda09f41
2019-04-24 20:03:57 -07:00
Adam Simpkins
2faa637da5 move some logic from RocksHandles to RocksDbLocalStore
Summary:
This moves some logic from the RocksHandles class up to RocksDbLocalStore.
The main thing moved here is the logic to automatically try and repair the DB
if opening fails.  This will make it easier in a subsequent diff to make the
repair logic a bit smarter and more aware of our column family semantics.

This keeps RocksHandles a pretty dumb wrapper around the RocksDB object and
column family handles, whose only purpose is to manage destroying these two
things in the correct order.

Reviewed By: chadaustin

Differential Revision: D15043208

fbshipit-source-id: ee2d5619ac7781a892e1ba151712eee9e3ebfb14
2019-04-24 20:03:57 -07:00
Adam Simpkins
256422737d rename eden_gc to eden_store_util
Summary:
Move this utility from eden/fs/service to eden/fs/store, and rename it to
`eden_store_util`.

I originally put it in the `service` subdirectory since it depends on library
code from `service/`, and most of the other code in `store/` shouldn't depend
on code in `service/`.  However logically it makes sense to be in the `store/`
directory.

I plan to update in the future to be able to perform some additionally utility
operations besides just garbage collection, so rename it to the more generic
`eden_store_util` name.

Reviewed By: chadaustin

Differential Revision: D15043209

fbshipit-source-id: e6c4a874ddd05bd1576ea2e8a6c6156ccdf4628f
2019-04-24 20:03:57 -07:00
Zeyi Fan
02dcf44bd0 add curl verbose logging
Summary: Logging curl verbose messages to DBG9 for debugging purposes.

Reviewed By: simpkins

Differential Revision: D15038271

fbshipit-source-id: 578bdd3eba4bc89a056c8f3441f4efee0a1a6721
2019-04-22 18:47:29 -07:00
Chad Austin
ca7bc2f0f7 split rocksdb store tests into a separate target
Summary:
Build the store tests on mode/mac. RocksDB doesn't build yet (and we
will likely move away from it anyway) so split it into its own target.

Reviewed By: simpkins

Differential Revision: D15002840

fbshipit-source-id: fa0fea1d52df06526032a6fd585e2da7273910ef
2019-04-18 19:36:19 -07:00
Wez Furlong
1480c1d043 eden: apple/clang compiler portability fixes
Summary: These allow more tests to compile

Reviewed By: chadaustin

Differential Revision: D14994582

fbshipit-source-id: 6b2a0b276fda64c7f27e28ea9e6d548aaaa1db7c
2019-04-18 10:37:57 -07:00
Wez Furlong
22fb6614e9 eden: speculative fix for accidental copy
Summary:
Seeing this on one of our linux CI hosts:

```
FAILED: eden/fs/store/hg/CMakeFiles/eden_store_hg.dir/HgBackingStore.cpp.o
/usr/bin/c++  -DFOLLY_XLOG_STRIP_PREFIXES=\"/var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden:/var/sandcastle/temp/fbcode_builder_getdeps/build/eden-13470f\" -DGFLAGS_IS_A_DLL=0 -DGOOGLE_GLOG_DLL_DECL="" -DGOOGLE_GLOG_DLL_DECL_FOR_UNITTESTS="" -I. -I/var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/googletest-520b8c/include -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/libgit2-c32720/include -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/fb-mercurial-53e1c8 -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/sqlite3-998248/include -I/var/sandcastle/temp/fbcode_builder_getdeps/installed/lz4-9c269f/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/gflags-425c30/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/fizz-680c3e/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/wangle-7a56ae/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/thrift-3c4bca/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/boost-864c2c/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/double-conversion-3e811f/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/glog-81244a/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/libevent-ff5d17/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/zstd-f1c315/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/snappy-d394bb/include -isystem /usr/include/libdwarf -isystem /usr/include/libiberty -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/libsodium-9066a8/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/rsocket-cpp-e998e5/include -isystem /var/sandcastle/temp/fbcode_builder_getdeps/installed/rocksdb-88d1cb/include -O2 -g -DNDEBUG   -pthread -std=gnu++1z -MD -MT eden/fs/store/hg/CMakeFiles/eden_store_hg.dir/HgBackingStore.cpp.o -MF eden/fs/store/hg/CMakeFiles/eden_store_hg.dir/HgBackingStore.cpp.o.d -o eden/fs/store/hg/CMakeFiles/eden_store_hg.dir/HgBackingStore.cpp.o -c /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.cpp
In file included from /var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/futures/Future.h:28:0,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/BackingStore.h:12,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.h:14,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.cpp:10:
/var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/Try.h: In instantiation of ‘folly::Try<T>::Try(const T&) [with T = std::unique_ptr<facebook::eden::Tree>]’:
/var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/futures/Future-inl.h:148:24:   required from ‘folly::futures::detail::FutureBase<T>::FutureBase(T2&&) [with T2 = std::unique_ptr<facebook::eden::Tree>&; <template-parameter-2-2> = void; T = std::unique_ptr<facebook::eden::Tree>]’
/var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/futures/Future.h:958:63:   required from ‘folly::Future<T>::Future(T2&&) [with T2 = std::unique_ptr<facebook::eden::Tree>&; <template-parameter-2-2> = void; T = std::unique_ptr<facebook::eden::Tree>]’
/var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.cpp:526:12:   required from here
/var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/Try.h:80:45: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = facebook::eden::Tree; _Dp = std::default_delete<facebook::eden::Tree>]’
       : contains_(Contains::VALUE), value_(v) {}
                                             ^
In file included from /usr/include/c++/7/memory:80:0,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/installed/folly-074709/include/folly/dynamic.h:56,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/config/EdenConfig.h:12,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.h:12,
                 from /var/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/fs/store/hg/HgBackingStore.cpp:10:
/usr/include/c++/7/bits/unique_ptr.h:388:7: note: declared here
       unique_ptr(const unique_ptr&) = delete;
       ^~~~~~~~~~
```

Reviewed By: fanzeyi

Differential Revision: D14987986

fbshipit-source-id: cbfe83619591d385cf9acb385254bb028aec1b4c
2019-04-17 21:03:54 -07:00
Zeyi Fan
a8c149437a add stats collecting for hg & mononoke backing store
Summary: This diff add four metrics to the stats we are collecting in Eden. Both time cost on calling `get_tree` and `get_blob` from hg and mononoke backing store.

Reviewed By: chadaustin

Differential Revision: D14780349

fbshipit-source-id: f0e902c7f7523fac2ae576a67f0c85555064e26c
2019-04-17 13:10:21 -07:00
Adam Simpkins
e6475d7693 remove the code that flushes all RocksDB columns on startup
Summary:
This effectively reverts D14452214, which caused Eden to write an `id` entry
to each RocksDB column family and then flush the column family each time
edenfs started.

There was relatively little benefit to this in practice.  It only matters in
cases where the RocksDB column families never had enough data written to them
to get flushed automatically and then a repair is required.

On the other hand it does have some material downsides: it flushing the column
families can be fairly expensive, and can require a substantial amount of free
disk space.  This flush caused some users to not be able to start up edenfs
when they did not have enough free disk space.

Reviewed By: chadaustin

Differential Revision: D14947235

fbshipit-source-id: a29f98163fa87185b028bb47945b6fab75700fd6
2019-04-16 11:01:25 -07:00
Adam Simpkins
07902b6a3c improve the "gc" implementation for RocksDB
Summary:
Change the `eden gc` implementation to use RocksDB's `DeleteFilesInRange()`
function, as well as its new-ish `DeleteRange()` method.

This makes the garbage collection much faster, and also require much less free
disk space than previously.

`DeleteFilesInRange()` asks RocksDB to simply delete all SST files from disk
if they only contain keys in the specified range.  Since the range we specify
should include all keys in the DB this should simply drop all SST files for
this column family.

We also call `DeleteRange()` after this, just in case.  This API is relatively
recent, and writes a single tombstone saying that the specified range has been
deleted.

Reviewed By: wez

Differential Revision: D14910345

fbshipit-source-id: c76bdc1c8e07cb2def66673ea892e7f455c9dc7a
2019-04-15 12:33:09 -07:00
Matt Glazar
1057039562 Encapsulate EdenStats
Summary:
EdenStats is currently an alias for ThreadLocal<EdenThreadStats>. I want to split EdenThreadStats into two structs which are allocated independently, but EdenStats's interface makes this impossible.

Refactor EdenStats from an alias to a class and encapsulate the underlying ThreadLocal<EdenThreadStats> member.

This diff should not change behavior.

Reviewed By: simpkins

Differential Revision: D14822272

fbshipit-source-id: 691f4731aa22ecbdcd3535ee0bb0b99c816ffc3d
2019-04-14 20:45:16 -07:00
Matt Glazar
11195c2b0b Rename ThreadLocalEdenStats to EdenStats
Summary:
I'm confused by the naming of EdenThreadStats and ThreadLocalEdenStats. For example, when I see "ThreadLocalEdenStats", I think that such objects can only be accessed by one thread. That's definitely not what "ThreadLocalEdenStats" means!

I think the following naming scheme makes more sense:

* **EdenThreadStats**: Statistics which are updated by one thread. Currently called EdenThreadStats.
* **EdenStats**: Statistics for all threads. Provides access to EdenThreadStats. Currently called ThreadLocalEdenStats.

Implement my preferred scheme: rename ThreadLocalEdenStats to EdenStats.

This diff should not change behavior.

Note: Prior to D14822274, EdenThreadStats was called EdenStats.

Reviewed By: simpkins

Differential Revision: D14822271

fbshipit-source-id: bd20179b1010588e3fc16dc9ed0657d458606f16
2019-04-14 20:45:16 -07:00
Zeyi Fan
34762da68d use ServiceAddress in curl implementation
Summary: This diff makes `MononokeCurlBackingStore` uses `ServiceAddress` for getting address of Mononoke service.

Reviewed By: chadaustin

Differential Revision: D14864675

fbshipit-source-id: 5c3d5e82a3bd6b55ff722427b3f44d20a3544a1d
2019-04-12 11:22:25 -07:00
Zeyi Fan
700d298136 use ServiceAddress in proxygen implementation
Summary: This diff makes `MononokeHttpBackingStore` uses `ServiceAddress` to manage remote address of the Mononoke API Server.

Reviewed By: chadaustin

Differential Revision: D14855661

fbshipit-source-id: 1c102f7b2c547dc6a5b5c2cba65a513313d90bdc
2019-04-12 11:22:25 -07:00
Matt Glazar
37a993bf42 Track how many HgImporter requests are made
Summary:
Sometimes, EdenFS goes bonkers and talks to 'hg debugedenimporthelper' a lot for seemingly no reason.

Make these situations easier to debug by counting how many requests EdenFS makes to 'hg debugedenimporthelper'. These counters let us answer questions such as the following:

* When performance sucks, is EdenFS is making a lot of requests or only a few requests? I.e. is Hg slow at responding or is EdenFS very demanding?
* Does a recent performance issue correlate with EdenFS communicating with 'hg debugedenimporthelper'?
* Which engineers are outliers having orders of magnitude more 'hg debugedenimporthelper' requests than p50 engineers?

We could get fancier with these counters and include the number of bytes received, the duration of the request, etc. For now, just having a request count is useful.

Reviewed By: simpkins

Differential Revision: D14677339

fbshipit-source-id: 7f8f394fb0096aef65d6a8a45d7da5936db539a0
2019-04-10 19:58:16 -07:00
Zeyi Fan
bbb0bc276e dynamically initialize mononoke backing stores
Summary: Move Mononoke backing store initialization process to every request so we can adjust the configuration value without restarting the process.

Reviewed By: strager

Differential Revision: D14583357

fbshipit-source-id: 49ce2736229ce3062d34337757ebda6bb6eae16a
2019-04-08 13:48:14 -07:00
Matt Glazar
4efa71411c Delete unused forward declaration
Reviewed By: wez

Differential Revision: D14823485

fbshipit-source-id: 480131db0ee9c66e18d6737a55b0416e47308c74
2019-04-08 11:20:55 -07:00
Stefan Filip
a2a0658ebe hg: update prefetch test with utf8 filenames
Summary:
We updating the encoding that mercurial uses for storing paths to UTF-8.
The current step is preventing files that have invalid names from being
committed. To that end we are updating the HgPrefetch test to submit
valid file names (valid UTF-8). This allows us to start using UTF-8
encoded string for the internal representation of file paths.

Doing encoding transformation between internal storage and system locale will
be implemented later. Normalization should also be handled at that point.

Reviewed By: simpkins

Differential Revision: D14812780

fbshipit-source-id: 1689910500391eed941df185ba92aa2d2f3f0960
2019-04-05 16:29:50 -07:00
Adam Simpkins
5eb2009088 drop the log level of a message in RocksDbLocalStore
Summary:
This message was added in D14337058.  It is logged at the `INFO` level, which
is enabled by default, but doesn't seem to add much value to normal production
logs.

Reviewed By: chadaustin

Differential Revision: D14712654

fbshipit-source-id: 5a86d883ace30e22d299046e33a6cd6247432857
2019-04-01 14:53:02 -07:00
Wez Furlong
f8099e5129 eden: cmake fixup include directories and deps
Summary:
While testing out the new getdeps code I found that none
of the include directories from the probed libraries were being used.

The new getdeps installs each dep into its own prefix, whereas the
existing getdeps script installed them into the installation
prefix for eden itself.  That meant that they were being implicitly
found from a single include directory.

In addition to this, I encountered linker failures for the pretty
printers; the solution to those was to add appropriate deps for
the modules that depend upon the pretty printers.

Reviewed By: pkaush

Differential Revision: D14638758

fbshipit-source-id: a4c2b4c79603c268e1b1c707a05c3cb0e3f2757b
2019-03-28 20:57:17 -07:00
Wez Furlong
df5f035b7f eden: fixup mononoke related opensource linux build
Summary:
This function depends on things that are not available
when EDEN_HAVE_HG_TREEMANIFEST is not enabled.

Ensure that the entire function is disabled if that is the case.

Reviewed By: chadaustin

Differential Revision: D14638759

fbshipit-source-id: 3fe83b7b42357c2b818469214b016ff591058e35
2019-03-28 20:57:17 -07:00
Zeyi Fan
31186d275d enable Mononoke thrift backing store
Summary: This diff enables thrift as a type of connection when talks to Mononoke API Server.

Reviewed By: strager, pkaush

Differential Revision: D14508956

fbshipit-source-id: 32e130c714be164f19452dec554976ea1cb594d3
2019-03-26 13:47:15 -07:00
Zeyi Fan
84b535fe3c Add MononokeThriftBackingStore
Summary: Implement a backing store that uses thrift protocol to communicate with Mononoke API Server.

Reviewed By: strager

Differential Revision: D13966575

fbshipit-source-id: 66f66dda6b17aecd6c6b4475ab6b004c608f457f
2019-03-26 13:47:15 -07:00
Puneet Kaushik
d42b639e3e Use hg import subcommand on Windows
Reviewed By: chadaustin

Differential Revision: D14314008

fbshipit-source-id: edfb600d4a9fa921bbcb4204b9a0a87ef042c185
2019-03-20 21:50:50 -07:00
Adam Simpkins
9e1805c9e0 explicitly flush all column families when opening the RocksDB
Summary:
When opening the RocksDB, write one entry to each column family and then
explicitly flush that column family.  This ensures that the column family
information has actually been flushed to an SST file.  Without this some
column families may only have been written out to the write-ahead log files.
(Even calling `db->Flush()` does not appear to be sufficient; each column
family has to be explicitly flushed.)

The RocksDB' `RepairDB()` function (used by `ldb repair`) currently ends up
deleting column families that do not have any data defined in an SST file.
The repair tool ends up deleting column families that only have data in log
files.

The fact that we haven't been doing these explicit flushes previously probably
isn't too much of a concern in practice: once we write out enough data RocksDB
will automatically trigger a flush.  This only matters in cases where we have
not yet written out enough data to trigger an automatic flush.

Note that with this change we re-write these `id` keys each time we open the
RocksDB store, even if they were already present.

Reviewed By: chadaustin, strager

Differential Revision: D14452214

fbshipit-source-id: 3f1b17e240cc89fe00e3d31105d16452795e754d
2019-03-18 11:36:42 -07:00
Matt Glazar
3b9a0310a1 Fix deadlock when restarting during RocksDbLocalStore::get()
Summary:
If TreeInode::startLoadingInode() is in progress, and EdenServer::startTakeoverShutdown() is called, edenfs can deadlock:

1. Thread A: A FUSE request calls TreeInode::readdir() -> TreeInode::prefetch() -> TreeInode::startLoadingInode() on the children TreeInode-s -> RocksDbLocalStore::getFuture().
2. Thread B: A takeover request calls EdenServer::performTakeoverShutdown() -> InodeMap::shutdown().
3. Thread C: RocksDbLocalStore::getFuture() (called in step 1) completes -> TreeInode::inodeLoadComplete(). (The inodeLoadComplete continuation was registered by TreeInode::registerInodeLoadComplete().)
4. Thread C: After TreeInode::inodeLoadComplete() returns, the TreeInode's InodePtr is destructed, dropping the reference count to 0.
5. Thread C: InodeMap::onInodeUnreferenced() -> InodeMap::shutdownComplete() -> EdenMount::shutdown() (called in step 2) completes -> EdenServer::performTakeoverShutdown().
6. Thread C: EdenServer::performTakeoverShutdown() -> localStore_.reset() -> RocksDbLocalStore::~RocksDbLocalStore().
7. Thread C: RocksDbLocalStore::~RocksDbLocalStore() signals the thread pool to exit and waits for the pool's threads to exit. Because thread C is one of the threads managed by RocksDbLocalStore's thread pool, the signal is never handled and RocksDbLocalStore::~RocksDbLocalStore() never finishes.

Fix this deadlock by executing EdenServer::shutdown()'s callback (in EdenServer::performTakeoverShutdown()) on a different thread.

Reviewed By: simpkins

Differential Revision: D14337058

fbshipit-source-id: 1d63b4e7d8f5103a2dde31e329150bf763be3db7
2019-03-12 19:29:35 -07:00
Zeyi Fan
fa10788fce Reuse CURL* handle from curl_easy interface
Summary: Since `CurlClient` is going to be used in multiple threads and each thread has its own instance of CurlClient, we are now able to assign one curl_easy handle for each of the client. So curl would be able to reuse the existing connections to Mononoke API Server.

Reviewed By: chadaustin

Differential Revision: D14334486

fbshipit-source-id: aacd210773c44dea6f1d9dd7f9b09d765a9c7a0a
2019-03-11 14:34:09 -07:00
Zeyi Fan
16687decb2 Use thread factory for curl clients
Summary: Put `CurlClient` into its own thread pool (like how `HgBackingStore` uses `HgImporter`)

Reviewed By: chadaustin

Differential Revision: D14334483

fbshipit-source-id: 3ce2a8245761c11bfa0f66691d10a66004b46fe6
2019-03-11 14:34:09 -07:00
Zeyi Fan
199eb0ed42 Use MononokeCurlBackingStore in HgBackingStore
Summary: This diff enables `MononokeCurlBackingStore` in HgBackingStore. It also adds a new config value `mononoke:connection-type` (values: `http`, `curl` and `thrift`).

Reviewed By: chadaustin

Differential Revision: D14135028

fbshipit-source-id: cc6fb95d94b3d98996d872d22ad1a95a97d562ab
2019-03-11 14:34:09 -07:00
Zeyi Fan
21a6606e1f Add MononokeCurlBackingStore
Summary: This diff add a MononokeBackingStore implemented based on libcurl so we could add Mononoke support on macOS.

Reviewed By: chadaustin

Differential Revision: D14096313

fbshipit-source-id: 2bcb0c49002dcbb0a0190ba505a6e814e74db747
2019-03-11 14:34:08 -07:00
Zeyi Fan
d9f1beb1a1 add mononoke:connector config and create initializeHttpMononokeBackingStore
Summary:
This diff added a configurable value "mononoke:connector" to EdenConfig, so that we can specify a particular type of connection we need when using Mononoke as backing store.

This diff also moved the logic of initializing the existing `MononokeHttpBackingStore` to `initializeHttpMononokeBackingStore`.

Reviewed By: wez, strager

Differential Revision: D14141725

fbshipit-source-id: c7208295d7b3853740d7b0e5166f8854457fcf8e
2019-03-11 14:34:08 -07:00
Adam Simpkins
01490a26da improve error messages if the hg import helper fails to start
Summary:
Throw a slightly nicer error message if the hg import helper exits before
returning a `CMD_STARTED` response or an error response.

When switching from the `hg_import_helper.py` script to the
`hg debugedenimporthelper` subcommand we are slightly more likely to encounter
errors during startup.  For instance, if the repository path was not a valid
repository the `hg_import_helper.py` code would send an error message back
that the `HgImporter.cpp` code could parse.  However, we unfortunately can't
catch errors loading the repository the same way when using an `hg`
subcommand.  If it fails to load the repository it will simply print an error
message to stderr and then bail out before it invokes the
`debugedenimporthelper` code.

Reviewed By: chadaustin

Differential Revision: D14222266

fbshipit-source-id: cd60e5a61725d45a816b74f63b9969b29ade2160
2019-02-27 13:46:36 -08:00
Adam Simpkins
21c5e34e33 move hg_import_helper.py back to bin/, update edenfs to find it
Summary:
This reverts the change in D14188312 that moved `hg_import_helper.py` from
`bin/` to `libexec/eden/`, and instead updates edenfs to look for
`hg_import_helper.py` at `../../bin/hg_import_helper.py`

We cannot remove `hg_import_helper.py` from `/usr/local/bin` without breaking
existing running `edenfs` daemons as they will continue to look for
`hg_import_helper.py` in this location.

Rather than keeping a copy in both `bin/` and `libexec/eden` it seems better
to simply update edenfs so that it can correctly find `hg_import_helper.py`
even when edenfs itself has been installed in `libexec/eden/`

Reviewed By: strager

Differential Revision: D14197390

fbshipit-source-id: 2845bd79343bc29af9d3acbacecac4501cdb9032
2019-02-22 19:49:45 -08:00
Zeyi Fan
8535c7fe69 rename MononokeBackingStore to MononokeHttpBackingStore
Summary: Rename `MononokeBackingStore` to `MononokeHttpBackingStore`. Also fixed some pre-existing issues regarding copying & constants.

Reviewed By: wez, strager

Differential Revision: D14140968

fbshipit-source-id: 832ce449167584e1684031655514bba7d1435e01
2019-02-22 12:22:00 -08:00
Puneet Kaushik
b2ad632b62 Moving #ifdef out of macro expansion to fix the Windows build.
Reviewed By: wez

Differential Revision: D14125839

fbshipit-source-id: 455e573b4645c3009f33baccd6a14200eb0d6313
2019-02-19 10:50:48 -08:00
Wez Furlong
ab03aa78c2 eden: hg_import_helper.py execs hg debugedenimporthelper
Summary:
Now that `hg debugedenimporthelper` has been released for
a little while, we can remove the bundled implementation of it from
the eden release.

However, we cannot remove the script itself as there are users
with long running edenfs instances that pre-date the knowledge
of `hg debugedenimporthelper`.   So, as a compatibility shim,
this diff redirects `hg_import_helper.py` and has it exec the
command in mercurial.

For extra fun, our own integration tests rely on being able
to import `hg_import_helper.py` and override portions of it,
so we cannot remove its implementation from the codebase just
yet either.

So this diff:

* Introduces `proxy_import_helper.py` which execs `hg debugedenimporthelper`
* Installs `proxy_import_helper.py` as `hg_import_helper.py` in the rpm
* Leave `hg_import_helper.py` as-is in the tree for now.

Reviewed By: simpkins

Differential Revision: D13970332

fbshipit-source-id: 717dc86a880fbbbe4a7e801a8b748abd053c7f7c
2019-02-14 22:27:00 -08:00
Wez Furlong
995f140d67 eden: resolve hg.real from $PATH on unix systems
Summary:
in D13970332 we want to allow using `hg.real` to run the
import helper that is embedded into mercurial, but we don't know
the full path, so we need to resolve it from the environment.

`folly::Subprocess` has `usePath` option, but it is not compatible
with also overriding the environment for a child process.

The easiest short term thing to do is to resolve the path ourselves
using this simple function call.

I've also added the path to `hg.real` that is used on our mac systems
to the PATH we pass down to `edenfs` when starting eden.

Longer term we want to better encapsulate how we resolve and start
the import helper, but for now this unblocks starting eden on the
mac.

Reviewed By: strager

Differential Revision: D14078612

fbshipit-source-id: bc6787bbe99cd87224b783d2fb9d3255b825b976
2019-02-14 22:27:00 -08:00
Michael Liu
b626f922ce Apply modernize-use-override (2nd iteration)
Summary:
Use C++11’s override and remove virtual where applicable.
Change are automatically generated.

Reviewed By: simpkins

Differential Revision: D14087291

fbshipit-source-id: 80e6a393c5ed8ea1656855da3832bcee10635004
2019-02-14 17:29:27 -08:00
Chad Austin
c0955f75d2 split the RocksDB local store into its own Buck target
Summary:
I don't have RocksDB building in mode/mac yet, and the inode code
only depends on the store interface, not all of the specific
implementations.

Reviewed By: simpkins, strager

Differential Revision: D14036390

fbshipit-source-id: d0b8d5c4d4f2f38dbc9bc2476c24ac99398d37b7
2019-02-13 15:53:46 -08:00
Lee Howes
4076449871 onerror to thenerror phase 2
Summary:
Replace Future::onError with Future::thenError:
 * to remove ambiguous typing
 * to ensure that the executor is not lost and the returned Future is still bound to an executor

See:
https://fb.workplace.com/groups/fbcode/permalink/2002251863144976/
for details.

Reviewed By: yfeldblum

Differential Revision: D13908257

fbshipit-source-id: 8b5315b019290f1c60087ca5716c31ebbf1f1be5
2019-02-01 13:16:50 -08:00
Jun Wu
1bdd58960e Fix hg_import_helper import path
Summary: `hgext` was moved to `edenscm.hgext`.

Reviewed By: simpkins

Differential Revision: D13884629

fbshipit-source-id: 4bf69720cccbd43665cd350ac8a3ba4d46b10b93
2019-01-30 14:49:01 -08:00
Lee Howes
967e3f8a1c Future::onError replaced with Future::thenError
Summary:
Replace Future::onError with Future::thenError:
 * to remove ambiguous typing
 * to ensure that the executor is not lost and the returned Future is still bound to an executor

See:
https://fb.workplace.com/groups/fbcode/permalink/2002251863144976/
for details.

Reviewed By: yfeldblum

Differential Revision: D13784772

fbshipit-source-id: 1d3ede848b7d31c7a197a21b4ff2b31e840040a5
2019-01-30 09:56:15 -08:00
Jun Wu
ff1357e076 codemod: import from the edenscm package
Summary:
D13853115 adds `edenscm/` to `sys.path` and code still uses `import mercurial`.
That has nasty problems if both `import mercurial` and
`import edenscm.mercurial` are used, because Python would think `mercurial.foo`
and `edenscm.mercurial.foo` are different modules so code like
`try: ... except mercurial.error.Foo: ...`, or `isinstance(x, mercurial.foo.Bar)`
would fail to handle the `edenscm.mercurial` version. There are also some
module-level states (ex. `extensions._extensions`) that would cause trouble if
they have multiple versions in a single process.

Change imports to use the `edenscm` so ideally the `mercurial` is no longer
imported at all. Add checks in extensions.py to catch unexpected extensions
importing modules from the old (wrong) locations when running tests.

Reviewed By: phillco

Differential Revision: D13868981

fbshipit-source-id: f4e2513766957fd81d85407994f7521a08e4de48
2019-01-29 17:24:53 -08:00
Jun Wu
bef1006071 codemod: move Python packages to edenscm
Summary:
Move top-level Python packages `mercurial`, `hgext` and `hgdemandimport` to
a new top-level package `edenscm`. This allows the Python packages provided by
the upstream Mercurial to be installed side-by-side.

To maintain compatibility, `edenscm/` gets added to `sys.path` in
`mercurial/__init__.py`.

Reviewed By: phillco, ikostia

Differential Revision: D13853115

fbshipit-source-id: b296b0673dc54c61ef6a591ebc687057ff53b22e
2019-01-28 18:37:31 -08:00
Wez Furlong
a545acbbd4 eden: add C datapack/treemanifest to cmake build
Summary:
This requires our mercurial repo to be available during
the build; I symlink it in alongside `common` in the `oss` dir,
and point it up to `scm/hg`.

This has partial support for mononoke too, but will need to add
logic to getdeps to pull down the proxygen repo and build that.

Reviewed By: simpkins

Differential Revision: D13480146

fbshipit-source-id: 54874245015af83a259f56944d2e5f87615baee7
2019-01-17 18:52:53 -08:00
Wez Furlong
e30628c964 hg: add eden import helper debug command
Summary:
In our linux deployments it was relatively straightforward
to import the mercurial runtime from a python process running the
system python executable.   Our macOS deployments are a lot more
complex because they do not use the system python and do not install
the mercurial python packages in the python path of the target
python executable.

It is simpler to move the import helper functional into a mercurial
command that we can invoke instead of our own helper program.

This diff moves the script to be a debug command and adjusts its
argument parsing to match the mercurial dispatcher requirements.

There are some stylistic mismatches between this code and the
rest of mercurial; I'm suggesting that we ignore those as the
medium term solution is that this command is replaced by eden
directly consuming the rust config parsing code and by native
rust code to perform the data fetching that we need.

Reviewed By: pkaush

Differential Revision: D13522225

fbshipit-source-id: 28d751c5de4228491924df4df88ab382cfbf146a
2019-01-16 19:44:21 -08:00
Chad Austin
d42ea29476 convert BlobAccess tests to use FakeBackingStore
Summary:
In the future, we will likely coalesce redundant fetches at the
BlobAccess/ObjectStore layer. To measure what we actually want,
populate a normal ObjectStore with a NullLocalStore and add counters
to FakeBackingStore.

Reviewed By: wez

Differential Revision: D13454331

fbshipit-source-id: 2fbf393d159f94e84c24ac53ccc207162fa754b7
2019-01-10 16:28:05 -08:00
Wez Furlong
1b5709f273 eden: fixup cmake defines for some optional features
Summary:
a couple of parts of the rust, datapack and mononoke code
didn't have appropriate definitions.

Allow `useDatapackGetBlob_` to be default initialized per its
definition in the header file rather than replicating the relatively
complex ifdef logic in the implementation.

Reviewed By: strager

Differential Revision: D13475710

fbshipit-source-id: d2955c9b22f1186f5897aa8bdbd9046b8f6b5f7a
2018-12-17 20:16:19 -08:00
Adam Simpkins
c599906cb6 switch the mononoke tests to use the simpler ScopedHTTPServer API
Summary:
ScopedHTTPServer allows callers to specify a simple request handler function
instead of having to define their own handler factory.  This updates the
MononokeBackingStore tests to change the `Handler` class in to a simpler
functor object, and delete the `HandlerFactory` class.

Reviewed By: wez

Differential Revision: D13476411

fbshipit-source-id: 0ede232ff9570c95e877b689272ea8eb26d97d83
2018-12-17 19:15:36 -08:00
Adam Simpkins
f116c2c9ff update the mononoke tests to use ScopedHTTPServer
Summary:
Change the code to use ScopedHTTPServer instead of its own custom logic that
starts a server and runs all of the test logic inside the `onSuccess()`
callback.

Doing all of the test logic inside `onSuccess()` is generally bad, as most of
the tests perform blocking `get()` calls on `folly::Future` objects.  Blocking
work generally should not be done from inside EventBase threads.

When built with ASAN these tests occasionally crash with heap-use-after-free
errors during the HTTP server shutdown.  I didn't track down the exact bad
behavior that was causing this, but attempting to stop the server from inside
the `onSuccess()` callback does seem a little fishy.  Hopefully simply
switching to `ScopedHTTPServer` will fix this issue.

Reviewed By: wez

Differential Revision: D13476413

fbshipit-source-id: ab92cc16a5bf99a5e7b52529012a03786495c319
2018-12-17 19:15:36 -08:00