Commit Graph

135 Commits

Author SHA1 Message Date
Jan Mazur
083a9ad35c Vendor curl-sys crate with patched curl
Summary:
Vendoring this patch: https://github.com/curl/curl/pull/7737 to curl-sys rust crate. On windows the hg client is using curl that's bundled with sys-curl. I need this patch to have unix domain sockets working in hg client on windows.

I had to manually vendor https://raw.githubusercontent.com/mzr/curl/57e7ec4dbe4dd2831de51f2644879387d2ea7b44/docs/INSTALL because reindeer didn't do it. IDK why.

oss-eden-{darwin,linux,windows}-getdeps fail with:
```
FAILED: eden/scm/lib/backingstore/CMakeFiles/rust_backingstore.cargo eden/scm/lib/backingstore/debug/libbackingstore.a eden/scm/lib/backingstore/release/libbackingstore.a
cd /data/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/scm/lib/backingstore && /data/sandcastle/temp/fbcode_builder_getdeps/installed/cmake-hQhVzQT-WzFKTeqXjLxo5lLi8IG4_MjX2-YRqptCUVs/bin/cmake -E remove -f /data/sandcastle/temp/fbcode_builder_getdeps/shipit/eden/eden/scm/lib/backingstore/Cargo.lock && /data/sandcastle/temp/fbcode_builder_getdeps/installed/cmake-hQhVzQT-WzFKTeqXjLxo5lLi8IG4_MjX2-YRqptCUVs/bin/cmake -E env CARGO_TARGET_DIR=/data/sandcastle/temp/fbcode_builder_getdeps/build/eden/eden/scm/lib/backingstore CARGO_HOME=/data/sandcastle/temp/fbcode_builder_getdeps/build/eden/_cargo_home cargo build --release -p backingstore --features fb
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
error: failed to calculate checksum of: /data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust/vendor/curl-sys-0.4.45+curl-7.78.0/curl/docs/INSTALL
Caused by:
  failed to open file `/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/third-party/rust/vendor/curl-sys-0.4.45+curl-7.78.0/curl/docs/INSTALL`
Caused by:
  No such file or directory (os error 2)
```

Not idea how to fix this. Seems related to the fact that reindeer didn't vendor docs/INSTALL.

# EDIT:
# It might been caused by some bug in hg. now it's fine
# The failure in oss-eden-linux-getdeps looks unrelated (something with rocksdb)

Reviewed By: krallin

Differential Revision: D31370778

fbshipit-source-id: a1245f8cb6b58f5765e34c95dfd78325a8e6e457
2021-10-04 03:13:50 -07:00
Yan Soares Couto
1a78607026 Add snapshots for wire types and simplify tests
Summary:
This diff adds snapshot tests for most eden api wire types, while at the same time making the testing code much smaller, including tests for "wire" and "serialize" roundtrips.

## Context:
The previous diff had added an easy way to add snapshot tests. This stack aims to simplify the wire protocol code needed to create/modify an endpoint. A good thing to do before that is to add snapshot tests to all wire types, so that if we change them in a refactor, we're confident they still work exactly the same. This will also be useful when a type is changed in the future.

## How this makes tests easier
- In order to create snapshot tests, we need example objects to test with. Luckily we already use a framework for generating example objects (quickcheck::Arbitrary), so the idea here is to use that to make snapshot tests as automatic as possible.
- At the same time, the "wire" and "serialize" roundtrip tests (which also used Arbitrary), can also be made more automatic.

Now, using a simple helper, `auto_wire_tests!(WireObjectName)`, it is possible to derive all three types of tests automatically. This makes the current code smaller, and safer as we now have the additional safety provided by snapshot tests.

## Observations
- Not all wire types had tests implemented for them (I assume because it was too much work doing so, and might have done that myself in the past), I only moved the ones that already had. I'll do another pass and add remaining objects on a following diff.
- There are a couple actual non-refactor changes. I'll add comments explaining those.
- quickcheck crate is using quite an old version. I tried updating but it snowballed into something much more complicated, so I kept using the old version. We'll need to get to it at some point, though.

Reviewed By: markbt

Differential Revision: D31019233

fbshipit-source-id: 30c4a90848d0a5dcaffb89b9a0cd1cebfe4ace55
2021-10-01 14:43:32 -07:00
Yan Soares Couto
1d9afdf9fb Use short gotham request id to save storage space
Summary:
This is used to uniquely identify requests in gotham. It's logged to output, on errors, and on Scuba.

