Commit Graph

460 Commits

Author SHA1 Message Date
Stanislau Hlebik
2edda84233 mononoke: add backsync_many call to backsyncer
Summary:
This new method syncs all log entries until the the certain log entry.

This function will first read from replica, however if it can't find new entries in the replica it will try to fetch from master.

Reviewed By: krallin

Differential Revision: D17929152

fbshipit-source-id: 77fa0ef28ae3c530d427e079079d2d4d6b6c6b62
2019-10-16 23:34:58 -07:00
Daniel Grzegorzewski
15d0c5a8e8 Printing statistics in csv format
Summary: Print calculated statistics in csv format, so we can generate csv file by redirecting output to some file. As a TODO we may want to add new fields to RepoStatistics struct, refactor code and create csv file using e.g. serde deserialization.

Reviewed By: krallin

Differential Revision: D17907650

fbshipit-source-id: 0e7f0af522cc72c067d59431039e44998d5dd354
2019-10-15 05:54:30 -07:00
Alex Hornby
b8c9f661ad mononoke: pass a factory future to blobrepo for (sqlfactory, blobstore)
Summary: pass a factory future to blobrepo for (sqlfactory, blobstore)

Reviewed By: krallin

Differential Revision: D17786308

fbshipit-source-id: 472f3461210352e2ce56418328fec944c478071b
2019-10-15 03:36:20 -07:00
Mark Thomas
83917d3ebc backfill_derived_data: allow access to the unredacted repo
Summary:
Some backfill types, e.g. fsnodes, require access to the unredacted repo in
order to correctly compute their values.  For example, fsnodes require the
content hashes of the redacted blobs to correctly form the fnsode graph.
This kind of access is ok, as we are only deriving summary information
(hashes), and won't reveal the content of the redacted blob.

Add the ability for `backfill_derive_data` to access the unredacted repo,
limited only to whitelisted derived data types.

Reviewed By: ikostia

Differential Revision: D17877191

fbshipit-source-id: 6c9b1dfdfb2e6f431815ddf3de60029fbb180454
2019-10-14 07:18:44 -07:00
Stanislau Hlebik
c60df79c49 mononoke: unify logview initialization
Summary:
Follow up from D17765160. Let's unify logview initialization in one place.
This will let us log to logview from all binaries we have in mononoke

Note - the diff touches a lot of files, but main changes are in
cmdlib/src/args.rs, apiserver/src/main.rs and server/src/main.rs.

Reviewed By: krallin

Differential Revision: D17895480

fbshipit-source-id: c922adfb385461ff168bd788e42ea1b88891f7cf
2019-10-13 00:46:36 -07:00
Andres Suarez
cf36295fa4 Yearless license header
Summary:
This diff updates all license headers to use the new text and style.
Also, a few internal files were missing the header, but now they have it.
`fbcode/common/rust/netstring/` had the internal header, but now it has
GPLV2PLUS - since that goes to Mononoke's Github too.

Differential Revision: D17881539

fbshipit-source-id: b70d2ee41d2019fc7c2fe458627f0f7c01978186
2019-10-11 13:52:34 -07:00
Daniel Grzegorzewski
12598d9d94 Calculate statistics for old changesets in statistics collector tool
Summary: Added option to calculate statistics for old changesets saved in file. Currently it prints calculated statistics.

Reviewed By: StanislavGlebik

Differential Revision: D17811305

fbshipit-source-id: 162946941b9e153ffedc1fc28539eebacab77132
2019-10-11 06:20:10 -07:00
Thomas Orozco
ba6225dd9f mononoke/blobstore_healer: remove deprecated db-regions flags
Reviewed By: StanislavGlebik

Differential Revision: D17876565

fbshipit-source-id: d811e2951d31dac0798a912becbc995b0752000f
2019-10-11 03:41:07 -07:00
Thomas Orozco
1e872f48b5 mononoke/blobstore_healer: remove hardcoded list of regions
Summary:
This updates the blobstore healer to avoid using a hardcoded list of regions.

Facebook

I'll remove this from the TW spec once this makes it through Conveyor.

