Commit Graph

182 Commits

Author SHA1 Message Date
Aida Getoeva
1240231656 mononoke/mysql: share single connection pool in the same SMC between shards
Summary:
In Mononoke for a sharded DB we historically used connection pool size 1 per shard. With the Mysql FFI client now it doesn't make sense, as the client's conn pool is smart enough and designed to works with sharded DBs, so currently we don't even benefit from having a pool.

In this diff I added an API to create sharded connections: a single pool is shared between all the shards.

Reviewed By: farnz

Differential Revision: D24475317

fbshipit-source-id: b7142c030a10ccfde1d5a44943b38cfa70332c6a
2020-11-05 05:34:22 -08:00
Alex Hornby
511530d030 mononoke: change the default blobstore put behaviour to IfAbsent
Summary: Change the default blobstore put behaviour to IfAbsent, so that all binaries apart from admin tools using MononokeApp::special_put_behaviour() pick up the change.

Reviewed By: farnz

Differential Revision: D24619663

fbshipit-source-id: 98439513b985d2cde88ef99e5eb177974e9db5c9
2020-10-29 16:07:22 -07:00
Alex Hornby
89ace3790f mononoke: extend MononokeApp so admin apps can have a special default put behaviour
Summary:
Extend MononokeApp so admin apps can have a special default put behaviour (typically
 overwrite) vs the soon to be new default of IfAbsent

Use it from the admin tools.

Reviewed By: farnz

Differential Revision: D24623094

fbshipit-source-id: 5709c68429f8e1de0535eec132998d20411fc0e6
2020-10-29 16:07:22 -07:00
Simon Farnsworth
d0110ce4a8 Support marking garbage in SQLBlob
Summary:
We want to be able to detect garbage blobs by looking at generation numbers.

Update generation numbers on put, and have a mark command exist to mark blobs as not garbage.

Reviewed By: ahornby

Differential Revision: D23989289

fbshipit-source-id: d96f38649151e3dbd5297cffc262776e74f6cc86
2020-10-28 10:23:55 -07:00
Stanislau Hlebik
972ce32a65 mononoke: fix warnings
Reviewed By: krallin

Differential Revision: D24564863

fbshipit-source-id: 0c461aac40ae50d7315cdcda21e9d7b003a5e536
2020-10-27 09:13:42 -07:00
Simon Farnsworth
4e59e26775 Thread ConfigStore into blobstore creation
Summary: SQLBlob GC (next diff in stack) will need a ConfigStore in SQLBlob. Make one available to blobstore creation

Reviewed By: krallin

Differential Revision: D24460586

fbshipit-source-id: ea2d5149e0c548844f1fd2a0d241ed0647e137ae
2020-10-27 04:14:24 -07:00
Thomas Orozco
24560ded2e thrift: call hooks from Rust codegen
Summary:
This updates Thrift codegen for Rust to call hooks on a context stack in a
similar fashion as the C++ codegen.

There is still a bit of room for improvement here. Notably, we don't know how
much data we actually read or sent to the client, so for now those are
hard-coded to zero in the codegen. That's better than not calling those hooks
at all (which is what happens right now), but it could stand to be improved.

Reviewed By: jsgf

Differential Revision: D24445298

fbshipit-source-id: 470daf03057424dc300b6a193668be835ae28452
2020-10-22 17:01:47 -07:00
Thomas Orozco
ada1d7e7a9 mononoke/{multiplexedblob,logblob}: capture operation perf counters
Summary:
This updates multiplexedblob and logblob to capture perf counters for the
operations we run, and log them to Scuba. Along with the previous diffs in this
stack, this gives us the number of Manifold retries, total delay, and conflicts
all logged to blobstore trace on a per-operation basis.

Reviewed By: HarveyHunt

Differential Revision: D24333039

