Commit Graph

55 Commits

Author SHA1 Message Date
Kostia Balytskyi
1299164773 resolver.rs: migrate a few leaf functions
Summary:
See D20605813 for the overview of the stack.

This diff migrates a few leaf functions.

Reviewed By: krallin

Differential Revision: D20605811

fbshipit-source-id: 2f5d5e5fba3a00afd61a4eb58c505658ac82943a
2020-03-26 14:38:04 -07:00
Kostia Balytskyi
43c04640c4 resolver.rs: rename futures into old_futures
Summary:
A wider goal of this stack is to migrate `repo_client/unbundle/src/resolver.rs` to async/await and new futures.

The approach is as follows:
- rename old futures upon import into `OldFuture`, `OldBoxFuture`, etc. so that it is easily visible where we use what [this diff]
- implement a bunch of mechanical conversions of continuation-passing-style code to the imperative async/await based code without worrying about clones-vs-references or excessive boxification. Keep individual diffs as small and as mechanical as possible, so that it is easier to review.
- once the `resolve` fn is migrated, introduce `resolve_compat`, which is used from `repo_client/client/src/mod.rs`
- then go through the codebase and see where we can remove clones of resolver/ctx and excessive `boxed()/boxify()` if any are left

Note: `Bundle2` is an `OldStream` and I postpone its migration till the high-level structure of the `resolver.rs` is migrated, since the main value is in allowing imperative-style code in the file

Reviewed By: krallin

Differential Revision: D20605813

fbshipit-source-id: 32255d7b3573f87f74a496e6e40b842e553242a7
2020-03-26 14:38:04 -07:00
Lukas Piatkowski
c3e8dfd31a rust-shed: add hostname crate to the shed
Reviewed By: StanislavGlebik

Differential Revision: D20468997

fbshipit-source-id: 25240c38812f848c9b152e648a491fdfc645ee56
2020-03-20 08:56:12 -07:00
Kostia Balytskyi
21f70ac6d1 mononoke: do not log JSON field extra_contents to scuba, log columns instead
Reviewed By: farnz

Differential Revision: D20500084

fbshipit-source-id: 296747780298fe81e4cca4cdb8af05548ba80169
2020-03-20 02:48:03 -07:00
Stanislau Hlebik
107d049cf9 mononoke: fix some of the suggestions from clippy
Summary:
Run buck build -c rust.clippy=true eden/mononoke/:mononoke#check and fix some
of them manually. I wasn't able to make rustfix to work - will try to see
what's wrong and run it.

The suggestions looks non-controversial

Reviewed By: krallin

Differential Revision: D20520123

fbshipit-source-id: 25d4eb493f2363c5aa77bdb3876da4378483f6cb
2020-03-19 06:06:10 -07:00
Johann Steinbrecher
a2530a1bcb Deprecate rust-crypto in eden/mononoke/repo_client
Reviewed By: jsgf

Differential Revision: D20428696

fbshipit-source-id: 1d38512d1988ecb66a2b46f967737d8df3b6aabb
2020-03-18 19:34:38 -07:00
Dan Forest
59c4761872 clean API naming + make fbwhoami refreshable
Summary: 'new' is not very explicit with the fact that things are not refreshed.

Reviewed By: dtolnay

Differential Revision: D20356129

fbshipit-source-id: ff4a8c6fe4c34e93729c902e4b41afbe3c9deca1
2020-03-18 15:52:18 -07:00
Thomas Orozco
956c768095 mononoke/repo_client: add telemetry for designated nodes
Summary:
Now that Arun is about to roll this out to the team, we should get some more
logging in place server side. This updates the designated nodes handling code
to report whether it was enabled (and log prior to the request as well).

Reviewed By: HarveyHunt

Differential Revision: D20514429

fbshipit-source-id: 76ce62a296fe27310af75c884a3efebc5f210a8a
2020-03-18 12:57:34 -07:00
Simon Farnsworth
d2cba5a169 Centralise hook running in the HookManager
Summary: We had hooks logic scattered around the place - move it all into the hooks crate, so that it's easier to refactor to use Bonsai changesets instead of hg.