This Configerator file is referenced in the DBA region turnup instructions: https://our.intern.facebook.com/intern/wiki/MySQL/DBaaS/Internal/Regional_Turnup_Steps/#configs (they update `configerator/raw_configs/myrouter/routing_v3.jsonc`, which includes this file)

Reviewed By: StanislavGlebik

Differential Revision: D17787579

fbshipit-source-id: ec9128202679ce0dbe18d77fb84c3fbf6186cd19
2019-10-07 07:34:10 -07:00
Thomas Orozco
6c29aad4a0 mononoke/blobstore_healer: handle missing regions gracefully
Summary:
There's a few things broken with common/rust/sql and the blobstore healer's handling of replication lag right now:

- If Seconds_Behind_Master isn't an int (it'll be NULL if replications is paused), it just panics.
- If it's talking to a server that it expected to be a replica but is a master, it returns None for the replication lag, but 0 would be more appropriate.
- If a region no longer has a replica, it errors out.

This diff fixes that:

- If replication is paused, we return None for lag.
- If we're talking to a master, we return 0.
- If a region has no replica, we ignore it.

Reviewed By: StanislavGlebik

Differential Revision: D17787580

fbshipit-source-id: 9e5e7682456870b88910afec12e1c409fd8c5ba6
2019-10-07 07:34:10 -07:00
Kostia Balytskyi
b5917c96ea mononoke: use csid_resolve in places where we used resolve_hg_rev
Summary:
This is better from the usability perspective, as it can resolve hg changeset, bonsai changeset and a
bookmark.

However, this also means that when the user does provide an Hg commit hash and we need an hg commit hash, we are doing one more database query (`get_hg_from_bonsai_changeset`). This is a little bad, but all of the use-cases I changed here are from the admin tool, so we should be fine.

Reviewed By: StanislavGlebik

Differential Revision: D17740448

fbshipit-source-id: 7c1620979e25631f1a4e44d6310668fe634b2075
2019-10-05 05:48:43 -07:00
Daniel Grzegorzewski
469d115e01 Skip fetching file content for big files in statistics_collector tool
Summary: Skip calculating number of lines for files with size greater than 10MB

Reviewed By: krallin

Differential Revision: D17710287

fbshipit-source-id: 025e94b66539b471e5e48aee0ec7e61808cb0bd6
2019-10-02 06:22:57 -07:00
Stanislau Hlebik
d5d4d20f64 mononoke: fix parent order in blobimport
Summary:
Attached tasks have more details, but in short - if a commit has two parents
then the order of them in mercurial can change but the commit hash won't
change. In Mononoke it's different - change of parent order changes the hash.

This option allows us to fix parent order if needed

Reviewed By: krallin

Differential Revision: D17683807

fbshipit-source-id: 23549e55369b625ea5d597bc336b465373cbbc74
2019-10-01 15:18:32 -07:00
Daniel Grzegorzewski
1fadbb3013 Added STATS counter to statistics_collector tool
Summary: Added STATS counter to stats tool, at the beginning one counter: calculated_changesets

Reviewed By: HarveyHunt

Differential Revision: D17685882

fbshipit-source-id: 3fbd6ea72cfa4f4ee7f39da623a4adfd85587b5b
2019-10-01 09:46:51 -07:00
Daniel Grzegorzewski
95ed50db45 Moved info logging to log_statistics function
Summary: print_statistics and log_statistics were used in the same places in code.

Reviewed By: StanislavGlebik

Differential Revision: D17665790

fbshipit-source-id: 5d41f1b9d77edbe12db25f109a8bb171c8072fb4
2019-09-30 07:21:26 -07:00
Daniel Grzegorzewski
19331de1c1 Set time of changeset creation in statistics_collector samples saved in Scuba
Summary: Set time when changeset was created instead of current time (default time) in samples that are saved in Scuba

Reviewed By: StanislavGlebik

Differential Revision: D17629069

fbshipit-source-id: a4c34f38eff520b96f7e8a85445ee2255c220941
2019-09-30 06:31:45 -07:00
Daniel Grzegorzewski
bf09fb7f65 Added HgChangesetId field to statistics_collector
Summary: Added hg_cs_id field to RepoStatistics struct + logging changeset_hash to samples in Scuba.

Reviewed By: StanislavGlebik