Problem: On scuba, this packs very badly, as it is a large string (36 chars), unique for all requests.

Solution: Let's get a prefix of it, it should reduce size used on scuba. Got a prefix of size 5.

This affects both LFS and EdenApi.

Pros:
- Reduces size
- Very easy fix

Cons:
- More chance of conflict. The space of this id is 16^5 = 10^6. There will surely be conflicts, but maybe that's not a huge deal?

Alternative: Using 8 digits, that's about 4bi ids, which will reduce conflicts significantly in exchange for more space.

Why not use an int id (example: u64), or using other characters in id (not only hex): This would reduce the size of data significantly, but has drawbacks:
- For int, would require a big refactoring, as everything assumes the id to be string. Specially since this goes through client-server, might be complicated.
- Not just getting a prefix means more processing on each request, and means we need to recalculate it everytime.
- Size reduction might not be that big, as scuba already packs stuff pretty well.

Reviewed By: krallin

Differential Revision: D31305547

fbshipit-source-id: 23f6b6cb7de5b7a090864db414d4d71cd68c4946
2021-10-01 03:37:51 -07:00
Digant Kasundra
ffd233228b Add syslog and slog-syslog crates
Summary: ACE will have to run in situations where Chef has not run, but we'll need to be able to reliably write to the auth logs so Blackbird can properly build detections.  So we need these crates so we can build the somewhat foolproof solution to ensure ACE logs all executions.

Reviewed By: farnz

Differential Revision: D31066559

fbshipit-source-id: 9fa3b5778cd2602bdeaac90a9daa758b117babfe
2021-09-21 07:22:38 -07:00
Zeyi (Rice) Fan
18dbf379df ring: backport kSecRandomDefault is NULL to fix macOS build
Summary:
Backport: https://github.com/briansmith/ring/pull/1334

This will allow us to unpin Rust compiler to 1.53.0 and update to 1.55.0.

Reviewed By: xavierd

Differential Revision: D31039024

fbshipit-source-id: f6a9c918e836d93d03c34c77c12bbe63cf7cbe09
2021-09-20 11:22:49 -07:00
Gus Wynn
c797db63a1 vendor tokio-console and console-subscriber
Summary:
this relies on local changes to make it so cargo metadata ACTUALLY finds this
binary: https://github.com/tokio-rs/console/pull/146 is where I try to upstream
it

Reviewed By: jsgf

Differential Revision: D30944630

fbshipit-source-id: 5d34a32a042f83eff7e7ae7445e23badf10fffe3
2021-09-17 16:23:43 -07:00
David Tolnay
7f0c6953b8 third-party/rust: Update pin-project 0.4.24 to 0.4.28
Summary:
0.4.24 is incompatible with crates that use `deny(warnings)` on a compiler 1.55.0 or newer.

Example error:

```
error: unused borrow that must be used
  --> common/rust/shed/futures_ext/src/stream/return_remainder.rs:22:1
   |
22 | #[pin_project]
   | ^^^^^^^^^^^^^^
   |
   = note: this error originates in the derive macro `::pin_project::__private::__PinProjectInternalDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
