Commit Graph

54 Commits

Author SHA1 Message Date
Alex Hornby
2d0b7db627 mononoke: allow cmdlib init_logging to return a Result
Summary: Allow us to return arg parsing errors rather than panicing

Reviewed By: krallin

Differential Revision: D25837626

fbshipit-source-id: 87e39de140b1dcd3b13a529602fdafc31233175d
2021-01-14 09:52:40 -08:00
Egor Tkachenko
11dd72d6c5 Add unbundlereplay command
Summary:
Unbundlereplay command was not implemented in the mononoke but it is used by sync job. So let's add this command here
together with additional integration test for sync between 2 mononoke repos. In addition I'm adding non fast forward bookmark movements by specifying key to sync job.

Reviewed By: StanislavGlebik

Differential Revision: D25803375

fbshipit-source-id: 6be9e8bfed8976d47045bc425c8c796fb0dff064
2021-01-07 20:36:26 -08:00
Daniel Xu
1e78d023e7 Update regex to v1.4.2
Summary: Update so libbpf-cargo doens't need to downgrade regex version.

Reviewed By: kevin-vigor

Differential Revision: D25719327

fbshipit-source-id: 5781871a359f744e2701a34df1931f0c37958c27
2020-12-29 22:59:52 -08:00
Aida Getoeva
8b93f52b71 mononoke/mysql: use single static shared connection pool
Summary:
The correct workflow for using a multi-threaded connection pool for multiple DBs is to have a single shared pool for all the use-cases. The pool is smart enough to maintain separate "pools" for each DB locator and limit them to maximum 100 conn per key.

In this diff I create a `OnceCell` connection pool that is initialized once and reused for every attempt to connect to the DB.
The pool is stored in `MononokeAppData` in order to bind its lifetime to the lifetime of Mononoke app. Then it is passed down as a part of `MysqlOptions`.  Unfortunately this makes `MysqlOptions` not copyable, so the diff also contains lots of "clones".

Reviewed By: ahornby

Differential Revision: D25055819

fbshipit-source-id: 21f7d4a89e657fc9f91bf22c56c6a7172fb76ee8
2020-12-17 15:46:30 -08:00
Aida Getoeva
e9f3284b5b mononoke/mysql: make mysql options not copyable
Summary:
In the next diff I'm going to add Mysql connection object to `MysqlOptions` in order to pass it down from `MononokeAppData` to the code that works with sql.
This change will make MysqlOptions un-copyable.

This diff fixed all issues produced by the change.

Reviewed By: ahornby

Differential Revision: D25590772

fbshipit-source-id: 440ae5cba3d49ee6ccd2ff39a93829bcd14bb3f1
2020-12-17 15:46:30 -08:00
Pavel Aslanov
0fc5c3aca7 convert BlobRepoHg to new type futures
Summary: Convert all BlobRepoHg methods to new type futures

Reviewed By: StanislavGlebik

Differential Revision: D25471540

fbshipit-source-id: c8e99509d39d0e081d082097cbd9dbfca431637e
2020-12-17 07:45:26 -08:00
Stefan Filip
2193b84b43 autocargo: regen
Summary: Regen autocargo

Reviewed By: quark-zju

Differential Revision: D25409963

fbshipit-source-id: 7dbbe420aeb30248bf43d3a96a9aa6a47bb2b0be
2020-12-08 18:30:24 -08:00
Thomas Orozco
16bac45a07 mononoke/bonsai_globalrev_mapping: set perf counters
Summary:
Like it says in the title. This is helpful to measure the number of SQL queries
we make. This required actually threading in a CoreContext, which we didn't
have before.

Reviewed By: StanislavGlebik

Differential Revision: D25336069

fbshipit-source-id: 35677c55550e95b5126de29c2a824b4eda32092c
2020-12-07 08:23:19 -08:00
Thomas Orozco
1ec5537e9e mononoke/bonsai_globalrev_mapping: update to futures 0.3
Summary: Like it says in the title.