Differential Revision: D17626381

fbshipit-source-id: 97c91543bcfb15a50e9c6630f3dd441b58264894
2019-09-30 02:56:34 -07:00
Andres Suarez
5f19c31135 Enable text linter for toml files
Reviewed By: mzlee

Differential Revision: D17638063

fbshipit-source-id: 9ee13ab9ac2f2202d33028c34922234d51d5dd08
2019-09-27 16:21:43 -07:00
Daniel Grzegorzewski
aef2f4d6d1 Add info logging in statistics_collector tool
Summary: Logging basic info about statistics_collector tool.

Reviewed By: StanislavGlebik

Differential Revision: D17605520

fbshipit-source-id: 1b44bcaa0fb5dd2ce4f54a5a02d49979f0e91e2f
2019-09-27 02:22:45 -07:00
David Tolnay
1cd333be79 rust/thrift: Rename rust_thrift runtime library to fbthrift
Summary:
As suggested by yfeldblum in https://our.intern.facebook.com/intern/diff/D17544447/?transaction_id=2964022370277861.

> the `rust_` bit seems superfluous; the `_thrift` bit opens the door for confusion with apache thrift. Any issue using a module name like `fbthrift`?

 ---

```
$ fastmod '\brust_thrift\b' fbthrift -d ~/fbcode -e rs,toml
$ fastmod '\brust_thrift\b' fbthrift -d ~/fbcode -g '**/TARGETS'
$ hg revert experimental
$ arc lint -a
```

Reviewed By: bolinfest

Differential Revision: D17611123

fbshipit-source-id: b621a422480b00eb2e339ff7542cc66c3ca5b8ec
2019-09-26 20:23:47 -07:00
Simon Farnsworth
e65a44a8c7 Add a quick query tool for the commit sync remapping database
Summary: This is the bare minimum to ask the remapping table for any values it has. Combined with other admin tool commands, you can use this to track down a synced commit.

Reviewed By: StanislavGlebik

Differential Revision: D17554261

fbshipit-source-id: f5f967a55182b614b68b5a8c1421401921c9a268
2019-09-25 09:25:46 -07:00
Daniel Grzegorzewski
2e6c46e7c9 Save statistics from statistics_collector to Scuba
Summary: Modified statistics_collector tool that now it saves statistics to Scuba

Reviewed By: HarveyHunt

Differential Revision: D17570918

fbshipit-source-id: b22094dcc915bc9ba9cb76c09f73e9590c65e641
2019-09-25 07:58:37 -07:00
Mark Thomas
3995bf9927 backfill_derived_data: add fsnodes
Summary: Add `fsnodes` as a kind of derived data that can be backfilled.

Reviewed By: krallin

Differential Revision: D17549835

fbshipit-source-id: 14d7540567c0bd0eae4f53944a5c4c19e5902105
2019-09-25 05:19:55 -07:00
Simon Farnsworth
2e4fe33290 Add hgchangesets to backfill_derived_data
Summary:
This is currently a bit hacky, as bonsai->hg conversion does not work like other derived data, but it does the job.

We want to be able to dump Bonsai changesets from synced commits onto a bookmark, and have a tailer fill in Mercurial changesets behind us. This code does that via the existing mechanism for creating changesets

Reviewed By: StanislavGlebik

Differential Revision: D17552077

fbshipit-source-id: d5b13f884332e57e7d8c55256ccb4ea918fe4921
2019-09-25 01:00:24 -07:00
Andres Suarez
239e008c73 mononoke: fix broken toml fixture
Reviewed By: krallin

Differential Revision: D17557847

fbshipit-source-id: 7c003d8075f394d07333f8294addc5235ab95305
2019-09-24 14:56:23 -07:00
Daniel Grzegorzewski
191194f60f Modified statistics_collector tool to calculate statistics in new commits
Summary: I modified tool that now it calculates statistics starting from current master (or other provided by us bookmark), then it waits for new commits and updates statistics.

Reviewed By: StanislavGlebik

Differential Revision: D17502571

fbshipit-source-id: c98b06529cc7fc6ab9ee358b87dc9fa161546da5
2019-09-24 10:35:52 -07:00
Thomas Orozco
2ac2e95d08 mononoke/admin: allow showing envelopes for filenodes
Summary: This is convenient to get the content ID for a file at a given path.

