Commit Graph

39 Commits

Author SHA1 Message Date
Simon Farnsworth
577d58ae72 Rearrange blobstore factory to ensure that PackBlob has a BlobstoreWithLink
Summary:
In the next diff, the packer will need to create PackBlobs with access to link and unlink operations on the underlying data store.

Rearrange blobstore factory so that this is guaranteed by design, noting that we will want to manually create just a PackBlob later.

Reviewed By: ahornby

Differential Revision: D27795485

fbshipit-source-id: e16c7baea4f2402a4f8f95d722adb5c422c5b8e3
2021-04-16 06:51:18 -07:00
Alex Hornby
169bc7d659 mononoke: add unlink operation to BlobstoreWithLink
Summary:
Add an unlink operation to BlobstoreWithLink for use from packblob in the next diff.

The reason an unlink operation is needed is so that pack keys don't keep old packed data live longer than it should be.  e.g.

Before the packer runs, keys A, B, C, D each point to content A, B, C, D

packer run 1: keys A and B are packed to P1. Keys A, B, P1 now all point to pack P1
GC run here can remove content A and B
packer run 2: keys A and C are packed to P2. Keys A, C, P2 now all point to P2.
GC run here can remove content C
packer run 3: keys B and D are packed to P3. Keys B, D, P3 now all point to P3.
GC run here can remove content B and D.
At this point, keys A, C point to pack P2, keys B, D point to pack P3.

If we don't unlink pack P1 during packer run 1 then GC can't collect the old pack after run 3 as the key P1 will keep it live; if we unlink key P1 after pointing keys A and B to point at P1, then when keys A and B stop pointing to pack P1, there will be no further references.

The unlink method is on the BlobstoreWithLink trait which most Mononoke code does not reference and therefore can't easily accidentally call.

Its modelled on posix unlink(2), it will error if the key being unlinked does not exist.

Reviewed By: farnz

Differential Revision: D27188109

fbshipit-source-id: 628698dd5894895e2aff5cf7db979d32e1bc2b3e
2021-03-24 11:12:51 -07:00
Simon Farnsworth
06009cf378 Add blobstore name information to logging
Summary:
With the upcoming rollout of C++ Manifold client, it's useful to know which blobstores are which in our Scuba log, `mononoke_blobstore_trace`.

Pass a debug name down to help

Reviewed By: krallin

Differential Revision: D26673162

fbshipit-source-id: e7c16ad217d8daf21565939a45ac82204459055a
2021-03-02 03:40:54 -08:00
Alex Hornby
a060ad11db mononoke: remove Arc and Clone from CountedBlobstore
Summary: Can remove Clone constraint and no need for Arc with some code tidyups

Reviewed By: farnz

Differential Revision: D26575852

fbshipit-source-id: 0cd31879c6d72cc7242e1c34ef5df07c96ac6e6c
2021-02-22 03:35:25 -08:00
Mark Juggurnauth-Thomas
8fe2b30e9a derived_data: commonise blobstore mapping implementations
Summary:
Create `BlobstoreMapping` as a trait with the common implementations for
derived data mappings that are stored in the blobstore.

Reviewed By: StanislavGlebik

Differential Revision: D25099915

fbshipit-source-id: 8a62fbb809918045336944c8cd3584b109811012
2020-12-02 07:33:41 -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
Lukas Piatkowski
15f0f924e6 mononoke/blobstore: use async_trait instead of BoxFuture
Reviewed By: farnz

Differential Revision: D25124793

fbshipit-source-id: 1ebe72d1db8043fabf9f20538f3e95c755e049e0
2020-11-23 07:58:34 -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
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
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
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
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
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
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
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
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
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
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
Simon Farnsworth
aa2df38491 Improve errors on scrub failure
Summary:
With three blobstores in play, we have issues working out exactly what's wrong during a manual scrub. Make the error handling better:

1. Manual scrub adds the key as context for the failure.
2. Scrub error groups blobstores by content, so that you can see which blobstore is most likely to be wrong.

Reviewed By: ahornby, krallin

Differential Revision: D23565906

fbshipit-source-id: a199e9f08c41b8e967d418bc4bc09cb586bbb94b
2020-09-09 07:25:13 -07:00
Alex Hornby
d59dd787c5 mononoke: make blobstore ctime a bit easier to use
Summary: Ctime is an Option<i64>, so rather than as_ctime()/into_ctime() use the fact that it's fairly small and Copy to just .ctime()