Reviewed By: StanislavGlebik

Differential Revision: D25333450

fbshipit-source-id: 49ad4b1964a4dfd9f3e0108fa421d451ef905256
2020-12-07 08:23:18 -08:00
Alex Hornby
935a7ddfc8 mononoke: remove the need to pass in cachelib settings twice
Summary:
Previously needed to pass in cachelib settings once to MononokeAppBuilder and once to parse_and_init_cachelib.

This change adds a MononokeClapApp and MononokeMatches that preserve the settings, thus preventing the need to pass them in twice (and thus avoiding possible inconsistency)

MononokeMatches uses MaybeOwned to hold the inner ArgMatches, which allows us to hold both the usual reference case from get_matches and an owned case for get_matches_from which is used in test cases.

Reviewed By: krallin

Differential Revision: D24788450

fbshipit-source-id: aad5fff2edda305177dcefa4b3a98ab99bc2d811
2020-12-02 07:27:23 -08:00
Alex Hornby
f077f69408 mononoke: move expected_item_size_byte into CachelibSettings
Summary:
Move expected_item_size_byte into CachelibSettings, seems like it should be there.

To enable its use also exposes a parse_and_init_cachelib method for callers that have different defaults to default cachelibe settings.

Reviewed By: krallin

Differential Revision: D24761024

fbshipit-source-id: 440082ab77b5b9f879c99b8f764e71bec68d270e
2020-12-02 00:47:22 -08:00
Alex Hornby
a2247dc41c mononoke: rename MononokeApp to MononokeAppBuilder
Summary:
It has a build() method and later in stack it will build a mononoke
specific type rather than the clap::App

Differential Revision: D25216827

fbshipit-source-id: 24a531856405a702e7fecf54d60be1ea3d2aa6e7
2020-12-01 11:45:00 -08:00
Stanislau Hlebik
561ff43310 mononoke: add --use-hg-server-bookmark-value-if-mismatch option to hg sync job
Summary:
At the moment if we try to sync a bookmark entry but from_cs_id of bookmark
entry doesn't match the value of the bookmark on hg servers then the sync will
fail.
Let's add an option that in the case of this mismatch sets from_cs_id to the
current value on hg servers.

Reviewed By: krallin

Differential Revision: D25242172

fbshipit-source-id: 91180fb86f25d10c9ba2b78d7aa18ed0a52d13a5
2020-12-01 05:58:23 -08:00
Kostia Balytskyi
e4dab84619 scuba: turn ScubaSampleBuilderExt into a wrapper struct
Summary:
This diff prepares the Mononoke codebase for composition-based extendability of
`ScubaSampleBuilder`. Specifically, in the near future I will add:
- new methods for verbose scuba logging
- new data field (`ObservabilityContext`) to check if verbose logging should
  be enabled or disabled

The higher-level goal here is to be able to enable/disable verbose Scuba
logging (either overall or for certain slices of logs, like for a certain
session id) in real time, without restarting Mononoke. To do so, I plan to
expose the aforementioned verbose logging methods, which will run a check
against the stored `ObservabilityContext` and make a decision of whether the
logging is enabled or not. `ObservabilityContext` will of course hide
implementation details from the renamed `ScubaSampleBuilderExt`, and just provide a yes/no
answer based on the current config and sample fields.

At the moment this should be a completely harmless change.

Reviewed By: krallin

Differential Revision: D25211089

fbshipit-source-id: ea03dda82fadb7fc91a2433e12e220582ede5fb8
2020-11-30 21:26:24 -08:00
Stanislau Hlebik
550d331981 mononoke: remove unused code
Reviewed By: mitrandir77

Differential Revision: D25187055