```

The release notes for 0.4.28 call out this issue. https://github.com/taiki-e/pin-project/releases/tag/v0.4.28

Reviewed By: krallin

Differential Revision: D30858380

fbshipit-source-id: 98e98bcb5a6b795b93ed1efd706a1711f15c57db
2021-09-15 23:01:30 -07:00
Jeremy Fitzhardinge
113060beb1 third-party/rust: bump all the tracing packages
Summary:
This includes recent changes:
- `skip_all` in #[instrument] https://github.com/tokio-rs/tracing/pull/1548
- NoSubscriber no-op Subscriber https://github.com/tokio-rs/tracing/pull/1549
- Box/Arc Layer (https://github.com/tokio-rs/tracing/pull/1536 +
  https://github.com/tokio-rs/tracing/pull/1547)
- log filtering fixes https://github.com/tokio-rs/tracing/pull/1543

Local: force `log` and `log-always` features off. This removes the
`enable-trace-logging` flag from smartplatform/reconciler.

Reviewed By: guswynn

Differential Revision: D30906032

fbshipit-source-id: fdc3e4e29a39e9e181d9f4ff017e6b3e16acdcd8
2021-09-15 16:52:25 -07:00
Jeremy Fitzhardinge
cbceb08640 third-party/rust: local patch to tracing-subscriber
Summary:
Add impls for Layer for Box/Arc<L: Layer> and <dyn Layer>. Also a pile of other
updates in git which haven't been published to crates.io yet, including proper
level filtering of trace events being fed into log.

Reviewed By: dtolnay

Differential Revision: D30829927

fbshipit-source-id: c01c9369222df2af663e8f8bf59ea78ee12f7866
2021-09-09 22:38:25 -07:00
Arun Kulshreshtha
354fe9e111 edenapi_service: automatically compress EdenApiHandler responses
Summary: The new `EdenApiHandler` framework for defining EdenAPI endpoints provides a common place where responses are encoded. This diff adds automatic content compression at this point, using the received `Accept-Encoding` header from the request to determine what compression, if any, should be used. As a result, all endpoints that implement `EdenApiHandler` will get compression for free.

Reviewed By: yancouto

Differential Revision: D30553242

fbshipit-source-id: 9eda54cbf81dd1e03abec769744c96b16fad64ea
2021-09-08 11:33:19 -07:00
Thomas Orozco
35e3466031 third-party/rust: update daemonize to 0.5
Summary:
Like it says in the title, this updates us to use Daemonize 0.5, though from
Github and not Crates.io, because it hasn't been released to the latter yet.

The main motivation here is to pull in
https://github.com/knsd/daemonize/pull/39 to avoid leaking PID files to
children of the daemon.

This required some changes in `hphp/hack/src/facebook/hh_decl`  and `xplat/rust/mobium` since the way to
run code after daemonization has changed (and became more flexible).

Reviewed By: ndmitchell

Differential Revision: D30694946

fbshipit-source-id: d99768febe449d7a079feec78ab8826d0e29f1ef
2021-09-02 06:27:03 -07:00
Thomas Orozco
0d2bfbeccd Update autocargo component on FBS:master
Summary:
Manual component version update
Bump Schedule: https://www.internalfb.com/intern/msdk/bump/?schedule_fbid=342556550408072
Package: https://www.internalfb.com/intern/msdk/package/181247287328949/
Oncall Team: rust_foundation
NOTE: This build is expected to expire at 2022/09/01 09:14AM PDT
---------
New project source changes since last bump based on D30663071 (08e362a355e0a64a503f5073f57f927394696b8c at 2021/08/31 03:47AM -05):
| 2021/08/31 04:41AM -05 | generatedunixname89002005294178 | D30665384 | [MSDK] Update autocargo component on FBS:master |
| 2021/08/31 07:14PM PDT | kavoor | D30681642 | [autocargo] Make cxx-build match version of cxx |
| 2021/09/01 04:05PM BST | krallin | D30698095 | autocargo: include generated comment in OSS manifests |
---------

build-break (bot commits are not reviewed by a human)

Reviewed By: farnz

Differential Revision: D30717040

fbshipit-source-id: 2c1d09f0d51b6ff2e2636496cf22bcf781f22889
2021-09-02 02:33:56 -07:00
David Tolnay
ba87c55127 third-party/rust: Patch mockall_derive to fix nondeterminism failures in Conveyor
Summary:
The mockall crate's `automock` attribute previously created nondeterministic output, which leads to frequent random "Found possibly newer version of crate" failures in Buck builds that involve cache.

The affected trait in Conveyor is:

https://www.internalfb.com/code/fbsource/[4753807291f7275a061d67cead04ea12e7b38ae2]/fbcode/conveyor/common/just_knobs/src/lib.rs?lines=13-23

which has a method with two lifetime parameters. Mockall's generated code shuffled them in random order due to emitting the lifetimes in HashSet order. The generated code would randomly contain one of these two types:

`Box<dyn for<'b, 'a> FnMut(&str, Option<&'a str>, Option<&'b str>) -> Result<bool> + Send>`

`Box<dyn for<'a, 'b> FnMut(&str, Option<&'a str>, Option<&'b str>) -> Result<bool> + Send>`

Reviewed By: jsgf

Differential Revision: D30656936

fbshipit-source-id: c1a251774333d7a4001a7492c1995efd84ff22e5
2021-08-30 21:12:18 -07:00
Gus Wynn
87a09132dc tokio -> 1.10
Reviewed By: dtolnay

Differential Revision: D30647831

fbshipit-source-id: 7094873ec5cfbf80cd7c3564fdd011268053b0d3
2021-08-30 15:55:16 -07:00
CodemodService Bot
0a375b8e5d Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: StanislavGlebik

Differential Revision: D30535840

fbshipit-source-id: a941161547246c1e9aac0735a1994f20389ce1ae
2021-08-25 03:07:04 -07:00
David Tolnay
cf16f0b157 Add nested-values feature to slog
Reviewed By: zertosh

Differential Revision: D30387633

fbshipit-source-id: 27b1d601a73abf522d835c2f857d5a621c2b693b
2021-08-18 10:47:58 -07:00
Robbin Xu
0af6c0031f Revert D30351289: Add nested-values feature to slog
Differential Revision:
D30351289 (637bd00002)

Original commit changeset: b6c1c896b06c

fbshipit-source-id: c226f283a744170bb6bc2ed0b00e59249f9392c3
2021-08-17 16:33:26 -07:00
Matt Smith
637bd00002 Add nested-values feature to slog
Summary:
The diff is giant, but it's just a one-line change to add the
nested-values feature to slog, we just have a whole bunch of projects dependent
on slog.

Reviewed By: dtolnay

Differential Revision: D30351289

fbshipit-source-id: b6c1c896b06cbdf23b1f92c0aac9a97aa116085d
2021-08-17 15:28:16 -07:00
Thomas Orozco
de5b8e2dcb rust: ignore metadata-sys rules in Autocargo
Summary:
Autocargo only allows 1 rust-library per Cargo.toml, but right now we have 3
per Thrift library so that doesn't work:

https://www.internalfb.com/intern/sandcastle/log/?instance_id=27021598231105145&step_id=27021602582167211&step_index=13&name=Run%20config

There's little benefit in Autocargo-ifying those rules anyway since they're of
use to Thrift servers and this doesn't work at all in our OSS builds, so let's
just see if we can just noop them. That'll make the crate not exist at all as a
dep, but even considering that it exists only to link to a C++ library that
Autocargo doesn'tk now how to build anyway, that seems OK?

drop-conflicts

Reviewed By: markbt

Differential Revision: D30304720

fbshipit-source-id: 047524985b2dadab8610267c05e3a1b3770e84e6
2021-08-13 10:43:40 -07:00
Arun Kulshreshtha
a69d9d91de third-party/rust: disable lzma and xz features for async-compression
Summary:
The `async-compression` crate is currently only used by Mononoke for zstd and gzip compression. We'd like to use it in Mercurial too (primarily for zstd), but unlike Mononoke, Mercurial needs to build on all platforms.

One of `async-compression`'s dependencies, `lzma-sys`, has a complicated build script which required extensive fixups (see D21455819). Unfortunately, `lzma-sys` currently does not build on Windows with Buck because the [fixups.toml](https://www.internalfb.com/code/fbsource/[ba27fac3d5b5]/third-party/rust/fixups/lzma-sys/fixups.toml?lines=35) and [a fixup header file](https://www.internalfb.com/code/fbsource/[468048d6e50b]/third-party/rust/fixups/lzma-sys/include/config.h?lines=34) both enable pthreads, which causes conditional compilation to attempt to include POSIX dependencies.  The exact error is:

```
third-party/rust/vendor/lzma-sys-0.1.16/xz-5.2/src/common\mythread.h:103:10: fatal error: 'sys/time.h' file not found
```
Given that this crate is currently only used by Mercurial and Mononoke, and only for the zstd algorithm in practice, as a quick workaround let's just disable LZMA and XZ support. This is unfortunate; it would be better to figure out how to make the fixup work correctly, but Buck on Windows is such a niche use case at the moment that I'm not really sure where to begin.

Reviewed By: dtolnay

Differential Revision: D30271553

fbshipit-source-id: 76560c39b6f2d8750fa34c30ccb3e7db734e92a7
2021-08-12 09:30:58 -07:00
Alex Hornby
2f28c4121c rust: remove chashmap from cargo vendoring
Summary: Previous diffs switched all our usage from chashmap to dashmap as dashmap upstream is more responsive. Now remove chashmap from the cargo vendoring.

Reviewed By: dtolnay

Differential Revision: D30046522

fbshipit-source-id: 111ef9375bd8095f8b7c95752ecbc1988fb0438d
2021-08-04 07:31:08 -07:00
David Tolnay
aa8152f1dd Make thrift-generated dyn async traits future compatible
Summary:
The use of dyn traits of the Thrift-generated server traits was emitting future compatibility warnings with recent versions of rustc, due to a fixed soundness hole in the trait object system:

```
error: the trait `x_account_aggregator_if::server::XAccountAggregator` cannot be made into an object
     |
     = this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