Reviewed By: HarveyHunt

Differential Revision: D17498393

fbshipit-source-id: f40706b9289ca77e99cb3d7070b396ee134f79c3
2019-09-20 04:08:53 -07:00
Kostia Balytskyi
a3a2b0200d mononoke: extract non-arg-related things into cmdlib::helpers from cmdlib::args
Summary: What the title says.

Reviewed By: farnz

Differential Revision: D17475432

fbshipit-source-id: b117ab37df6c1965c20da6154cd32d6c68dd9882
2019-09-19 06:56:39 -07:00
Daniel Grzegorzewski
8515e6f741 Modified statistics_collector tool to calculate total number of lines in source files
Summary: Modified code to calculate next statistic: total number of lines in source files.

Reviewed By: krallin

Differential Revision: D17395757

fbshipit-source-id: f19ee888b9836b42e755acee2d4c76e1fef6265e
2019-09-17 04:56:21 -07:00
Mark Thomas
aa6ad17e93 unodes: move crate to derived_data
Summary:
Collect together all derived data in the `derived_data` directory.  This moves
the `unodes` derivation crate.

Reviewed By: StanislavGlebik

Differential Revision: D17314208

fbshipit-source-id: f1b575446192cb9799e443efb1cb863b80ef72d6
2019-09-17 02:49:41 -07:00
David Tolnay
713973975d Replace *fbinit::FACEBOOK with #[fbinit::main]
Summary:
This diff moves initFacebook calls that used to happen just before FFI calls to instead happen at the beginning of main.

The basic assumption of initFacebook is that it happens at the beginning of main before there are additional threads. It must be allowed to modify process-global state like env vars or gflags without the possibility of a data race from other code concurrently reading those things. As such, the previous approach of calling initFacebook through `*fbinit::FACEBOOK` near FFI calls was prone to race conditions.

The new approach is based on attribute macros added in D17245802.

 ---

The primary remaining situations that still require `*fbinit::FACEBOOK` are when we don't directly control the function arguments surrounding the call to C++, such as in lazy_static:

    lazy_static! {
        static ref S: Ty = {
            let _ = *fbinit::FACEBOOK;
            /* call C++ */
        };
    }

and quickcheck:

    quickcheck! {
        fn f(/* args that impl Arbitrary */) {
            let _ = *fbinit::FACEBOOK;
            /* call C++ */
        }
    }

I will revisit these in a separate diff. They are a small fraction of total uses of fbinit.

Reviewed By: Imxset21

Differential Revision: D17328504

fbshipit-source-id: f80edb763e7f42b3216552dd32f1ea0e6cc8fd12
2019-09-13 20:17:29 -07:00
Pavel Aslanov
0ca9f6e068 single subcommand for debugging purposes
Summary: `single` subcommand which regenerates specified derived data for provided changeset. This is useful for debugging purposes

Reviewed By: StanislavGlebik

Differential Revision: D17318968

fbshipit-source-id: 3d3a551991b0628a05335addedd7d5b315fd45d2
2019-09-13 05:13:34 -07:00
Daniel Grzegorzewski
fe39645958 Modified statistics_collector tool to calculate total file size.
Summary: I modified statistics_collector tool, so now it calculates both number of files, and total file size in repo.

Reviewed By: krallin

Differential Revision: D17342512

fbshipit-source-id: 94217d8b61c2a7350f1793a2ef33f84d600bbb54
2019-09-13 05:08:23 -07:00
Stanislau Hlebik
60d9fffda0 mononoke: make skiplist creation faster
Summary:
Previously rebuilding skiplist required fetching all the commits from mysql,
and then rebuilding the index from scratch. That was quite slow (> 16 mins to
finish). Instead let's try to read the key to check if it has the data already
and prepopulate skiplist with it.

Reviewed By: krallin

Differential Revision: D17343950

fbshipit-source-id: e8a446b94af61dbbd224d853f7dd8dd41510549d
2019-09-12 07:54:53 -07:00
Thomas Orozco
53bf2886cc mononoke: connect stdlog and slog
Summary:
This wires up the stdlog crate with our slog output. The upshot is that we can
now run binaries with `RUST_LOG` set and expect it to work.