fbshipit-source-id: 8faf2398e0407f56cf133feeb0da2812e27acaad
2020-11-30 07:51:08 -08:00
Stanislau Hlebik
80967e0c6a mononoke: fix clippy in hg sync job
Reviewed By: mitrandir77

Differential Revision: D25186814

fbshipit-source-id: 6258289cbf6ba349f1c1ba542e6bc81e94007fb9
2020-11-30 07:51:08 -08:00
Stanislau Hlebik
59c5f80b75 mononoke: add bundle combining to hg sync job
Summary:
This diff adds bundle combining to hg sync job. See motivation for doing that in D25168877 (cebde43d3f).

Main struct here is BookmarkLogEntryBatch. This struct helds a vector of BookmarkUpdateLogEntry that were combined (they are used mostly for logging) and also it contains parameters necessary for producing the bundle, notably from/to changeset ids and bookmarks. This struct has try_append method that decides whether it's possible to combine bundles or not.

Reviewed By: mitrandir77

Differential Revision: D25186110

fbshipit-source-id: 77ce91915f460db73d8a996efe415954eeea2476
2020-11-30 07:51:08 -08:00
Pavel Aslanov
ac33b17233 convert globalrev related methods to new futures
Summary: convert globalrev related methods to new futures

Reviewed By: ahornby

Differential Revision: D25196171

fbshipit-source-id: 10c31f5869b9dd803955a7755d74b31ba1d8f7c5
2020-11-27 11:11:18 -08:00
Lukas Piatkowski
fa1a195fd0 mononoke/blobstore: pass CoreContext via borrowed instead of owned value
Summary: Follow up after removing 'static from blobstore.

Reviewed By: StanislavGlebik

Differential Revision: D25182106

fbshipit-source-id: e13a7a31d71b4674425123268e655ae66127f1b7
2020-11-27 03:31:07 -08:00
Stanislau Hlebik
cebde43d3f mononoke: refactoring to allow combining bundles in the sync job
Summary:
In the next diff I'd like to allow hg sync job to combine a few bookmark update log entries and send a single bundle for all of them. The goal is to reduce the lag between mononoke and hg servers.

We've already made an attempt to implement bundle combining some time ago, hence why we have things like CombinedBookmarkUpdateLogEntry. However it was never really used in prod - back then the only way to sync a bundle from mononoke to hg servers was to replay a bundle that client has pushed to us, and combining bundles like that was tricky.

Now it's different, because hg sync job has the logic to generates the bundles itself rather than re-use the bundle that client has pushed to us. This makes implementing bundle combinging easier.

This diff doesn't add the actual bundle combining, but it does the refactoring that makes it easier. In particular:
1) Old logic for combining bundles was removed - it was never really used anyway.
1) prepare_bundles() function was added - this function takes a vector of BookmarkUpdateLogEntry and returns a vector of CombinedBookmarkUpdateLogEntry. The idea is to move bundle combining logic from main function to BundlePreparer class, since it has better knowledge of how to do bundle combining (in particular, it knows whether sync job re-uses existing bundle or generates it)
1) prepare_single_bundle() was changed - instead of taking bookmark name, from/to changeset id from BookmarkUpdateLogEntry, it now requires passing them explicitly. This makes adding bundle combining easier in the next diff.

Reviewed By: mitrandir77

Differential Revision: D25168877

fbshipit-source-id: 2935d1795925b4bf0456b9221e2f76ce3987cbd0
2020-11-27 02:21:50 -08:00
Stanislau Hlebik
966d33a84f mononoke: asyncify prepare_single_bundle
Reviewed By: aslpavel

Differential Revision: D25185096

fbshipit-source-id: 4a61420cdf01ceb7e64592c515271459c27114b3
2020-11-27 02:21:50 -08:00
Stanislau Hlebik
d856af393a mononoke: asyncify BundlePreparer constructor
Reviewed By: aslpavel

Differential Revision: D25185048