```

This diff pulls in https://github.com/dtolnay/async-trait/releases/tag/0.1.51 which results in the Thrift-generated server traits no longer hitting the problematic pattern.

Reviewed By: zertosh

Differential Revision: D29979939

fbshipit-source-id: 3e6e976181bfcf35ed453ae681baeb76a634ddda
2021-07-29 16:25:33 -07:00
Arun Kulshreshtha
14d8c051c1 third-party/rust: remove patch from curl and curl-sys
Summary:
The patches to these crates have been upstreamed.

allow-large-files

Reviewed By: jsgf

Differential Revision: D29891894

fbshipit-source-id: a9f2ee0744752b689992b770fc66b6e66b3eda2b
2021-07-26 15:00:16 -07:00
CodemodService Bot
0a402ce760 Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: krallin

Differential Revision: D29841733

fbshipit-source-id: c9da8e0324f402f3b9726f2733b51de56abde8f6
2021-07-22 09:22:41 -07:00
Harvey Hunt
14ba455e60 mononoke: Use new rate limiting crate
Summary:
Update Mononoke server to use the new `rate_limiting` crate. This diff
also removes the old rate limiting library.

Differential Revision: D29396507

fbshipit-source-id: 05adb9322705b771a739c8bcaf2816c95218a42d
2021-07-05 10:18:51 -07:00
Harvey Hunt
a92eae78ae mononoke: lfs: Use new load shedding config
Summary:
Replace the LFS server's load shedding logic with that provided by the
`rate_limiting` crate.

Differential Revision: D29396503

fbshipit-source-id: a71812a55b9c9f111ee2861dc1b131ad20ca82d2
2021-07-05 10:18:51 -07:00
Xavier Deguillard
41897e3acc third-party: patch os_info to properly support Centos Stream
Summary:
This is just updating the os_info crate to my fork with a fix for Centos
Stream: https://github.com/stanislav-tkach/os_info/pull/267

Reviewed By: quark-zju

Differential Revision: D29410043

fbshipit-source-id: 3642e704f5a056e75fee4421dc59020fde13ed5e
2021-06-25 21:07:33 -07:00
Thomas Orozco
8c83bd9a1c third-party/rust: update Tokio to 1.7.1
Summary: There is a regression in 1.7.0 (which we're on at the moment) so we might as well update.

Reviewed By: zertosh, farnz

Differential Revision: D29358047

fbshipit-source-id: 226393d79c165455d27f7a09b14b40c6a30d96d3
2021-06-25 06:17:41 -07:00
Andrew Gallagher
05cf7acd77 object-0.25.3: patch SHT_GNU_versym entsize fix
Summary:
Pull in a patch which fixes writing out an incorrect entsize for the
`SHT_GNU_versym` section:
ddbae72082

Reviewed By: igorsugak

Differential Revision: D29248208

fbshipit-source-id: 90bbaa179df79e817e3eaa846ecfef5c1236073a
2021-06-21 09:31:49 -07:00
Andres Suarez
845128485c Update bytecount
Reviewed By: dtolnay

Differential Revision: D29213998

fbshipit-source-id: 92e7a9de9e3d03f04b92a77e16fa0e37428fe2fb
2021-06-17 19:50:32 -07:00
Davide Cavalca
b82c5672fc Update several rust crate versions
Summary: Update versions for several of the crates we depend on.

Reviewed By: danobi

Differential Revision: D29165283

fbshipit-source-id: baaa9fa106b7dad000f93d2eefa95867ac46e5a1
2021-06-17 16:38:19 -07:00
CodemodService Bot
4c4dfd45ad Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: krallin

Differential Revision: D29158387

fbshipit-source-id: 48a0b590e01083d762bbed2b7e272cbefc72641f
2021-06-16 04:50:15 -07:00
Alex Hornby
4457092322 rust: revert zstd crates
Summary: revert the zstd crates back to previous version

Reviewed By: johansglock

Differential Revision: D29038514

fbshipit-source-id: 3cbc31203052034bca428441d5514557311b86ae
2021-06-11 04:39:54 -07:00
Alex Hornby
f89dbebae8 rust: update zstd bindings to 1.5.0
Summary: Update to latest version.  This includes a patch to async-compression crate from [my PR updating it](https://github.com/Nemo157/async-compression/pull/125), I will remove once the crate is released.

Reviewed By: mitrandir77

Differential Revision: D28897019

fbshipit-source-id: 07c72f2880e7f8b85097837d084178c6625e77be
2021-06-08 07:57:29 -07:00
CodemodService Bot
254d2a37ad Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: krallin

Differential Revision: D28928316

fbshipit-source-id: 6da6c9a5321d722a3dfd816b49f3994df98c7471
2021-06-07 02:19:59 -07:00
CodemodService Bot
65062e63e7 Daily common/rust/cargo_from_buck/bin/autocargo
Reviewed By: farnz

Differential Revision: D28671045

fbshipit-source-id: cbb9dc477bc2a579133d1f68e2a4c12dc0bec456
2021-05-25 17:03:52 -07:00
Thomas Orozco
846a983d67 thrift/lib/rust: update to Bytes 1.x
Summary:
Like it says in the title. The API between Bytes 1.x has changed a little bit,
but the concepts are basically the same, so we just need to change the
callsites that were calling `bytes()` and have them ask for `chunk()` instead.

This diff attempts to be as small as it can (and it's already quite big). I
didn't attempt to update *everything*: I only updated whatever was needed to
keep `common/rust/tools/scripts/check_all.sh` passing.

However, there are a few changes that fall out of this. I'll outline them here:

## `BufExt`

One little caveat is the `copy_to_bytes` we had on `BufExt`. This was
introduced into Bytes 1.x (under that name), but we can't use it here directly.

The reason we can't is because the instance we have is a `Cursor<Bytes>`, which
receives an implementation of `copy_from_bytes` via:

```
impl<T: AsRef<[u8]>> Buf for std::io::Cursor<T>
```

This means that implementation isn't capable of using the optimized
`Bytes::copy_from_bytes` which doesn't do a copy at all. So, instead, we need
to use a dedicated method on `Cursor<Bytes>`: `copy_or_reuse_bytes`.

## Calls to `Buf::to_bytes()`

This method is gone in Bytes 1.x, and replaced by the idiom
`x.copy_to_bytes(x.remaining())`, so I updated callsites of `to_bytes()`
accordingly.

## `fbthrift_ext`

This set of crates provides transports for Thrift calls that rely on Tokio 0.2
for I/O. Unfortunately, Tokio 0.2 uses Bytes 0.5, so that doesn't work well.

For now, I included a copy here (there was only one required, when reading from
the socket). This can be removed if we update the whole `fbthrift_ext` stack to
Bytes 1.x. fanzeyi had been wanting to update this to Tokio 1.x, but was blocked on `thrift/lib/rust` using Bytes 0.5, and confirmed that the overhead of a copy here is fine (besides, this code can now be updated to Tokio 1.x to remove the copy).

## Crates using both Bytes 0.5 & Bytes 1.x

This was mostly the case in Mononoke. That's no coincidence: this is why I'm
working on this. There, I had to make changes that consist of removing Bytes
0.5 to Bytes 1.x copies.

## Misuse of `Buf::bytes()`

Some places use `bytes()` when they probably mean to use `copy_to_bytes()`. For
now, I updated those to use `chunk()`, which keeps the behavior the same but
keeps the code buggy. I filed T91156115 to track fixing those (in all
likelihood I will file tasks for the relevant teams).

Reviewed By: dtolnay

Differential Revision: D28537964

fbshipit-source-id: ca42a614036bc3cb08b21a572166c4add72520ad
2021-05-20 09:44:41 -07:00
Thomas Orozco
9f9709fcd8 mononoke/gotham_ext: update away from deprecated async-compression stream module
Summary:
This is deprecated now: https://docs.rs/async-compression/0.3.8/async_compression/stream/index.html

Lets update as documented there.

Reviewed By: farnz

Differential Revision: D28509889

fbshipit-source-id: b28713fcad3b1b2ec3ff8bec766fe05c4edba200
2021-05-18 10:30:22 -07:00
Stanislau Hlebik
eab97b6123 mononoke: sync changeset implementation for megarepo
Summary: First stab at implementing sync changeset functionality for megarepo.

Reviewed By: ikostia

Differential Revision: D28357210

fbshipit-source-id: 660e3f9914737929391ab1b29f891b3b5dd47638
2021-05-13 10:04:21 -07:00
Stefan Filip
1852d28c38 edenapi_service: add CustomCborStream
Summary:
Some EdenapiEndpoints serialize their error and send them to the client. This
robs the gotham framework from the change of seeing those errors. This custom
stream takes care of counting those errors and reporting them to gotham for
logging.

There is a slight worry in the back of my head that if we start getting errors,
CPU utilization will increase because we construct so many extra strings.

Reviewed By: kulshrax

Differential Revision: D28109314

fbshipit-source-id: ab39a05227e0f8be9205d6036d32523cb1e45ca4
2021-05-06 09:14:10 -07:00
Alex Hornby
da5dac311b rust: remove patch for async-compression
Summary: Upstream crate has landed my PR for zstd 1.4.9 support and made a release, so can remove this patch now.

Reviewed By: ikostia

Differential Revision: D28221163

fbshipit-source-id: b95a6bee4f0c8d11f495dc17b2737c9ac9142b36
2021-05-05 12:20:34 -07:00
Thomas Orozco
16fa5d1bdf mononoke: sample logging from Quicksand
Summary:
Quicksand is about 60% of our logging, but we don't really need to log
everything it does because the workload is pretty much the same across all
hosts.

Reviewed By: HarveyHunt

Differential Revision: D28225416

fbshipit-source-id: 68c0f68c4da73e0f7543754c917d7efa4bbf374e
2021-05-05 11:02:50 -07:00
Toan Mai
410f7c5c61 Imported a mysql_common patch to support FromRow for tuples up to arity 16 (#23)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/rust-shed/pull/23

Pull Request resolved: https://github.com/facebookincubator/resctl/pull/8081

Pull Request resolved: https://github.com/facebookexperimental/eden/pull/82

Imported a mysql_common patch to support FromRow for tuples upto arity 16
Context: https://fburl.com/zfnw7r86

Followed the guide: https://www.internalfb.com/intern/wiki/Rust-at-facebook/Managing_fbsource_third-party_with_Reindeer/#maintaining-local-change

Reviewed By: marcelogomez

Differential Revision: D28094262

fbshipit-source-id: fed48e3950e8a3ba3d7a15407522167e5ae41a98
2021-05-05 10:32:48 -07:00
Gus Wynn
cbbb45206b slog max_level_debug -> trace
Reviewed By: Imxset21

Differential Revision: D28097080

fbshipit-source-id: 7d417f8256922926cf379d9c2fb3249f6d2544ef
2021-05-03 10:30:21 -07:00
Thomas Orozco
9c7aa6aaf7 third-party/rust: remove patches for Tokio 0.2 & Hyper 0.2
Summary:
We used to carry patches for Tokio 0.2 to add support for disabling Tokio coop
(which was necessary to make Mononoke work with it), but this was upstreamed
in Tokio 1.x (as a different implementation), so that's no longer needed. Nobody
else besides Mononoke was using this.

For Hyper we used to carry a patch with a bugfix. This was also fixed in Tokio
1.x-compatible versions of Hyper. There are still users of hyper-02 in fbcode.
However, this is only used for servers and only when accepting websocket
connections, and those users are just using Hyper as a HTTP client.

Reviewed By: farnz

Differential Revision: D28091331

fbshipit-source-id: de13b2452b654be6f3fa829404385e80a85c4420
2021-04-29 08:07:45 -07:00
Thomas Orozco
ffed22260d third-party/rust: remove Gotham 0.2
Summary:
This used to be used by Mononoke, but we're now on Tokio 1.x and on
corresponding versions of Gotham so it's not needed anymore.

Reviewed By: farnz

Differential Revision: D28091091

fbshipit-source-id: a58bcb4ba52f3f5d2eeb77b68ee4055d80fbfce2
2021-04-29 08:07:45 -07:00
Thomas Orozco
0f44a4f106 mononoke: update to tokio 1.x
Summary:
NOTE: there is one final pre-requisite here, which is that we should default all Mononoke binaries to `--use-mysql-client` because the other SQL client implementations will break once this lands. That said, this is probably the right time to start reviewing.

There's a lot going on here, but Tokio updates being what they are, it has to happen as just one diff (though I did try to minimize churn by modernizing a bunch of stuff in earlier diffs).

Here's a detailed list of what is going on:

- I had to add a number `cargo_toml_dir` for binaries in `eden/mononoke/TARGETS`, because we have to use 2 versions of Bytes concurrently at this time, and the two cannot co-exist in the same Cargo workspace.
- Lots of little Tokio changes:
  - Stream abstractions moving to `tokio-stream`
  - `tokio::time::delay_for` became `tokio::time::sleep`
  - `tokio::sync::Sender::send` became `tokio::sync::Sender::broadcast`
  - `tokio::sync::Semaphore::acquire` returns a `Result` now.
  - `tokio::runtime::Runtime::block_on` no longer takes a `&mut self` (just a `&self`).
  - `Notify` grew a few more methods with different semantics. We only use this in tests, I used what seemed logical given the use case.
- Runtime builders have changed quite a bit:
  - My `no_coop` patch is gone in Tokio 1.x, but it has a new `tokio::task::unconstrained` wrapper (also from me), which I included on  `MononokeApi::new`.
  - Tokio now detects your logical CPUs, not physical CPUs, so we no longer need to use `num_cpus::get()` to figure it out.
- Tokio 1.x now uses Bytes 1.x:
  - At the edges (i.e. streams returned to Hyper or emitted by RepoClient), we need to return Bytes 1.x. However, internally we still use Bytes 0.5 in some places (notably: Filestore).
  - In LFS, this means we make a copy. We used to do that a while ago anyway (in the other direction) and it was never a meaningful CPU cost, so I think this is fine.
  - In Mononoke Server it doesn't really matter because that still generates ... Bytes 0.1 anyway so there was a copy before from 0.1 to 0.5 and it's from 0.1 to 1.x.
  - In the very few places where we read stuff using Tokio from the outside world (historical import tools for LFS), we copy.
- tokio-tls changed a lot, they removed all the convenience methods around connecting. This resulted in updates to:
  - How we listen in Mononoke Server & LFS
  - How we connect in hgcli.
  - Note: all this stuff has test coverage.
- The child process API changed a little bit. We used to have a ChildWrapper around the hg sync job to make a Tokio 0.2.x child look more like a Tokio 1.x Child, so now we can just remove this.
- Hyper changed their Websocket upgrade mechanism (you now need the whole `Request` to upgrade, whereas before that you needed just the `Body`, so I changed up our code a little bit in Mononoke's HTTP acceptor to defer splitting up the `Request` into parts until after we know whether we plan to upgrade it.
- I removed the MySQL tests that didn't use mysql client, because we're leaving that behind and don't intend to support it on Tokio 1.x.

Reviewed By: mitrandir77

Differential Revision: D26669620

fbshipit-source-id: acb6aff92e7f70a7a43f32cf758f252f330e60c9
2021-04-28 07:36:31 -07:00
Thomas Orozco
eb3f97b858 mononoke/gotham_ext: remove ForwardErr
Summary: This is not used anymore.

Reviewed By: sfilipco

Differential Revision: D27998038

fbshipit-source-id: 7f8de56897931d72e6bc3405b463a2302d5da6a3
2021-04-27 11:00:16 -07:00
Thomas Orozco
f1a4c3e615 mononoke/gotham_ext: introduce CaptureFirstError
Summary:
In EdenAPI, most endpoints don't raise errors when they fail, and instead just take items out of the response stream (though there are some exceptions: D24315399 (0ccae1cef9).

Right now, this just gets logged to stderr, which isn't great. This diff introduces a CaptureFirstError wrapper we can use to capture those errors and expose them in post-response callbacks (i.e. Scuba).

Reviewed By: sfilipco

Differential Revision: D27998036

fbshipit-source-id: 960d0e09a82ca79adfafe22e2eeef2e0294d27dc
2021-04-27 11:00:16 -07:00
Thomas Orozco
006932c7bc mononoke/gotham_ext: remove DefaultScubaHandler
Summary: It's not used.

Reviewed By: mitrandir77

Differential Revision: D27967990

fbshipit-source-id: 0c332e6ef44af369fdd943a759342210f2e65e4a
2021-04-27 08:10:34 -07:00