Reviewed By: StanislavGlebik

Differential Revision: D20198725

fbshipit-source-id: fb8bdc2cdbd1714c7181a5a0562c1dacce9fcc7d
2020-03-18 09:17:17 -07:00
Simon Farnsworth
a908be34b3 Modernise hooks support
Summary: Migrate hooks to new futures and thus modern tokio. In the process, replace Lua hooks with Rust hooks, and add fixes for the few cases where Lua was too restrictive about what could be done.

Reviewed By: StanislavGlebik

Differential Revision: D20165425

fbshipit-source-id: 7bdc6820144f2fdaed653a34ff7c998913007ca2
2020-03-18 09:17:17 -07:00
Arun Kulshreshtha
bc5b530959 hgproto: use Option<MPath> instead of Bytes for path in GettreepackArgs
Summary: title

Reviewed By: StanislavGlebik

Differential Revision: D20459401

fbshipit-source-id: 3473c2eef39b0d51e6133a5f575d2fd7bef3bd97
2020-03-17 15:07:54 -07:00
Adam Simpkins
b01b2783ad unbreak the build of eden/mononoke/repo_client
Summary:
D20444137 added a new use of `lfs_threshold`, and D20441264 removed this
variable.  These two diffs landed close to the same time without ever being
tested with both diffs together.

Reviewed By: StanislavGlebik

Differential Revision: D20484843

fbshipit-source-id: fd0f0837142cdb641892005a64fd14272da7d2b7
2020-03-17 00:09:35 -07:00
Harvey Hunt
d1b4f83bf5 mononoke: Log number of possible LFS fetches for a getpack request.
Summary:
Update the `getpack` code to calculate how many files (and their total
size) would be served over LFS.

NOTE: The columns have `Possible` in their names as we might not have LFS
enabled, in which case we aren't actually fetching this many blobs from an LFS
server.

Reviewed By: farnz

Differential Revision: D20444137

fbshipit-source-id: 85506d8c468cfdc470684dd216567f1848c43d08
2020-03-16 14:11:49 -07:00
Stanislau Hlebik
5790f7e176 mononoke: add lfs rollout percentage
Summary:
Allow to gradually rollout lfs. A lot of the details are covered in D20441254
I won't repeat them here. I'd only mention that in order for fastreplay to
correctly calculate percentages this diff starts to log client_hostname for
fastreplay.

Reviewed By: ikostia

Differential Revision: D20441264

fbshipit-source-id: e272176f68879f6c545784609799d21daedec5eb
2020-03-16 08:18:41 -07:00
Stanislau Hlebik
20b8b76b87 mononoke: introduce SessionLfsParams
Summary: For now it's identical to LfsParams - it will change in the next diff

Reviewed By: krallin

Differential Revision: D20442530

fbshipit-source-id: 8434610373bb9aefe16702207448283b34676ca2
2020-03-16 03:52:20 -07:00
Dan Forest
1e02b6ff6f replace hashmap with structured data
Summary: Since they are static and immutable, fbwhoami/fbwhatami could be simple structs with public fields.

Reviewed By: eugeneoden

Differential Revision: D20299423

fbshipit-source-id: 492f49c2b3003760517bfc5be06ace07fabbc6b9
2020-03-13 14:52:55 -07:00
Mateusz Kwapich
e70e7a9017 rename get_generation_number_by_bonsai to get_generation_number
Summary: I'm about to introduce one more usecase of it so let's rename it first.

Reviewed By: farnz

Differential Revision: D20393776

fbshipit-source-id: d74146fa212cdc4989a18c2cbd28307f58994759
2020-03-13 08:31:07 -07:00
Stefan Filip
78deb9142b mononoke: add stats collection for getcommitdata
Summary: Stats. Cargo culted from `gettreepack`.

Reviewed By: StanislavGlebik

Differential Revision: D20377955