fbshipit-source-id: 251bca9e6693151e889520e0a40a8051e824d4f7
2020-11-27 02:21:49 -08:00
Stanislau Hlebik
f10d77ce5d mononoke: continue asyncifying main hg sync job loop
Reviewed By: aslpavel

Differential Revision: D25184859

fbshipit-source-id: 7cdc4a2676ee04d8832dc5fd60072cadf5474a18
2020-11-27 02:21:49 -08:00
Stanislau Hlebik
3d03808d05 mononoke: asyncifying loop_over_log_entries
Reviewed By: aslpavel

Differential Revision: D25184814

fbshipit-source-id: 74e702e059856371fc8737bea3e755321ebe07ba
2020-11-26 07:42:49 -08:00
Stanislau Hlebik
3492e5531b mononoke: asyncify build_outcome_handler
Reviewed By: aslpavel

Differential Revision: D25184784

fbshipit-source-id: 66ca7fb874c7172c39ddfafd0ebde36e9c71f350
2020-11-26 07:42:49 -08:00
Stanislau Hlebik
629cfc750d mononoke: asyncify build_reporting_handler
Summary: This diff asyncifies build_reporting_handler, and while there also simplifies this function a bit by ignoring cases where log_entries is empty or not specified

Reviewed By: farnz

Differential Revision: D25184396

fbshipit-source-id: 46b5d2f9fb5571e502bcdf5a0fe964fb62426313
2020-11-26 07:42:49 -08:00
Stanislau Hlebik
c8400473c9 mononoke: asyncify locking/unlocking functions in hg_sync
Reviewed By: aslpavel

Differential Revision: D25184377

fbshipit-source-id: 72457cb669d00c68eee0fb2c19a866458a369bdb
2020-11-26 07:42:49 -08:00
Stanislau Hlebik
9f6fb707d9 mononoke: asyncify combine_entries in hg_sync job
Reviewed By: ahornby

Differential Revision: D25184363

fbshipit-source-id: fcc289e72b99fe524e6f92ab672bbcfba7101e9a
2020-11-26 07:42:49 -08:00
Stanislau Hlebik
196dec1904 mononoke: asyncify sync_single_combined_entry in hg_sync job
Reviewed By: ahornby

Differential Revision: D25184245

fbshipit-source-id: 59985cdc3cadc7ff945db60fabbcd6c241ff3ba1
2020-11-26 07:42:49 -08:00
Stanislau Hlebik
569733215c mononoke: make SYNC_LOOP async
Summary:
This diff asyncifies SYNC_LOOP similar to how SYNC_ONCE was asyncified.
The biggest part of SYNC_LOOP is a stream that starts with loop_over_log_entries. Previously it was a very long chain of combinators. This diff makes this chain ~2 times smaller, but unfortunately it can't make it even smaller  because of the use of "buffered(...)" method.

Reviewed By: ahornby

Differential Revision: D25123487

fbshipit-source-id: e913bbd1369e4375b5b1d0e6ba462e463a5a44fc
2020-11-26 07:42:48 -08:00
Stanislau Hlebik
2ca8bd5900 mononoke: make hg sync job SYNC_ONCE async
Reviewed By: farnz

Differential Revision: D25123103

fbshipit-source-id: 634287909a6be9e1b34160d63e27f14eabcdce95
2020-11-26 04:41:44 -08:00
Stanislau Hlebik
ed51aac36c mononoke: make retry asynchronous
Reviewed By: ikostia

Differential Revision: D25122781

fbshipit-source-id: a7d69c2cdeff0c9c6abd92e486af191e8baed8d5
2020-11-26 04:41:44 -08:00
Stanislau Hlebik
657d226360 mononoke: make try_prepare_single_bundle async
Reviewed By: farnz

Differential Revision: D25121835