This is nice because many crates use stdlog (e.g.  Tokio, Hyper), so this is
convenient to get access to their logging.  For example, if you run with
`RUST_LOG=gotham=info,hyper=debug`, then you get debug logs from Hyper and info
logs from Gotham.

The way this works is by registering a stdlog logger that uses the env_logger's
filter (the one that "invented" `RUST_LOG`) to filter logs, and routes them to
slog if they pass. Note that the slog Logger used there doesn't do any
filtering, since we already do it before sending logs there.

One thing to keep in mind is that we should only register the stdlog global
logger once. I've renamed `get_logger` to `init_logging` to make this clearer.
This behavior is similar to what we do with `init_cachelib`. I've updated
callsites accordingly.

Note that we explicitly tell the stdlog framework to ignore anything that we
won't consider for logging. If you don't set `RUST_LOG`, then the default
logging level is `Error`, which means that anything below error that is sent to
stdlog won't even get to out filtering logic (the stdlog macros for logging
check for the global level before actually logging), so this is cheap unless
you do set `RUST_LOG`.

As part of this, I've also updated all our binaries (and therefore, tests) to
use glog for logging. We had been meaning to do this, and it was convenient to
do it here because the other logger factory we were using didn't make it easy
to get a Drain without putting it a Logger.

Reviewed By: ahornby

Differential Revision: D17314200

fbshipit-source-id: 19b5e8edc3bbe7ba02ccec4f1852dc3587373fff
2019-09-12 04:13:11 -07:00
Stanislau Hlebik
6cf20fc88f mononoke: prefetch commits in backfill derive data
Summary:
Fetching commits takes a long time. I've added a subcommand that saves them to
a file, and "backfill" command can later read it. Note that another option
would be to add indices to the db to make commit fetching faster, however this diff
was simpler to do.

I also fixed a panic which was because of division by zero.

Reviewed By: aslpavel

Differential Revision: D17341640

fbshipit-source-id: b0335ebf8799cd48884c19fa8a0ee8023eb751af
2019-09-12 02:25:20 -07:00
David Tolnay
577a31b2a1 Delete extern crate lines
Summary:
`extern crate` is usually no longer needed in 2018 edition of Rust. This diff removes `extern crate` lines from fbcode where possible, replacing #[macro_use] with individual import of macros.

Before:

```
#[macro_use]
extern crate futures_ext;
extern crate serde_json;
```

After:

```
use futures_ext::try_boxfuture;
```

Reviewed By: Imxset21

Differential Revision: D17313537

fbshipit-source-id: 70462a2c161375017b77fa44aba166884ad2fdc3
2019-09-11 22:01:58 -07:00
Daniel Grzegorzewski
ab56c2051e Binary that counts number of files in the repo
Summary: First version of binary that counts number of files in specific repo and print it.

Reviewed By: StanislavGlebik

Differential Revision: D17285812

fbshipit-source-id: 30bc9e2c11ee75fcfb8d94610bd4e320a56dafc7
2019-09-11 03:21:53 -07:00
Kostia Balytskyi
a878f7ed13 mononoke: make blobimport capable of prefixing bookmarks
Summary:
We need this for `megarepo_test` blobimport, which will prefix `fbsource` and
`ovrsource` bookmarks.

Reviewed By: krallin

Differential Revision: D17286275

fbshipit-source-id: 40bb3f97b0a06dcd636f891d9b32c7ef9b55a0fc
2019-09-11 03:19:38 -07:00
David Tolnay
ecc30ffe8a Delete lines of the form "use [a-z_]+;"
Summary: I think these are left over from pre-2018 code where they may have been necessary. In 2018 edition, import paths in `use` always begin with a crate name or `crate`/`super`/`self`, so `use $ident;` always refers to a crate. Since extern crates are always in scope in every module, `use $ident` does nothing.

Reviewed By: Imxset21

Differential Revision: D17290473