fbshipit-source-id: f64b702d3f9f3c76915db5b397dfaac77a848fa2
2020-03-12 14:36:13 -07:00
Stefan Filip
974ccafbb0 mononoke: initial implementation for getcommitdata
Summary:
The input for getcommitdata is a list of HgChangesetIds. For every entry, the
endpoint retrieves the commit, formats it like the revlog then returns it back
to the client.
The format for the returned entries is:
```
Hash " " Length LF
RevlogContent LF
```
Looking for recommendations for how to structure the code better.
Looking for recommendations on implementation requirements:
metrics, throttling, veriftying hash for returned bytes.

Reviewed By: krallin

Differential Revision: D20376665

fbshipit-source-id: 5d9eb0d581fd2b352cf3ce44f4777ad45076c8f4
2020-03-12 14:36:13 -07:00
Thomas Orozco
87491d14a7 mononoke/repo_client: add designated manifest fetching in gettreepack
Summary:
This will allow the hg client to do tree fetching like we do in the API Server,
but through the SSH protocol — i.e. by passing a series a manifest ids and
their paths, without recursion on the server side through gettreepack.

Reviewed By: StanislavGlebik

Differential Revision: D20307442

fbshipit-source-id: a6dca03622becdebf41b264381fdd5837a7d4292
2020-03-12 06:35:34 -07:00
Stanislau Hlebik
4241ca0272 mononoke: add repo name in BlobRepo
Summary:
A lot of callsites want to know repo name. Currently they need to pass it from
the place where repo was initialized, and that's quite awkward, and in some
places even impossible (i.e. in derived data, where I want to log reponame).

This diff adds reponame in BlobRepo

Reviewed By: krallin

Differential Revision: D20363065

fbshipit-source-id: 5e2eb611fb9d58f8f78638574fdcb32234e5ca0d
2020-03-10 08:32:33 -07:00
Stanislau Hlebik
b0cb300af8 mononoke: introduce BlobrepoBuilder
Summary:
The goal of the whole stack is quite simple (add reponame field to BlobRepo), but
this stack also tries to make it easier to initialize BlobRepo.

To do that BlobrepoBuilder was added. It now accepts RepoConfig instead of 6
different fields from RepoConfig - that makes it easier to pass a field from
config into BlobRepo. It also allows to customize BlobRepo. Currently it's used
just to add redaction override, but later we can extend it for other use cases
as well, with the hope that we'll be able to remove a bunch of repo-creation
functions from cmdlib.

Because of BlobrepoBuilder we no longer need open_blobrepo function. Later we
might consider removing open_blobrepo_given_datasources as well.

Note that this diff *adds* a few new clones. I don't consider it being a big
problem, though I'm curious to hear your thoughts folks.

Note that another option for the implementation would be to take a reference to objects
instead of taking them by value. I briefly looked into how they used, and lot of them are passed to the
objects that actually take ownership of what's inside these config fields. I.e. Blobstore essentially takes ownership
of BlobstoreOptions, because it needs to store manifold bucket name.
Same for scuba_censored_table, filestore_params, bookmarks_cache_ttl etc. So unless I'm missing anything, we can
either pass them as reference and then we'll have to copy them, or we can
just pass a value from BlobrepoBuilder directly.

Reviewed By: krallin

Differential Revision: D20312567

fbshipit-source-id: 14634f5e14f103b110482557254f084da1c725e1
2020-03-09 12:05:57 -07:00
Stanislau Hlebik
c1ea56c17c mononoke: asyncify blobrepo_factory
Summary:
Note that comparing to many other asyncifying efforts, this one actually adds
one more clone instead of removing them. This is the clone of a logger field.
That shouldn't matter much because it can be cleaned up later and because this
function will be called once per repo.

Reviewed By: krallin

Differential Revision: D20311122