fbshipit-source-id: 9c7d0a467f8df08dcb2a0d3bb6b543cdb3ea1d90
2020-10-16 08:57:13 -07:00
Thomas Orozco
63158883e3 mononoke/manifoldblob: log retries, delay and conflicts to perf counters
Summary:
This updates ManifoldBlob to log the aformentioned data points to perf
counters. There's a bit of refactoring that also had to go into this to make
`ctx` available everywhere it's needed.

Reviewed By: aslpavel

Differential Revision: D24333040

fbshipit-source-id: 1b63bcd1e1ee36bae4dbbc1da053c7f1bdf96675
2020-10-16 08:57:13 -07:00
Alex Hornby
c2bb337653 mononoke: delegate chaosblob put to put_impl
Summary:
Delegate chaosblob put to put_impl to remove some duplication.

This is possible as all chaosblob construction has an inner BlobstorePutOps.

Reviewed By: StanislavGlebik

Differential Revision: D24258401

fbshipit-source-id: dee9fce888e5ef9c2f34865c97921b9cc87ac3bf
2020-10-13 06:25:58 -07:00
Alex Hornby
c52f1faba0 mononoke: add put overwrite counters to CountedBlobstore
Summary: Add put overwrite counters to CountedBlobstore.

Reviewed By: StanislavGlebik

Differential Revision: D24254922

fbshipit-source-id: 8de56cee17ebe411e92d1d0e7c4ff2addca6308c
2020-10-13 03:09:39 -07:00
Alex Hornby
1fed539319 mononoke: factor out common code in throttledblob
Summary: Factor out common async limit code in throttledblob to throttled_access function.

Reviewed By: StanislavGlebik

Differential Revision: D24254357

fbshipit-source-id: 8f3277ccc065e3eb93f089edb2f3bd12e80ef352
2020-10-13 03:09:38 -07:00
Alex Hornby
a13cbcf12f mononoke: remove BlobstorePutOps::put_behaviour
Summary:
Remove BlobstorePutOps::put_behaviour and the default implementation of BlobstorePutOps::put_with_status as they did not make sense for multiplexed stores

This resolves the corresponding TODO in multiplexblob/base.rs

Reviewed By: StanislavGlebik

Differential Revision: D24162629

fbshipit-source-id: aa175bbedac473093dd1862226e910dea15c1299
2020-10-13 03:09:38 -07:00
Alex Hornby
570cd79b3a mononoke: make multiplex blobstore a BlobstorePutOps
Summary:
Implement BlobstorePutOps for multiplex blobstores, so restoring the ability to have multiplexes of multiplexes.

Note that this makes BlobstorePutOps::put_behaviour accessor problematic as the inner stores could have different put_behaviour, will remove it in next diff so as to keep this diff reasonable size.

Reviewed By: StanislavGlebik

Differential Revision: D24162235

fbshipit-source-id: 2ace3af5f60607996e449451316c5c0720351f82
2020-10-13 03:09:38 -07:00
Alex Hornby
011f3ffa76 mononoke: add overwrite status logging to multiplexblob puts
Summary:
Add overwrite status logging to multiplexblob puts now that the inner types held all implement BlobstorePutOps

This has the effect of making any configuration that specifies a multiplex of multiplexes invalid, which is addressed in next diff in stack.

Reviewed By: StanislavGlebik

Differential Revision: D24159958

fbshipit-source-id: dd1f70a636dfb36686d796af7afd8d5da8797a23
2020-10-13 03:09:38 -07:00
Alex Hornby
d9777a38fa mononoke: delegate put to put_with_status for logblob
Summary: Delegate put to put_with_status for logblob now that the blobstore factory can provide right inner type.

Reviewed By: StanislavGlebik

Differential Revision: D24109296

fbshipit-source-id: 1493421f632708d8ec24bd9f7c5cd5745f17ae68
2020-10-13 03:09:37 -07:00
Alex Hornby
05e62f0a26 mononoke: delegate put to put_with_status for packblob
Summary: Delegate put to put_with_status for packblob now that the blobstore factory can provide right inner type