Reviewed By: krallin

Differential Revision: D23081739

fbshipit-source-id: be62912eca02e5c29d7473d6f386d98df11000dd
2020-08-14 02:09:46 -07:00
Santiago Alfonso Muñoz Rodriguez
007dc93916 Enumeration API for BlobStore keys
Summary:
- Enumerate API now provided via trait BlobstoreKeySource
- Implementation for Fileblob and ManifoldBlob
- Modified populate_healer to use new api
- Modified fixrepocontents to use new api

Reviewed By: ahornby

Differential Revision: D22763274

fbshipit-source-id: 8ee4503912bf40d4ac525114289a75d409ef3790
2020-08-04 06:54:18 -07:00
Alex Hornby
ecb58ff8d7 mononoke: add cmdlib argument to control cachelib zstd compression
Summary:
Add a cmdlib argument to control cachelib zstd compression. The default behaviour is unchanged, in that the CachelibBlobstore will attempted compression when putting to the cache if the object is larger than the cachelib max size.

To make the cache behaviour more testable, this change also adds an option to do an eager put to cache without the spawn. The default remains to do a lazy fire and forget put into the cache with tokio::spawn.

The motivation for the change is that when running the walker the compression putting to cachelib can dominate CPU usage for part of the walk, so it's best to turn it off and let those items be uncached as the walker is unlikely to visit them again (it only revisits items that were not fully derived).

Reviewed By: StanislavGlebik

Differential Revision: D22797872

fbshipit-source-id: d05f63811e78597bf3874d7fd0e139b9268cf35d
2020-07-31 01:12:02 -07:00
Simon Farnsworth
b1c85aaf4b Switch Blobstore to new-style futures
Summary:
Eventually, we want everything to be `async`/`await`; as a stepping stone in that direction, switch the remaining lobstore traits to new-style futures.

This just pushes the `.compat()` out to old-style futures, but it makes the move to non-'static lifetimes easier, as all the compile errors will relate to lifetime issues.

Reviewed By: krallin

Differential Revision: D22183228

fbshipit-source-id: 3fe3977f4469626f55cbf5636d17fff905039827
2020-06-26 03:54:42 -07:00
Simon Farnsworth
454de31134 Switch Loadable and Storable interfaces to new-style futures
Summary:
Eventually, we want everything to be `async`/`await`; as a stepping stone in that direction, switch some of the blobstore interfaces to new-style `BoxFuture` with a `'static` lifetime.

This does not enable any fixes at this point, but does mean that `.compat()` moves to the places that need old-style futures instead of new. It also means that the work needed to make the transition fully complete is changed from a full conversion to new futures, to simply changing the lifetimes involved and fixing the resulting compile failures.

Reviewed By: krallin

Differential Revision: D22164315

fbshipit-source-id: dc655c36db4711d84d42d1e81b76e5dddd16f59d
2020-06-25 08:45:37 -07:00
Alex Hornby
5e9223f633 mononoke: add link support to CountedBlobstore
Summary: Add link support to CountedBlobstore

Reviewed By: StanislavGlebik

Differential Revision: D22090644

fbshipit-source-id: 36dc5454f1ca12c91d0eac6e5059f554ac5cb352
2020-06-22 03:15:53 -07:00
Stanislau Hlebik
dc84f9741d mononoke: try to compress values if they above cachelib limit
Summary: If a value is above cachelib limit let's try to compress it.

Reviewed By: krallin

Differential Revision: D22139644

fbshipit-source-id: 9eb366e8ec94fe66529d27892a988b035989332a
2020-06-20 01:05:54 -07:00
Alex Hornby
b21dca37b0 mononoke: add blobstore link trait
Summary: Add blobstore link trait so we can use hardlink style links in fileblob and memblob for testing and later sqlblob et al for prod.

Reviewed By: StanislavGlebik

Differential Revision: D21935647

fbshipit-source-id: f76eaca26b6b226c77d6e39e9c64e02b4145b614
2020-06-17 02:35:03 -07:00
Alex Hornby
2b115684af mononoke: switch blobstore imports to use futures_old naming
Summary: Switch blobstore imports to use futures_old naming in preparation for using new futures in BlobstoreWithLink (and later BlobstoreWithEnumeration) traits.

Reviewed By: krallin

Differential Revision: D21972842