fbshipit-source-id: ace2a108790b1423f8525d08bdea9dc3a2e3c37c
2020-03-09 05:02:05 -07:00
Thomas Orozco
9493a05e7b mononoke/filestore: update store_bytes to chunk content
Summary:
This updates the store_bytes method to chunk incoming data instead of uploading
it as-is. This is unfortunately a bit hacky (but so was the previous
implementation), since it means we have to hash the data before it has gone
through the Filestore's preparation.

That said, one of the invariants of the filestore is that chunk size shouldn't
affect the Content ID (and there is fairly extensive test coverage for this),
so, notionally, this does work.

Performance-wise, it does mean we are hashing the object twice. That actually
was the case before as well anyway (since obtain the ContentId for FileContents
would clone them then hash them).

The upshot of this change is that large files uploaded through unbundle will
actually be chunked (whereas before, they wouldn't be).

Long-term, we should try and delete this method, as it is quite unsavory to
begin with. But, for now, we don't really have a choice since our content
upload path does rely on its existence.

Reviewed By: StanislavGlebik

Differential Revision: D20281937

fbshipit-source-id: 78d584b2f9eea6996dd1d4acbbadc10c9049a408
2020-03-06 07:43:07 -08:00
Lukas Piatkowski
7ddcdd818c mononoke: make sql_ext OSS buildable
Summary: separate out the Facebook-specific pieces of the sql_ext crate

Reviewed By: ahornby

Differential Revision: D20218219

fbshipit-source-id: e933c7402b31fcd5c4af78d5e70adafd67e91ecd
2020-03-06 01:33:38 -08:00
Pavel Aslanov
95bf3a32a4 Report bytes sent via perf counters for stream_out_shallow command
Summary: Report bytes sent via perf counters for `stream_out_shallow` command

Reviewed By: krallin

Differential Revision: D20283114

fbshipit-source-id: 1f354904c68322b941ff0c035bb0b811e41e74a1
2020-03-05 08:58:21 -08:00
David Tolnay
c008ba8513 rust: Move tokio-old rdeps to renamed tokio-old
Summary:
Context: https://fb.workplace.com/groups/rust.language/permalink/3338940432821215/

In targets that depend on both 0.1 and 0.2 tokio, this codemod renames the 0.1 dependency to be exposed as tokio_old::. This is in preparation for flipping the 0.2 dependencies from tokio_preview:: to plain tokio::.

This is the tokio version of what D20168958 did for futures.

Codemod performed by:

```
rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| sed 's,TARGETS$,:,' \
| xargs \
    -x \
    buck query "labels(srcs,
        rdeps(%Ss, fbsource//third-party/rust:tokio-old, 1)
        intersect
        rdeps(%Ss, //common/rust/renamed:tokio-preview, 1)
    )" \
| xargs sed -i 's,\btokio::,tokio_old::,'
```

Reviewed By: k21

Differential Revision: D20235404

fbshipit-source-id: cfb2689a584ad0d73f16d98d8587fb9c44661465
2020-03-04 11:09:30 -08:00
Thomas Orozco
275e4eff76 mononoke/mercurial: remove incorrect FileBytes Extend implementation
Summary:
This removes the Extend implementation for FileBytes, which was incorrect (it
discarded existing data!). I had introduced this as a backwards compatibility
shim when doing the Bytes 0.4 to Bytes 0.5 migration :/

We don't really need this shim, considering:

- The only place that really matters that uses this is the remotefilelog crate,
  where we have a content id, and where we should use `filestore::fetch_concat`
  instead.
- The other places are tests (or close to abandonware...), which can do their
  own folding.

Longer term, I'd like to remove the whole `Content` stream in hg entries, so
those callsites can use the filestore methods, which a) have test coverage
(unlike ad-hoc folds, which don't always do), and b) are more efficient since
they know how large the destination buffer needs to be ahead of time, and don't
need to re-allocate.

To make sure this fixes the bug, I also introduced tests for the remotefilelog
crate. As expected, the chunked variant fails without this fix.

Reviewed By: mitrandir77

Differential Revision: D20248978

fbshipit-source-id: 1b554d3e595eb867b6b6cf4204d31f27dd90a111
2020-03-04 08:51:42 -08:00
David Tolnay
e988a88be9 rust: Rename futures_preview:: to futures::
Summary:
Context: https://fb.workplace.com/groups/rust.language/permalink/3338940432821215/

This codemod replaces *all* dependencies on `//common/rust/renamed:futures-preview` with `fbsource//third-party/rust:futures-preview` and their uses in Rust code from `futures_preview::` to `futures::`.

This does not introduce any collisions with `futures::` meaning 0.1 futures because D20168958 previously renamed all of those to `futures_old::` in crates that depend on *both* 0.1 and 0.3 futures.

Codemod performed by:

```
rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| sed 's,TARGETS$,:,' \
| xargs \
    -x \
    buck query "labels(srcs, rdeps(%Ss, //common/rust/renamed:futures-preview, 1))" \
| xargs sed -i 's,\bfutures_preview::,futures::,'

rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| xargs sed -i 's,//common/rust/renamed:futures-preview,fbsource//third-party/rust:futures-preview,'
```

Reviewed By: k21

Differential Revision: D20213432

fbshipit-source-id: 07ee643d350c5817cda1f43684d55084f8ac68a6
2020-03-03 11:01:20 -08:00
Alex Hornby
464ffc40eb mononoke: pushrebase: fix casefolding_check usage during changeset creation
Summary: Honor the repo casefolding_check setting as tested by test-pushrebase-allow-casefolding.t

Reviewed By: StanislavGlebik

Differential Revision: D20192411

fbshipit-source-id: 8da72049417015b1f284c115a53b13c26ce3c3f6
2020-03-03 03:57:32 -08:00
David Tolnay
fe65402e46 rust: Move futures-old rdeps to renamed futures-old
Summary:
In targets that depend on *both* 0.1 and 0.3 futures, this codemod renames the 0.1 dependency to be exposed as futures_old::. This is in preparation for flipping the 0.3 dependencies from futures_preview:: to plain futures::.

rs changes performed by:

```
rg \
    --files-with-matches \
    --type-add buck:TARGETS \
    --type buck \
    --glob '!/experimental' \
    --regexp '(_|\b)rust(_|\b)' \
| sed 's,TARGETS$,:,' \
| xargs \
    -x \
    buck query "labels(srcs,
        rdeps(%Ss, fbsource//third-party/rust:futures-old, 1)
        intersect
        rdeps(%Ss, //common/rust/renamed:futures-preview, 1)
    )" \
| xargs sed -i 's/\bfutures::/futures_old::/'
```

Reviewed By: jsgf

Differential Revision: D20168958

fbshipit-source-id: d2c099f9170c427e542975bc22fd96138a7725b0
2020-03-02 21:02:50 -08:00
Kostia Balytskyi
cec057adc5 mononoke: add some perf counters for hydrated getbundle responses
Summary:
In case this starts to cause problems, let's have a way to correlate those
problems with some exported metrics.

Reviewed By: StanislavGlebik

Differential Revision: D20158822

fbshipit-source-id: 6ac9e25861dbedaecdf04fd92bda835ae66535eb
2020-02-28 08:30:43 -08:00
Kostia Balytskyi
7ed52ee31b mononoke: return hydrated bundles for infinitepush, if config says so
Summary:
## Wider goal
See D20068839

## This diff
This diff actually implements the conditional hydration of `getbundle`
responses, as described in the D20068839.

Note that as well as implementing support for hydrated `getbyndle` responses, this diff also implements support for changegroup v3 and lfs in such responses, which is needed if we are to do this kind of stuff in LFS-enabled repository.

Reviewed By: StanislavGlebik

Differential Revision: D20068838

fbshipit-source-id: fbdd3f8f5fb7cd2cb60473a94094553a1d4b4d2f
2020-02-28 08:30:43 -08:00
Kostia Balytskyi
d5080d20ce mononoke: asyncify get_manifest_and_filenodes in getbundle_response
Summary:
## Wider goal
See D20068839

## This diff
Modernize this particular function

Reviewed By: StanislavGlebik

Differential Revision: D20097802

fbshipit-source-id: fe76aaf2c0b65cf9b47a1dedc66d417d22cad255
2020-02-28 04:36:38 -08:00
Kostia Balytskyi
7755c4c4e6 mononoke: asyncify prepare_filenode_entries_stream in getbundle_response
Summary:
## Wider goal
See D20068839

## This diff
Modernize this particular function.

Reviewed By: krallin

Differential Revision: D20097805

fbshipit-source-id: bbcf371921d3a709cc7178ec50b7729bddf1f630
2020-02-28 02:49:57 -08:00
Thomas Orozco
149e15f2ad mononoke: use spawn_future in getpack to fetch history
Summary:
The former implementation would eagerly query Memcache when fetching history
(due to how old futures work) for files in getpack, but the new one does not.
This means the new one loses out on a lot of buffering, which the old one used
to do.

This diff emulates the old behavior by eagerly querying filenodes in getpack,
which improves performance on a very big getpack (32K files) by about 3x, and
makes it 30% faster than the old code, instead of > 2x slower.

Note that I'm not certain we really want to do this kind of aggressive
buffering in getpack long term, but for now, I'd like to keep this unchanged.

Reviewed By: StanislavGlebik

Differential Revision: D19905398

fbshipit-source-id: 49f9a2cd505a98123fd1dabb835e8e378d45c930
2020-02-27 12:34:21 -08:00
Thomas Orozco
26ae726af5 mononoke: update internals to Bytes 0.5
Summary:
The Bytes 0.5 update left us in a somewhat undesirable position where every
access to our blobstore incurs an extra copy whenever we fetch data out of our
cache (by turning it from Bytes 0.5 into Bytes 0.4) — we also have quite a few
place where we convert in one direction then immediately into the other.

Internally, we can start using Bytes 0.5 now. For example, this is useful when
pulling data out of our blobstore and deserializing as Thrift (or conversely,
when serializing and putting it into our blobstore).

However, when we interface with Tokio (i.e. decoders & encoders), we still have
to use Bytes 0.4.  So, when needed, we convert our Bytes 0.5 to 0.4 there.

The tradeoff idea is that we deal with more bytes internally than we end up
sending to clients, so doing the Bytes conversion closer to the point of
sending data to clients means less copies.

We can also start removing those once we migrate to Tokio 0.2 (and newer
versions of Hyper for HTTP services).

Changes that were required:

- You can't extend new bytes (because that implicitly copies). You need to use
  BytesMut instead, which I did where that was necessary (I also added calls in
  the Filestore to do that efficiently).
- You can't create bytes from a `&'a [u8]`, unless `'a` is  `'static`. You need
  to use `copy_from_slice` instead.
- `slice_to` and `slice_from` have been replaced by a `slice()` function that
  takes ranges.

Reviewed By: StanislavGlebik

Differential Revision: D20121350

fbshipit-source-id: eb31af2051fd8c9d31c69b502e2f6f1ce2190cb1
2020-02-27 08:08:28 -08:00
Kostia Balytskyi
7ee657f124 mononoke: asyncify signatures of two fns in getbundle_response
Summary:
## Wider goal
See D20068839

## This diff
Asyncifying only singatures allows us to independently work on function bodies, without touching the callsites later in the diff.

Reviewed By: StanislavGlebik

Differential Revision: D20097804

fbshipit-source-id: f1391a055947c7802f719bc99b9eae71a4ac39cd
2020-02-27 05:01:52 -08:00
Kostia Balytskyi
bd90a843a7 mononoke: asyncify diff_with_parents in getbundle_response
Summary:
## Wider goal
See D20068839

## This diff
Let's modernize this particular fucntion

Reviewed By: StanislavGlebik

Differential Revision: D20097800

fbshipit-source-id: a919b5ad1b544a7b784668ca265e24c375100fa3
2020-02-27 05:01:51 -08:00
Kostia Balytskyi
90b03f5a0d mononoke: call old-style Future OldFuture in getbundle_response
Summary:
## Wider goal
See D20068839

## This diff
This file contains a mix of old and new-style futures. It even has futures,
which have items composed of futures. To be able to convert on one of the
levels and not the other, we need to deal with the confusion.

Let's have old things have `Old` in the name.

Reviewed By: StanislavGlebik

Differential Revision: D20097803

fbshipit-source-id: fedb3669ef34a8328ec389a30ff2c512ab363818
2020-02-27 05:01:51 -08:00
Kostia Balytskyi
4f2993c765 mononoke: move bundle generation bits from hg_sync_job into getbundle_response
Summary:
## Wider goal
We want the flexibility to return hydrated responses for `getbundle` wireproto
requests for draft commits. This means that the responses will contain not
only the commit data (as they do now), but also trees and files.
For context, when an "unhydrated" response is returned for the `getbundle`
request for a draft commit, we expect one of two things to happen later
in the e2e scenario:
- either `hg` client would immediately make another wireproto request
  (`gettreepack`, `getpackv1`) within the same client `hg` command execution
- or a subsequent `hg update` call will cause another wireproto request

In any case, another request is needed before the pulled commit can be used.
This request can hit a different server, sometimes it can even be Mercurial
instead of Mononoke. Specifically, it can Mercurial instead of Mononoke if the
`fallback` path markers are configured incorrectly. In that case we have a
problem, as Mercurial is incapable of serving `gettreepack` or `getpackv1` for
infinitepush commits.

One way to deal with this is to always have correct path markers, which is
prone to human mistakes. Another way is to guarantee that Mononoke returns
everything in the original `getbundle` request. We don't want to do this for
public commits, as `pull`s of public commits typically fetch thousands of those
commits and never care about tree or file data for all but one of them. Draft
commits are different however, as they are usually exactly what the client
intends to use, so hydrating those is fine. Still, we want this behavior to
be gated behind a config flag.

## This diff
A lot of the needed code is already implemented in the hg-sync job, bundle
generating variant. So prior to implementing the actual behavior described
above, let's move the relevant bits to `getbundle_response`. Later we can comb
them up a bit (asyncify) and use to implement the needed behavior.

Reviewed By: StanislavGlebik

Differential Revision: D20068839

fbshipit-source-id: 0ab63d57b2d167401b7ee8864fe7760f5f65f8ec
2020-02-27 05:01:51 -08:00
Stanislau Hlebik
19e1e94984 mononoke: add lease renewing to derived data
Summary:
During S196197 lease expired and we were rederiving the same derived data over and over again for a big commit.
this diff adds lease renewal that should help with this problem.

Reviewed By: HarveyHunt

Differential Revision: D20093323

fbshipit-source-id: d139abf6659722f47ea40d9b2f279daa03623ff4
2020-02-25 09:22:46 -08:00
Mateusz Kwapich
6111067524 add git mapping pushrebase hook
Summary:
Let's populate the bonsai<->git mapping on pushrebase of the commits that are
coming from git. By this being a pushrebase hook we can have the accuare mappings
being available as soon as the bonsai commit is available.

Corresponding configerator change: D19951607

Reviewed By: krallin

Differential Revision: D19949472

fbshipit-source-id: b957cbcdd0f14450ceb090539814952db9872576
2020-02-21 05:41:45 -08:00
Thomas Orozco
58126d90d6 mononoke: log input size
Summary:
This adds some basic logging for input size for Gettreepack and Getpack. This
might make it easier to understand "poison pill" requests that take out the
host before it has a chance to finish the request.

Reviewed By: StanislavGlebik

Differential Revision: D19974661

fbshipit-source-id: deae13428ae2d1857872185de2b6c0a8bcaf3334
2020-02-20 02:24:10 -08:00
Mark Thomas
a8f06f75c0 derived_data: add DeriveError for when derivation is disabled
Summary:
Currently if derivation of a particular derived data type is disabled, but a
client makes a request that requires that derived data type, we will fail with
an internal error.

This is not ideal, as internal errors should indicate something is wrong, but
in this case Mononoke is behaving correctly as configured.

Convert these errors to a new `DeriveError` type, and plumb this back up to
the SCS server.  The SCS server converts these to a new `RequestError`
variant: `NOT_AVAILABLE`.

Reviewed By: krallin

Differential Revision: D19943548

fbshipit-source-id: 964ad0aec3ab294e4bce789e6f38de224bed54fa
2020-02-19 09:28:09 -08:00
Thomas Orozco
16384599a8 mononoke (+ rust/shed/async_unit): update async_unit to expect async fn's
Summary:
This allows code that is being exercised under async_unit to call into code
that expects a Tokio 0.2 environment (e.g. 0.2 timers).

Unfortunately, this requires turning off LSAN for the async_unit tests, since
it looks like LSAN and Tokio 0.2 don't work very well together, resulting in
LSAN reporting leaked memory for some TLS structures that were initialized by
tokio-preview (regardless of whether the Runtime is being dropped):
https://fb.workplace.com/groups/rust.language/permalink/3249964938385432/

Considering async_unit is effectively only used in Mononoke, and Mononoke
already turns off LSAN in tests for precisely this reason ... it's probably
reasonable to do the same here.

The main body of changes here is also about updating the majority of our
changes to stop calling wait(), and use this new async unit everywhere. This is
effectively a pretty big batch conversion of all of our tests to use async fns
instead of the former approaches. I've also updated a substantial number of
utility functions to be async fns.

A few notable changes here:

- Some pushrebase tests were pretty flaky — the race they look for isn't
  deterministic. I added some actual waiting (using pushrebase hooks) to make
  it more deterministic.  This is kinda copy pasted from the globalrev hook
  (where I had introduced this first), but this will do for now.
- The multiplexblob tests don't work at all with new futures, because they call
  `poll()` all over the place. I've updated them to new futures, which required
  a bit of reworking.
- I took out a couple tests in async unit that were broken anyway.

Reviewed By: StanislavGlebik

Differential Revision: D19902539

fbshipit-source-id: 352b4a531ef5fa855114c1dd8bb4d70ed967dd55
2020-02-18 01:55:00 -08:00
Lukas Piatkowski
186573f329 mononoke: cover server/context with OSS build
Summary: The load_limiter was extracted from server/context into its own crate and the server/context itself was refactored into multiple modules, one of which contains facebook-specific code.

Reviewed By: StanislavGlebik

Differential Revision: D19902972

fbshipit-source-id: d577492b4fe01ccfe11b3e092e0521b190516268
2020-02-14 04:51:49 -08:00
Pavel Aslanov
c902acbc3f remove the need to pass mapping to ::derive method
Summary: remove the need to pass mapping to `::derive` method

Reviewed By: StanislavGlebik

Differential Revision: D19856560

fbshipit-source-id: 219af827ea7e077a4c3e678a85c51dc0e3822d79
2020-02-12 10:22:39 -08:00
Kostia Balytskyi
edc40cb269 mononoke: add a perf counter for draft commits, returned by getbundle
Summary:
This will allow us to distinguish `getbundle` for a normal `pull` from the one
for infinitepush pull.

Reviewed By: StanislavGlebik

Differential Revision: D19833206

fbshipit-source-id: 86534320fbb4d60bac04d458a0953701201cba87
2020-02-11 19:26:49 -08:00
Lukasz Piatkowski
542d1f93d3 Manual synchronization of fbcode/eden and facebookexperimental/eden
Summary:
This commit manually synchronizes the internal move of
fbcode/scm/mononoke under fbcode/eden/mononoke which couldn't be
performed by ShipIt automatically.

Reviewed By: StanislavGlebik

Differential Revision: D19722832

fbshipit-source-id: 52fbc8bc42a8940b39872dfb8b00ce9c0f6b0800
2020-02-11 11:42:43 +01:00