Reviewed By: StanislavGlebik

Differential Revision: D24109288

fbshipit-source-id: 745fe3f6398833c9ac51e70f4d1c2959fceba0d5
2020-10-13 03:09:37 -07:00
Alex Hornby
934a491ed3 mononoke: make blobstore_factory PutBehaviour aware
Summary:
Make blobstore_factory PutBehaviour aware by layering all except the final multiplex as BlobstorePutOps

This makes it so all the components that go into a multiplex are BlobstorePutOps,  which is a prerequisite for making the multiplex logging include the Overwrite status.

Reviewed By: StanislavGlebik

Differential Revision: D24109289

fbshipit-source-id: 23f4cedbaebadae194e41cfbff9ef46b651e3fd4
2020-10-13 03:09:37 -07:00
Alex Hornby
4acca67600 mononoke: make logblob PutBehaviour aware
Summary:
log whether puts overwrite keys by implementing BlobstoreWithPutBehaviour for Logblob.

It logs a count of type of overwrite per put so we can sum them up.

Reviewed By: StanislavGlebik

Differential Revision: D24079272

fbshipit-source-id: 81944d92a56b0d3349ef390eb83f9e5bf4ee3d39
2020-10-13 03:09:37 -07:00
Alex Hornby
8df59b224b mononoke: make throttleblob PutBehaviour aware
Summary: Make throttleblob PutBehaviour aware

Reviewed By: StanislavGlebik

Differential Revision: D24109295

fbshipit-source-id: 9d5f712946ba3089facaa8f8c36b48f54338972f
2020-10-13 03:09:37 -07:00
Alex Hornby
6ed216b54b mononoke: make packblob PutBehaviour aware
Summary: Make packblob PutBehaviour aware

Reviewed By: StanislavGlebik

Differential Revision: D24109291

fbshipit-source-id: 01c4461feef2d84ec1e68703689234de94a3aec5
2020-10-12 12:12:21 -07:00
Alex Hornby
525f206b8d mononoke: make chaosblob PutBehaviour aware
Summary: Make chaosblob PutBehaviour aware

Reviewed By: farnz

Differential Revision: D24109297

fbshipit-source-id: 9b43262f00442bb5e70adf3c220795d23044dbdf
2020-10-12 12:12:21 -07:00
Alex Hornby
a80176f699 mononoke: make readonlyblob PutBehaviour aware
Summary: Update readonlyblob to be PutBehaviour aware

Reviewed By: StanislavGlebik

Differential Revision: D24109290

fbshipit-source-id: 2108c6969a4c15243efbca10daf64771e72a969b
2020-10-12 07:12:11 -07:00
Alex Hornby
6e2dfa2dd8 mononoke: add sqlblob to the common blobstore tests
Summary: Added sqlblob to the common blobstore tests to make sure it doesn't diverge from expectations for other stores.

Reviewed By: StanislavGlebik

Differential Revision: D24079254

fbshipit-source-id: 49ef1c372171a1594ba298c66d3473ef682d24cc
2020-10-12 07:12:10 -07:00
Alex Hornby
31b900bc08 mononoke: make CountedBlobstoreOps put behaviour aware
Summary:
Add CountedBlobstoreOps so that blobstore layers that need BlobstoreOps can still use counting

This unblocks adding sqlblob to blobstore-test in next diff in stack

Reviewed By: farnz

Differential Revision: D24079256

fbshipit-source-id: 6a6505aff8c8405353a1f10d79f6e6e08911228a
2020-10-12 07:12:10 -07:00
Alex Hornby
60a588aa87 mononoke: make prefixblob put behaviour aware
Summary: Add BlobstorePutOps so that blobstore layers that need BlobstorePutOps can still use PrefixBlob as a wrapper.

Reviewed By: farnz

Differential Revision: D24109298