fbshipit-source-id: 23d86e5d0dcd5c2d4e53c7a36b4267101dd4b45c
2019-09-10 15:06:19 -07:00
Pavel Aslanov
4d22d9f260 add skip and regenerate logic to backfill subcommand
Summary:
Add support for:
- regeneration of already backfilled derived data.
- skipping changesets (useful when we want to resume interrupted backfill)

Reviewed By: StanislavGlebik

Differential Revision: D17282548

fbshipit-source-id: 1e6e9ac5e3ac834b7d942431a007a52e0ddd75b8
2019-09-10 08:22:18 -07:00
Kostia Balytskyi
800824a2bd mononoke: add config reading logic for commit sync configs
Summary:
Commit sync will operate based on the following idea:
- there's one "large" and potentially many "small" repos
- there are two possible sync directions: large-to-small and small-to-large
- when syncing a small repo into a large repo, it is allowed to change paths
  of each individual file, but not to drop files
- large repo prepends a predefined prefix to every bookmark name from the small repo, except for the bookmarks, specified in `common_pushrebase_bookmarks` list, which refers to the bookmarks that can be advanced by any small repo

Reviewed By: krallin

Differential Revision: D17258451

fbshipit-source-id: 6cdaccd0374250f6bbdcbc9a280da89ccd7dff97
2019-09-10 07:23:15 -07:00
Pavel Aslanov
2f8314e204 actually allow to used fastlog derived data type
Summary: I've forgotten to amend before lending changes

Reviewed By: StanislavGlebik

Differential Revision: D17261853

fbshipit-source-id: 99a050a06348dd4fcc2b45e6243c1e56369bb0e9
2019-09-10 02:44:05 -07:00
Pavel Aslanov
740d4276aa add fastlog support
Summary: Extend `backfill_derived_data` utility to support `RootFastlog` derived data type.

Reviewed By: krallin

Differential Revision: D17258729

fbshipit-source-id: e2e1fc2ad067fb5f7b597f54727ade89a4721cb4
2019-09-09 07:48:08 -07:00
Pavel Aslanov
3284fb896c added ability to regenerate selected unode
Summary: Admin subcommand to force unode regeneration for specified commit. This is useful for debugging unodes generation perforamance

Reviewed By: farnz

Differential Revision: D17225913

fbshipit-source-id: 0ec700f670edd01e4c7659fe437e91c2f2c43497
2019-09-09 03:59:50 -07:00
Thomas Orozco
73f713ca70 mononoke: remove manifold / MySQL flags + safe_writes
Summary: None of these do anything.

Reviewed By: StanislavGlebik

Differential Revision: D16963565

fbshipit-source-id: bb0dd344daf151dd1d5c45392c43b014d2b17a07
2019-09-06 07:17:45 -07:00
Thomas Orozco
a85c5a80b4 mononoke/benchmark_filestore: support delay, debug, randomize
Summary:
This make it easier to benchmark things, in particular Manifold CDN
performance.

Reviewed By: StanislavGlebik

Differential Revision: D16963422

fbshipit-source-id: c110bd620fec6cfb25aa45cffdd059024495ff32
2019-09-06 07:17:45 -07:00
Thomas Orozco
a0e7d5d1ac mononoke/benchmark_filestore: use constants for arg names
Summary:
This avoids typos when accessing arguments, and thus avoids panics when we
unwrap arguments that don't exist.

Reviewed By: StanislavGlebik

Differential Revision: D16963424

fbshipit-source-id: cf35dfaf026be8842902af3c817301672a8929d2
2019-09-06 07:17:45 -07:00
Alex Hornby
8c46a4cc03 rust/futures-ext: add multiple initial value support to bounded_traversal_stream
Summary: Update bounded_traversal_stream to take IntoIterator of initial values. This allows simultaneous navigation of a graph from multiple roots.

Reviewed By: farnz

Differential Revision: D17163609

fbshipit-source-id: c999e7653cb620c215331ecc46f5a800ced8ef37
2019-09-04 08:31:16 -07:00
Daniel Grzegorzewski
7354e0a60c Change Arc<BlobRepo> to BlobRepo
Reviewed By: StanislavGlebik

Differential Revision: D17162141

fbshipit-source-id: fb7466e0aaed4c2494ebeaeb49b38c15f521745d
2019-09-03 06:51:28 -07:00