fbshipit-source-id: 6022c98e7b7254f7c7beb46dc1c7f83609810853
2020-06-16 04:11:44 -07:00
Harvey Hunt
0ee0131454 mononoke: Remove hit and miss metrics from CountedBlobstore
Summary:
CountedBlobstore is a Blobstore that wraps another blobstore in order
to report metrics about it, such as the number of gets or errors. It's commonly
used to wrap a CacheBlob blobstore, which itself is a caching wrapper over an
inner blobstore.

CountedBlobstore exposes metrics that are supposed to track the number of hits
or misses when fetching blobs. However, these metrics don't make sense as the
CountedBlobstore has no view into cache activity. These metrics actually report
the number of requests and the number of missing blobs rather than hits and
misses.

Remove these misleading counters.

Reviewed By: krallin

Differential Revision: D21640923

fbshipit-source-id: 07b9fc9864c70991415c2b84f35d631b702c17d1
2020-05-21 03:19:11 -07:00
Mistral Orhan Jean-Pierre Contrastin
5fe820dd06 Expose ctime from Blobstore::get() in mononoke
Summary:
- Change get return value for `Blobstore` from `BlobstoreBytes` to `BlobstoreGetData` which include `ctime` metadata
- Update the call sites and tests broken due to this change
- Change `ScrubHandler::on_repair` to accept metadata and log ctime
- `Fileblob` and `Manifoldblob` attach the ctime metadata
- Tests for fileblob in `mononoke:blobstore-test` and integration test `test-walker-scrub-blobstore.t`
- Make cachelib based caching use `BlobstoreGetData`

Reviewed By: ahornby

Differential Revision: D21094023

fbshipit-source-id: dc597e888eac2098c0e50d06e80ee180b4f3e069
2020-05-06 00:55:07 -07:00
Thomas Orozco
9ac8e0505b mononoke: update various error enums to use #[source]
Summary:
We have a number of error enums that wrap an existing errors, but fail to
register the underlying error as a `#[source]`. This results in truncated
context chains when we print the error. This fixes that. It also removes a
bunch of manual `From` implementation that can be provided by thiserror's
`#[from]`.

This also required updating the `Display` implementation for those errors. I've
opted for not printing the underlying error, since the context chain will
include it. This does mean that if we print one of those errors without the
context chain (i.e. `{}` as opposed to `{:#}` or `{:?}`), then we'll lose out a
bit of context. That said, this should be OK, as we really shouldn't ever being
do this, because we'd be missing the rest of the chain anyways.

Reviewed By: StanislavGlebik

Differential Revision: D21399490

fbshipit-source-id: a970a7ef0a9404e51ea3b59d783ceb7bf33f7328
2020-05-05 05:44:52 -07:00
Stanislau Hlebik
e10e5349e7 mononoke: remove boilerplate with auto_impl
Reviewed By: krallin

Differential Revision: D21207457

fbshipit-source-id: 32a9afe4eb4214ffa88d7ef756112e7e9033337e
2020-04-24 04:09:30 -07:00
Stanislau Hlebik
d2412fbcfe mononoke: move StoreLoadable and add LodableError
Summary:
This is a small refactoring that does two things:
1) Move StoreLoadable into the Blobstore crate. This might be a bit
controversial since StoreLoadable doesn't have anything to do with blobstore.
But I put it there for a few reasons:
* In the next diffs I want to use StoreLoadable in mononoke_types. However I
can't create dependency from `mononoke_types` crate to `manifest` crate because
`manifest` depends on `mononoke_types`
* `manifest` crate doesn't look like a good place for this struct either
* I didn't find a better place for it - don't want to put it in crates like
`common`, and it creating a separate crate just for this trait looks like an
overkill.

2) Changes error type to LoadableError to match Loadable trait. This add one
FIXME for git tree which doesn't differentiate between these errors.

Reviewed By: krallin

Differential Revision: D20561442

fbshipit-source-id: a0dca0ff8daa5d7fa166f4527c2f7cc7f541a4c0
2020-03-23 00:43:44 -07:00
Lukas Piatkowski
72c1a6c0d4 common/rust: remove unused asyncmemo from the codebase
Reviewed By: aslpavel

Differential Revision: D19948742

fbshipit-source-id: 43ecb4885f4385adb7598bdec875171e69bb2ffa
2020-02-19 05:15:17 -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
Lukasz Piatkowski
e8d62b64d5 mononoke: move the codebase under eden/ directory
fbshipit-source-id: 43a0252cb3ec42aa365f20d1b6faa4d24d74c9b8
2020-02-06 13:46:04 +01:00