fbshipit-source-id: 710571e6c30fa8a432d463eedfab5fcc0389baa3
2020-10-12 07:12:10 -07:00
Alex Hornby
48900ae545 mononoke: predicate based PutBehaviour logic to manifoldblob
Summary:
Add predicate based PutBehaviour logic to manifoldblob.

This will prevent overwrites of keys when in IfAbsent mode, and will generate useful logging in OverwriteAndLog and IsAbsent mode.

This change factors our part of the put logic to put_check_conflict, so that it can use re-used from each of the PutBehaviour cases.

Reviewed By: StanislavGlebik

Differential Revision: D24021170

fbshipit-source-id: d2e71afadada3d5e661634449108e6c9f8dc5907
2020-10-12 07:12:10 -07:00
Alex Hornby
9756def014 mononoke: implement BlobstorePutOps for sqlblob
Summary: Implement BlobstorePutOps for sqlblob

Differential Revision: D24021172

fbshipit-source-id: be24bc0d58263e190fdca546a3adf9b5815b3c4b
2020-10-08 04:59:11 -07:00
Alex Hornby
4e772d07d5 mononoke: implement BlobstorePutOps for S3Blob
Summary:
Implement BlobstorePutOps for S3Blob.  This uses is_present to check the various put behaviours

While implementing this I noticed get_sharded_key could be updated to take a reference, so I did that as well.

Differential Revision: D24079253

fbshipit-source-id: 16e194076dbdb4da8a7a9b779e0bd5fb60f550a6
2020-10-07 12:11:11 -07:00
Alex Hornby
cac5350f5f mononoke: add test for blobstore OverwriteStatus
Summary: Now that fileblob and memblob support put behaviour logic, update the overwrite test to check the overwrite result.

Differential Revision: D24021167

fbshipit-source-id: d9578630205cf5d79999a459cc29481968d5717d
2020-10-07 12:11:10 -07:00
Alex Hornby
cad15511f8 mononoke: update memblob to be PutBehaviour aware
Summary: Update memblob to be PutBehaviour aware by changing implementation from Blobstore to BlobstoreOps

Differential Revision: D24021166

fbshipit-source-id: 04dd25c5535769ea507120c1886592b808a7bbc6
2020-10-07 12:11:10 -07:00
Alex Hornby
fb1d4515df mononoke: update Memblob::new callsites to ::default()
Summary: Update Memblob::new callsites to ::default() in preparation for adding arguments to ::new() to specify the put behaviour desired

Differential Revision: D24021173

fbshipit-source-id: 07bf4e6c576ba85c9fa0374d5aac57a533132448
2020-10-07 12:11:10 -07:00
Alex Hornby
9c9401f691 mononoke: add put behaviour handling to fileblob
Summary: Add put behaviour handling to fileblob so that it can prevent overwrites if requested.

Differential Revision: D23933228

fbshipit-source-id: 8e74ac96b232be841174f6ad2bd2fccf92aaa90d
2020-10-07 12:11:10 -07:00
Alex Hornby
2abe862535 mononoke: add put behaviour to BlobstoreOptions
Summary:
Add put behaviour to BlobstoreOptions in preparation for passing in the put behaviour through blobstore_factory.

Later in the stack a command line option is added to set this non-None so that we can turn on overwrite logging for particular jobs.

Reviewed By: StanislavGlebik

Differential Revision: D24021169

fbshipit-source-id: 5692e2d3912ebde07b0d7bcce54b79df188a9f16
2020-10-07 12:11:10 -07:00
Alex Hornby
4f0b9c3e42 mononoke: introduce BlobstorePutOps for blobstore implementations
Summary:
This is the first part of allowing us to update mononoke blobstore put behaviour to optionally a) log when it is overwriting keys, and b) not overwrite existing keys.

Introduce BlobstorePutOps for blobstore implementations so we can track overwrite status of a put, and force an explicit PutBehaviour if required.  Its intended that only blobstore implementation code and special admin tooling will need to access BlobstorePutOps methods.