fbshipit-source-id: 2564c404a01ad1f1772da4fef47c4a8940f80f0d
2020-11-26 04:41:44 -08:00
Stanislau Hlebik
444289c5d0 mononoke: allow Push bookmark moves in hg sync job
Summary:
Soon we are going to use hg sync job for configerator repos, and they might use
Push bookmark move. Let's allow it in sync job

Reviewed By: ikostia

Differential Revision: D25121176

fbshipit-source-id: f6000617b42be8392730ffc56be1947fbdbfff76
2020-11-20 08:20:38 -08:00
Lukas Piatkowski
0f54cc3d63 mononoke/blobstore: make Blobstore generic over lifetime
Summary: Remove 'static requirement for async methods of Blobstore, propagate this change and fixup low hanging fruits where the code can become 'static free easily.

Reviewed By: ahornby, farnz

Differential Revision: D24839054

fbshipit-source-id: 5d5daa04c23c4c9ae902b669b0a71fe41ee6dee6
2020-11-20 05:51:52 -08:00
Thomas Orozco
26e06ef1a0 mononoke/filestore: update fetch methods to return 0.3 stream
Summary:
This updates the external facing API of the filestore to use 0.3 streams.
Internally, there is still a bit of 0.3 streams, but as of this change, it's
all 0.3 outside.

This required a few changes here and there in places where it was simpler to
just update them to use 0.3 futures instead of `compat()`-ing everything.

Reviewed By: ikostia

Differential Revision: D24731298

fbshipit-source-id: 18a1dc58b27d129970a6aa2d0d23994d5c5de6aa
2020-11-06 07:26:04 -08:00
Thomas Orozco
184310158b mononoke/filestore: update fetch external API to 0.3 futures
Summary:
Like it says in the title. This required quite a lot of changes at callsites,
as you'd expect.

Reviewed By: StanislavGlebik

Differential Revision: D24731299

fbshipit-source-id: e58447e88dcc3ba1ab3c951f87f7042e2b03eb2c
2020-11-06 07:26:03 -08:00
Lukas Piatkowski
3c3de9e954 rust-shed/futures_01_ext: rename futures_ext to futures_01_ext
Summary: As part of the effort to deprecate futures 0.1 in favor of 0.3 I want to create a new futures_ext crate that will contain some of the extensions that are applicable from the futures_01_ext. But first I need to reclame this crate name by renaming the old futures_ext crate. This will also make it easier to track which parts of codebase still use the old futures.

Reviewed By: farnz

Differential Revision: D24725776

fbshipit-source-id: 3574d2a0790f8212f6fad4106655cd41836ff74d
2020-11-05 06:07:16 -08:00
Lukas Piatkowski
2a779e82d8 mononoke/mercurial_bundles: use futures 0.3 in Bundle2Item
Summary: This is a step towards modernizing unbundle crate to use futures 0.3.

Reviewed By: farnz

Differential Revision: D24682963

fbshipit-source-id: 55c17fd699846a24647a23ea1c22888407643dfd
2020-11-03 00:12:21 -08:00
Simon Farnsworth
fb9283c378 Remove old-style futures from cmdlib::args and fix up build failures
Summary: The more we remove, the easier it'll be to remove the last few problem cases.

Reviewed By: StanislavGlebik

Differential Revision: D24592052

fbshipit-source-id: de6371305991d54bf2802fd904850b49aeb11bbd
2020-10-30 11:55:15 -07:00
Stanislau Hlebik
d40f15876d mononoke: upload missing lfs objects
Reviewed By: krallin

Differential Revision: D24595980

fbshipit-source-id: 397930e00a75b0343ed13839783501fe3d535ccd
2020-10-28 14:09:59 -07:00
Simon Farnsworth
7e06175e61 Make config store always explicit
Summary: In D24447404, I provided some utility functions that allowed me to avoid constructing and/or passing around a ConfigStore. Remove those functions and fix up the code to run.

Reviewed By: krallin

Differential Revision: D24502692