Reviewed By: farnz

Differential Revision: D24021168

fbshipit-source-id: 56ae34f9995a93cf1e47fbcfa2565f236c28ae12
2020-10-06 13:05:40 -07:00
Alex Hornby
42f5c54104 mononoke: remove unnecessary clone in packblob
Summary: Remove unnecessary clone in packblob along with the Clone constraint on the inner blobstore.

Reviewed By: krallin

Differential Revision: D24109293

fbshipit-source-id: b47e68e63b6ffda95d28d974ed6883e4ae31b3a1
2020-10-06 03:34:36 -07:00
Simon Farnsworth
83801357d4 Make SQLBlob overwrite on put rather than ignoring
Summary:
We want to end up with two `put` behaviours - overwrite and do not overwrite.

Currently, SQLBlob only implements the latter, but some users assume that `put` always overwrites. Change to match Manifold

Reviewed By: aslpavel

Differential Revision: D24079501

fbshipit-source-id: f75cac81acf874337c38f82597aae645c41a319b
2020-10-02 10:41:12 -07:00
Alex Hornby
409a9da79d mononoke: remove assert_present from Blobstore trait
Summary:
Remove assert_present from Blobstore trait as it had only one callsite other than the various blobstore layers/impls.

Replaced that one last call in repo_commit.rs/assert_in_blobstore() with an equivalent call to is_present.

Reviewed By: farnz

Differential Revision: D24016927

fbshipit-source-id: 764fddbebeb4b1192d196078b8824cf8a08e9691
2020-10-01 01:23:52 -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
Lukas Piatkowski
eea2b564a8 mononoke/s3blob: remove it from OSS (#62)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/62

This diff fixes OSS Mononoke build.

Reviewed By: HarveyHunt

Differential Revision: D23852016

fbshipit-source-id: 90371149a3566efdd5653b4ba5098dad81357ef2
2020-09-23 06:38:03 -07:00
Alex Hornby
d107b28d52 mononoke: SomeFailedOthersNone should not consider write mostly blobstores None if all other stores Error
Summary: SomeFailedOthersNone should not consider write mostly blobstores None if all other stores Error

Reviewed By: farnz

Differential Revision: D23840334

fbshipit-source-id: 9838bead6fec0d5f920e4a788387025d0dacf80b
2020-09-22 09:35:38 -07:00
Alex Hornby
d3a94e0a70 mononoke: Add a test for SomeFailedOthersNone when write mostly blobstore is None
Summary: Add a test for SomeFailedOthersNone when write mostly blobstore is None

Reviewed By: farnz

Differential Revision: D23840685

fbshipit-source-id: 81834663169b3a522b9c08e0a36f0b91354916c7
2020-09-22 09:35:38 -07:00
Egor Tkachenko
4d0ae8ae41 Added S3 blobstore
Summary:
Implemented S3 blobstore
Isilon implements S3 as 1:1 mapping into filesystem, and it limits the maximum number of blobs in the single directory. To overcome it lets shard the keys using base64 encoding and making 2 level dir structure with 2 chars dir names.

Reviewed By: krallin

Differential Revision: D23562541

fbshipit-source-id: c87aca2410381a07babb191cbd8cf28233556e03
2020-09-22 04:15:34 -07:00
Stanislau Hlebik
9fc2a01f0b mononoke: bump memcache key for blobstore
Summary:
I've re-backfilled some of blame values for configerator. But old values might
still be in memcache. To make sure that's not the case let's bump the memcache
key.

Reviewed By: krallin

Differential Revision: D23810971

fbshipit-source-id: c333a51ffb2babf7da808b276f9cfa31baaa105c
2020-09-21 01:47:01 -07:00
Alex Hornby
4203aca84b mononoke: include the causes in the log to mononoke_blobstore_trace
Summary:
We are currently logging only the outermost underlying error or context, not any of the lower level causes. This makes mononoke_blobstore_trace less useful!

This changes to use anyhow's alternate format that includes causes

Reviewed By: krallin

Differential Revision: D23708577

fbshipit-source-id: fa2e71734841e2b75d824c456dccf61c1fb13fd2
2020-09-16 02:02:56 -07:00
Johan Schuijt-Li
deb57a25ed mononoke: deprecate preamble in favor of metadata
Summary:
In preparation of moving away from SSH as an intermediate entry point for
Mononoke, let Mononoke work with newly introduced Metadata. This removes any
assumptions we now make about how certain data is presented to us, making the
current "ssh preamble" no longer central.

Metadata is primarily based around identities and provides some
backwards-compatible entry points to make sure we can satisfy downstream
consumers of commits like hooks and logs.

Simarly we now do our own reverse DNS resolving instead of relying on what's
been provided by the client. This is done in an async matter and we don't rely
on the result, so Mononoke can keep functioning in case DNS is offline.

Reviewed By: farnz

Differential Revision: D23596262

fbshipit-source-id: 3a4e97a429b13bae76ae1cdf428de0246e684a27
2020-09-15 10:28:38 -07:00
Thomas Orozco
21290702e1 third-party/rust: import async-compression + update zstd
Summary:
This imports the async-compression crate. We have an equivalent-ish in
common/rust, but it targets Tokio 0.1, whereas this community-supported crate
targets Tokio 0.2 (it offers a richer API, notably in the sense that we
can use it for Streams, whereas the async-compression crate we have is only for
AsyncWrite).

In the immediate term, I'd like to use this for transfer compression in
Mononoke's LFS Server. In the future, we might also use it in Mononoke where we
currently use our own async compression crate when all that stuff moves to
Tokio 0.2.

Finally, this also updates zstd: the version we link to from tp2 is actually
zstd 1.4.5, so it's a good idea to just get the same version of the zstd crate.

The zstd crate doesn't keep a great changelog, so it's hard to tell what has changed.
At a glance, it looks like the answer is not much, but I'm going to look to Sandcastle
to root out potential issues here.

Reviewed By: StanislavGlebik

Differential Revision: D23652335

fbshipit-source-id: e250cef7a52d640bbbcccd72448fd2d4f548a48a
2020-09-15 07:59:53 -07:00
Aida Getoeva
b92c64af7d shed/sql: make queries! macros work with new Rust mysql client
Summary:
shed/sql library used mainly to communicate with Mysql db and to have a nice abstraction layer around mysql (which is used in production) and sqlite (integration tests). The library provided an interface, that was backed up from Mysql side my raw connections and by MyRouter.
This diff introduces a new backend - new Mysql client for Rust.

New backend is exposed as a third variant for the current model: sqlite, mysql (raw conn and myrouter) and mysql2 (new client). The main reason for that is the fact that the current shed/sql interface for Mysql
(1) heavily depends on mysql_async crate, (2) introduces much more complexity than needed for the new client and (3) it seems like this will be refactored and cleaned up later, old things will be deprecated.
So to not overcomplicate things by trying to implement the given interface for the new Mysql client, I tried to simplify things by adding it as a third backend option.

Reviewed By: farnz

Differential Revision: D22458189

fbshipit-source-id: 4a484b5201a38cc017023c4086e9f57544de68b8
2020-09-11 06:33:37 -07:00
Simon Farnsworth
89e30973ff Report write errors when scrubbing
Summary: When we're scrubbing blobstores, it's not actually a success state if a scrub fails to write. Report this back to the caller - no-one will usually be scrubbing unless they expect repair writes to succeed, and a failure is a sign that we need to investigate further

Reviewed By: mitrandir77

Differential Revision: D23601541

fbshipit-source-id: d328935af9999c944719a6b863d0c86b28c54f59
2020-09-10 02:29:47 -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