fbshipit-source-id: 742dbc54fbcf735895d6829745b9317af14dfa0b
2020-10-24 06:23:49 -07:00
Simon Farnsworth
00871310a7 Ensure we have only one ConfigStore for the application
Summary: It's designed as a singleton store for normal use - rather than have lots of ways to get different config stores, let's use one global store

Reviewed By: krallin

Differential Revision: D24447404

fbshipit-source-id: 6ecc46351b14794471f654cec98527a11a93d3ef
2020-10-24 06:23:49 -07:00
Kostia Balytskyi
2ea25308ab commit_rewriting: use is_empty() where possible
Summary: `clippy` often complains about the use of `.len() != 0`, `.len() > 0` or `.len() == 0`and proposes to use `.is_empty()` instead. This diff does that across Mononoke.

Reviewed By: aslpavel

Differential Revision: D24099427

fbshipit-source-id: 1bba2f958485b7efb3f41bf3eae820879c92b0e5
2020-10-04 10:03:42 -07:00
Aida Getoeva
40b8353d21 mononoke: integrate mysql client
Summary:
This diff introduces Mysql client for Rust to Mononoke as a one more backend in the same row with raw xdb connections and myrouter. So now Mononoke can use new Mysql client connections instead of Myrouter.

To run Mononoke with the new backend, pass `--use-mysql-client` options (conflicts with `--myrouter-port`).

I also added a new target for integration tests, which runs mysql tests using mysql client.
Now to run mysql tests using raw xdb connections, you can use `mononoke/tests/integration:integration-mysql-raw-xdb` and using mysql client `mononoke/tests/integration:integration-mysql`

Reviewed By: ahornby

Differential Revision: D23213228

fbshipit-source-id: c124ccb15747edb17ed94cdad2c6f7703d3bf1a2
2020-09-29 03:09:05 -07:00
Stanislau Hlebik
f2e0da3af5 mononoke: use wait_for_latest_log_id_to_be_synced in x_repo_sync_job
Summary:
Previously we were able to add a backpressure to the x-repo-sync job that waits
until backsync queue gets empty. However it's also useful to wait until hg sync
queue drains for the large repo. This diff makes it possible to do so.

Reviewed By: aslpavel

Differential Revision: D23728201

fbshipit-source-id: 6b198c8d9c35179169a46f2b804f83838edeff1e
2020-09-16 09:17:42 -07:00
Stanislau Hlebik
80e710e70d mononoke: add wait_for_latest_log_id_to_be_synced function to hg sync helper
Summary:
This is the function that was used in repo_import tool to wait until hg sync
has processed all of the entries in the queue. Let's move it to the hg sync
helper lib so that it can be used in other places. E.g. I'd like to use it in
the next diffs in mononoke_x_repo_sync_job.

Reviewed By: krallin

Differential Revision: D23708280

fbshipit-source-id: ea846081d89b55b0d2f5407c971e13869cedfd8b
2020-09-15 17:37:50 -07:00
Stanislau Hlebik
bfc3410fdd mononoke: allow syncing XRepoSync bookmarks
Summary:
Facebook
We need them since we are going to sync ovrsource commits into fbsource

Reviewed By: krallin

Differential Revision: D23701667

fbshipit-source-id: 61db00c7205d5d4047a4040992e7195f769005d3
2020-09-15 02:28:35 -07:00
David Tolnay
0cb8a052f5 Update formatter to rustfmt 2.0
Reviewed By: zertosh

Differential Revision: D23591021

fbshipit-source-id: e664aa2fdd3aaa457796a59080be6b94f604a112
2020-09-09 07:52:33 -07:00
David Tolnay
be0786f14b Prepare for rustfmt 2.0
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like https://github.com/rust-lang/rustfmt/issues/4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: StanislavGlebik

Differential Revision: D23568780

fbshipit-source-id: b4b4a0aa683d236e2fdeb5b96d723ac2d84b9faf
2020-09-08 07:33:16 -07:00