Commit Graph

1898 Commits

Author SHA1 Message Date
Kostia Balytskyi
b4d35b0dc9 mononoke: modify bookmark update log queries to return homogenous series
Summary:
First and foremost, this is a safe diff to land on its own as this query
is only used by the sync job and only with the `limit=1`. So the things I am
introducing are not changing any existing behavior.

General goal of this diff is to make sure that these queries always return
series of bookmark update log entries where each entry has the same reason
and bookmark. This way it is always safe to merge these entries into a single
combined entry and send this entry to Mercurial servers for replay.

NB: this same can obviously be done by a nested query, but it is a bit more convenient for me to write it this way. It can be changed if people have strong feelings about it, either now or in a separate diff.

Reviewed By: krallin

Differential Revision: D15251977

fbshipit-source-id: 028c085bb7c4c325c1926bf351b985ef1200ef41
2019-05-21 12:25:54 -07:00
Stanislau Hlebik
0fe404988e mononoke: print bundle id to replay
Summary:
Printint id will make it easier to debug sync job problems (for example,
rewiding the latest replayed id counter)

Reviewed By: krallin

Differential Revision: D15322624

fbshipit-source-id: 5c94be9cc0dcced9df51162adb598b6498f1c749
2019-05-21 12:25:54 -07:00
Stanislau Hlebik
ab66fd6b19 mononoke: connect to xdb directly if myrouter port is not specified
Summary: This functionality was accidentally deleted in D15065421

Reviewed By: jsgf

Differential Revision: D15323413

fbshipit-source-id: 79a8e5d8fe36ba6ed0b9856f8eb26da858f25c69
2019-05-21 12:25:53 -07:00
Stanislau Hlebik
d7d95eeb5d mononoke: do not panic if stream has ended
Summary:
Short-running binaries like blobimport panic if it exists. Let's not panic if
it finished successfully.

Reviewed By: krallin

Differential Revision: D15322259

fbshipit-source-id: a71935e8a0bf0316400e60d39fda7281c7507913
2019-05-21 12:25:53 -07:00
Thomas Orozco
4e15b7b538 mononoke: fix broken build (racing diffs)
Summary:
Looks like D15166925 conflicted with D15199637, which has broken our builds. This fixes that.

#quickstamp

Reviewed By: StanislavGlebik

Differential Revision: D15321997

fbshipit-source-id: 35c39a51c183e6153e6214f950262f83050b4bf5
2019-05-21 12:25:53 -07:00
Pavel Aslanov
78ff3b9909 improve performance of hg manifest generation
Summary: Improves performance of `.save` operation of in memory manifest by saving dependencies in parallel

Reviewed By: farnz

Differential Revision: D15166924

fbshipit-source-id: 4eeff76a7ff065b88610c64ae08a646a1dfa27b2
2019-05-21 12:25:52 -07:00
Pavel Aslanov
8198e87793 add reporducability under load test for memory_manifest
Summary: add reporducability under load test for memory_manifest

Reviewed By: farnz

Differential Revision: D15249834

fbshipit-source-id: 515282c6255fb002bc96a228112abd1602a66767
2019-05-21 12:25:52 -07:00
Pavel Aslanov
88ac29f2aa add benchmark for get_hg_from_bonsai_changeset
Summary:
This synthetic benchmark/simulation:
- it creates `BlobRepo` which contains delayed implementation for main components, but also includes all caches enabled, since most of our code heavily depends on caching
- it also includes stack generator which can produce stack of changesets
- this particular benchmark exercises bonsai->hg generation path

Reviewed By: StanislavGlebik

Differential Revision: D15166925

fbshipit-source-id: 8ca7fcf1df1400af6c61616218a84eac655c276f
2019-05-21 12:25:51 -07:00
Pavel Aslanov
c845de3bd8 added bounded_traversal
Summary: `bounded_traversal` traverses implicit asynchronous tree specified by `init` and `unfold` arguments, and it also does backward pass with `fold` operation. All `unfold` and `fold` operations are executed in parallel if they do not depend on each other (not related by ancestor-descendant relation in implicit tree) with amount of concurrency constrained by `scheduled_max`.

Reviewed By: jsgf

Differential Revision: D15197796

fbshipit-source-id: 1145497f5cb1c0effee47a4d27698bcf9d88f840
2019-05-21 12:25:51 -07:00
Durham Goode
aa8712a082 treemanifest: add flatcompat mode for test migration
Summary:
We want to migrate the tests to run using treemanifest. As part of
that, we want to first transition to using treemanifest without actually
changing the hash, so we can check that the tests still work first, then update
the hashes second.

This diff adds the flatcompat mode and enables it by default. A future diff will
start enabling treemanifest for existing tests.

Reviewed By: quark-zju

Differential Revision: D15030252

fbshipit-source-id: 06c82be749282d62f1d9cfb43246695c427f8165
2019-05-21 12:25:50 -07:00
Thomas Orozco
1e40b755dc mononoke: cache in CachingChangesets::get_many
Summary: This introduces support for caching for get_many in CachingChangesets.

Reviewed By: StanislavGlebik

Differential Revision: D15199637

fbshipit-source-id: 031bf9609c4d4803ef931f1a5200f1343706b26b
2019-05-21 12:25:50 -07:00
Thomas Orozco
a70681f359 caching_ext: expose cache hits / misses
Summary:
This updates caching_ext to record cache hit and miss stats. This makes
it easier to write tests that exercise this caching.

As part of this, I refactored the CachelibHandler and MemcacheHandler mocks to
use a shared MockStore implementation.

Reviewed By: StanislavGlebik

Differential Revision: D15220647

fbshipit-source-id: b0f70b9780f577226664ebf6760b5fc93d733cd3
2019-05-21 12:25:49 -07:00
Arun Kulshreshtha
2c814d935c types: rename api structs
Summary: Given that the on-the-wire representation of file and tree data is essentially the same, we can reuse our existing structs for file fetching for tree fetching. As such, we should rename these structs to make it clear that they are not just for file data. (This also involves updating some comments/variable names to make sure everything is consistent.)

Reviewed By: singhsrb

Differential Revision: D15286690

fbshipit-source-id: 8c7fa4392057e90a9f19beb17b0bbcbf04b7e8e7
2019-05-21 12:25:49 -07:00
Stanislau Hlebik
058d2a4eed mononoke: integration test for multiplexed blobstore
Summary: Can be used to verify multiplexer

Reviewed By: aslpavel

Differential Revision: D15264133

fbshipit-source-id: cb9044b6b51e099b61e751925367c71fd506332e
2019-05-21 12:25:48 -07:00
Jeremy Fitzhardinge
c93f17d1ef mononoke/repoconfig: make sure "expect fail" tests are failing for the right reason
Summary:
Some tests were failing because their syntax wasn't updated, not
because of the thing they're testing for. Add a check for the error string as
well.

Reviewed By: StanislavGlebik

Differential Revision: D15280521

fbshipit-source-id: 81402fae6854811a8e386ee4d7f37139f0489035
2019-05-21 12:25:48 -07:00
Stanislau Hlebik
324ffbf862 mononoke: allow local blobstore sync queue
Summary: useful for tests

Reviewed By: HarveyHunt

Differential Revision: D15263210

fbshipit-source-id: 8e78e437dca4fd04b3e233bfd03af9f971508a1d
2019-05-21 12:25:47 -07:00
Arun Kulshreshtha
2a0492400f types: don't re-export structs from api module
Summary: As we add more functionality to the Eden API, we will have a lot more request structs. These structs are only used by the HTTP data fetching code, and should not be used by actual business logic. As such, while these types need to be public (so that both Mononoke and Mercurial can use them), they should not be re-exported at the top level.

Reviewed By: quark-zju

Differential Revision: D15268439

fbshipit-source-id: e7d1405d2ac234892baedbf7dbf3e133d187cb45
2019-05-21 12:25:47 -07:00
Thomas Orozco
25d48bbbd6 mononoke: hg-sync-job: gracefully exit even without work
Summary:
Checking for our exit condition after pulling a new piece of work from the buffer is good because it means we exit without doing any of the work we buffered (i.e. we'll exit quickly)

However, that approach does means that a piece of work has to go through the stream all the way to the sync step before we decide to drop it and stop the stream.

If there is not work, this means we might take a while to exit! On paper, this is fine because if there is no work, then it's OK to just take our time to exit ... but it might be a little confusing from an operator perspective.

This patch fixes that problem by checking our exit condiiton after every no-op iteration as well.

 ---

It's worth noting that both checks are indeed required if we want to exit quickly regardless of whether we are very busy or completely idle.

Reviewed By: ikostia

Differential Revision: D15270517

fbshipit-source-id: 06c3b100ccbf69191ac67691a2991086596a15c0
2019-05-21 12:25:46 -07:00
Thomas Orozco
2cf7a2aaf9 mononoke: hg-sync-job: allow for graceful exit
Summary:
This adds support in the hg-sync-job for graceful exits by adding an `--exit-file` parameter. When the file referenced by this parameter exists, the sync job will stop processing new entries.

Note that the sync job will actually exit only once it evaluates the exit condition, i.e. the program will only exit once we get the next entry and decide to stop processing work.

Another way to look at this is that creating the flag file guarantees the sync job will not start any new syncs from that point on, but it doesn't guarantee a timely exit.

That's probably what we want here, but if we also want to guarantee a timely exit, then we can add an additional check for the file existence in `loop_over_log_entries` next to the `loop_forever` check.

 ---

The idea here is to use `touch $THE_FILE` as our exit command in Tupperware to allow for gracefully exiting the process.

Reviewed By: ikostia

Differential Revision: D15263468

fbshipit-source-id: 0a5b04e662e2a4042de9e0c5207f1b1be46d1807
2019-05-21 12:25:46 -07:00
Stanislau Hlebik
3e12f12e2f mononoke: bump filenodes buffer sizes
Summary: It makes pushes faster, especially on non-master regions.

Reviewed By: quark-zju

Differential Revision: D15279259

fbshipit-source-id: c184b68cc8b7509938849cd86bb15ef5d5f33bdd
2019-05-21 12:25:45 -07:00
Stanislau Hlebik
d3e9dce296 RFC mononoke: do batch writes to blobstore sync queue
Summary:
We've hit an issue of slow pushes to Mononoke when a commit modifies a lot of
files (>500 in our case). turned out that the problem was in the fact that
we have only one master write connection open, and each blobstore write
requires a write to mysql because of multiplexed blobstore. Because we have
only one connection open all our mysql writes are serialized, and the push is
taking too much time. It's especially bad in non-master regions.

To mitigate the issue let's add a batching in the blobstore sync queue. When
clients call `blobstore_sync_queue.add(...)` we'll send this new entry via the
channel to a separate task that would send writes in batches. That allows us to
increase throughput significantly.

Reviewed By: jsgf

Differential Revision: D15248288

fbshipit-source-id: 22bab284b0cbe552b4b51bab4027813b4278fd14
2019-05-21 12:25:45 -07:00
Jeremy Fitzhardinge
48fc142093 mononoke/configlint: check locality
Reviewed By: StanislavGlebik

Differential Revision: D15167592

fbshipit-source-id: 474e1864468ec05ad0d974160deff29f099063ff
2019-05-21 12:25:45 -07:00
Jeremy Fitzhardinge
9b54d0f85b mononoke: move storage configuration to a common file
Summary:
This change has two goals:
- Put storage configuration that's common to multiple repos in a common place,
  rather than replicating it in each server.toml
- Allow tools that only operate on the blobstore level - like blobstore healing
  - to be configured directly in terms of the blobstore, rather than indirectly
    by using a representative repo config.

This change makes several changes to repo configuration:
1. There's a separate common/storage.toml which defines named storage
configurations (ie, a combination of a blobstore and metadata DB)
2. server.toml files can also define local storage configurations (mostly
useful for testing)
3. server.toml files now reference which storage they're using with
`storage_config = "name"`.
4. Configuration of multiplex blobstores is now explicit. Previously if a
server.toml defined multiple blobstores, it was assumed that it was a
multiplex. Now storage configuration only accepts a single blobstore config,
but that config can be explicitly a multiplexed blobstore, which has the
sub-blobstores defined within it, in the `components` field. (This is
recursive, so it could be nested, but I'm not sure if this has much value in
practice.)
5. Makes configuration parsing more strict - unknown fields will be treated as
an error rather than ignored. This helps flag problems in refactoring/updating
configs.

I've updated all the configs to the new format, both production and in
integration tests. Please review to make sure I haven't broken anything.

Reviewed By: StanislavGlebik

Differential Revision: D15065423

fbshipit-source-id: b7ce58e46e91877f4e15518c014496fb826fe03c
2019-05-21 12:25:44 -07:00
Jeremy Fitzhardinge
e56d695cec mononoke: use SqlConstructors label for local db names
Summary:
Seems redundant to also require callers to open_ssl to also pass a
(mostly) identical string.

Also make open_ssl special-case filenodes with sharding (though filenodes
aren't currently opened through it).

Reviewed By: StanislavGlebik

Differential Revision: D15157834

fbshipit-source-id: 0df45307f17bdb2c021673b3153606031008bee2
2019-05-21 12:25:44 -07:00
Jeremy Fitzhardinge
046abb21ad mononoke: Migrate to new config structures, leaving config files unchanged
Summary:
This migrates the internal structures representing the repo and storage config,
while retaining the existing config file format.

The `RepoType` type has been replaced by `BlobConfig`, an enum containing all
the config information for all the supported blobstores. In addition there's
the `StorageConfig` type which includes `BlobConfig`, and also
`MetadataDBConfig` for the local or remote SQL database for metadata.

Reviewed By: StanislavGlebik

Differential Revision: D15065421

fbshipit-source-id: 47636074fceb6a7e35524f667376a5bb05bd8612
2019-05-21 12:25:43 -07:00
Jeremy Fitzhardinge
6123587f83 mononoke/repoconfig: use serde defaults rather than Option where possible
Summary:
We don't need Option<bool> or Option<Vec<T>> - in the former case, the
bool is always treated as having a default value if not present, and in the
latter, None is equivalent to Some(vec![]), so just use an empty vector for
absense.

Reviewed By: lukaspiatkowski

Differential Revision: D15051895

fbshipit-source-id: 0ac6f2e6b13357bf6e30dbfa25c7fdebd208e505
2019-05-21 12:25:43 -07:00
Jeremy Fitzhardinge
4074965fdc mononoke/admin: refactor subcommands into their own functions
Summary: main() was getting ungainly

Reviewed By: aslpavel

Differential Revision: D15046903

fbshipit-source-id: 50d1ad8cb44f84f00247dc6435bac7cc8a194ca1
2019-05-21 12:25:42 -07:00
Jeremy Fitzhardinge
0fadbc3571 mononoke/cmdlib: convert to Rust 2018
Reviewed By: StanislavGlebik

Differential Revision: D15046902

fbshipit-source-id: 3340df0691a0144aa3cedcdfbdb52d172e03c816
2019-05-21 12:25:42 -07:00
Mark Thomas
42b95ae213 commitcloud: use component for status and exceptions
Summary:
Set the `component` to `"commitcloud"` for commit cloud statuses and
messages, rather than using custom highlight functions.

Reviewed By: quark-zju

Differential Revision: D15201944

fbshipit-source-id: 7635942a5ca029209711a2b89c32cc5fd677d22f
2019-05-21 12:25:41 -07:00
Stanislau Hlebik
79c14ef818 mononoke: print hg hashes of next log entries to replay
Summary:
Reads current replay counter, and where a bookmark would point to after this
bundle is replayed. That can be useful for debugging

Reviewed By: aslpavel

Differential Revision: D15216378

fbshipit-source-id: fd250e27c2a6d7ee407510561a36b820cc5a1d2b
2019-05-21 12:25:41 -07:00
Lukas Piatkowski
a48e975038 args: use myrouter port to open sql connection if provided
Summary: Fixes the mistakes of D15174538. Apparently this method is used in production utils like the sync job, so it should use myrouter if it is provided.

Reviewed By: ikostia, StanislavGlebik

Differential Revision: D15263742

fbshipit-source-id: a6d4c4a397c627e119b164039a7c00783b63f75f
2019-05-21 12:25:40 -07:00
Thomas Orozco
5e0f2d895a mononoke: allow different tier name for sharded filenodes
Summary:
This updates our configuration to allow using a different tier name for sharded filenodes.

One thing I'd like to call out is that we currently use the DB tier name in the keys generated by `CachingFilenodes`. Updating the tier name will therefore result in us dropping all our caches. Is this acceptable? If not, should we just continue using the old tier name.

Reviewed By: jsgf, StanislavGlebik

Differential Revision: D15243112

fbshipit-source-id: 3bfdcefcc823768f2964b4733e570e9cef57cebc
2019-05-21 12:25:40 -07:00
Stanislau Hlebik
e5cdd1a5da mononoke: do not return boolean in BlobstoreSyncQueue interface
Summary:
In the later diff we'll add batching of BlobstoreSyncQueue writes. It would be
much harder to add the batching if we also have to return this boolean.

And since noboby uses it, let's just remove it

Reviewed By: farnz

Differential Revision: D15248290

fbshipit-source-id: 72c64770c1b023e9de23a5dfccd8b4482302fe96
2019-05-21 12:25:40 -07:00
Pavel Aslanov
b0bfda8819 calculate phases for all commits only once
Summary: Instead of calculating phases of each request, this diff makes sure we are keeping all public phases up to date in database

Reviewed By: StanislavGlebik

Differential Revision: D15045340

fbshipit-source-id: 1ee95eabce4ff517925d5d2b2705e26e68474d92
2019-05-21 12:25:39 -07:00
Thomas Orozco
e6a78271c7 mononoke: fix broken sync job test
Summary: This test appears to have broken after two commits landed at the same time that both affected this test file. This fixes that.

Reviewed By: HarveyHunt

Differential Revision: D15244360

fbshipit-source-id: 6b3c595ecc8500190999948a31ae36cc303caa54
2019-05-21 12:25:39 -07:00
Thomas Orozco
feba12ad67 mononoke: admin: make tests (actually) more deterministic
Summary:
The mononoke admin integration tests can be flaky when there is logging and an error, because those are respectively sent to stdout and stderr, which means they're not ordered relative to one another.

I attempted to fix this with minimal changes in D15146392, but that didn't solve the issue: StanislavGlebik reported that he still ran into a flaky test.

The reason for this is presumably that even though we write to stderr first then to stdout, there's no guarantee that the `.t` test runner will read whetever we output to stderr before it reads what we output to stdout.

I noted in that earlier diff that a more proper fix would be to write errors to stderr so they are indeed ordered relative to logging. That is what this diff does.

For consistency, I updated other fatal outcomes (bad arguments) to also log to stderr.

Reviewed By: StanislavGlebik

Differential Revision: D15181944

fbshipit-source-id: 3ca48870c39f11a7dcc57f1341f25ce61ccae360
2019-05-21 12:25:38 -07:00
Stanislau Hlebik
33481fd628 mononoke: log to scuba if authorization failed
Summary:
Previously it was logged only to stderr, which would make debugging harder.
This diff fixes it

Reviewed By: aslpavel

Differential Revision: D15215522

fbshipit-source-id: ef7e6268bd30aa8a07f307f4c18f3d8f9bf8bee6
2019-05-21 12:25:38 -07:00
Stanislau Hlebik
53478d3ab2 mononoke: apply delta in parallel
Summary:
Note: it usually doesn't matter because delta application usually doesn't need
any fetching from blobstore. But this change is safe and can prevent problems
in future.

Reviewed By: HarveyHunt

Differential Revision: D15241499

fbshipit-source-id: 43fbfd495f0f795b90ef343ac1055d16cdda129c
2019-05-21 12:25:37 -07:00
Harvey Hunt
2c427b6eb7 mononoke: Print queue size from the sync job
Summary: As above

Reviewed By: krallin

Differential Revision: D15228366

fbshipit-source-id: 6c01347767a788bdad6cd912abe4429f7fcff8e8
2019-05-21 12:25:37 -07:00
Kostia Balytskyi
2b647034f3 mononoke: make sync job print hg server names into logs
Summary:
This will help us understand which servers behave poorly and whether there's
any clustering.

Reviewed By: StanislavGlebik

Differential Revision: D15229101

fbshipit-source-id: 1aae9196702ed6fb791b5265c3bdfe90e7e24ae4
2019-05-21 12:25:36 -07:00
Kostia Balytskyi
5c78f96e84 mononoke: add a test for bookmark deletion sync
Summary: We noticed that it does not work during the rollout. Let's add a test for it.

Reviewed By: StanislavGlebik

Differential Revision: D15226353

fbshipit-source-id: bc97ecd3336561b52919c65ff5625d80e29f9a13
2019-05-21 12:25:36 -07:00
Stanislau Hlebik
493fbc9557 mononoke: remove runhook
Summary:
1) I don't think anybody uses it
2) Hook tailer has the same functionality

Reviewed By: farnz

Differential Revision: D15216418

fbshipit-source-id: 698fc7d998475fe77ff7bf1ac55068ee75a34acc
2019-05-21 12:25:35 -07:00
Lukas Piatkowski
a7d5f76635 mononoke: using raw connection to xdb when myrouter_port is not provided
Summary:
In the case of mononoke's admin tool it's annoying for users to be required to run myrouter in the background and provide myrouter port to every command.
Thanks to this change it is no longer necessary to run admin commands through myrouter - the tool will simply use a direct connection to XDB using the sql crate.

It is important to note that the raw XDB connection via sql crate doesn't have connection pooling and doesn't handle XDB failover so it is crucial that it is never used for long-lived or request heavy use cases like running mononoke server or blobimport

Reviewed By: jsgf

Differential Revision: D15174538

fbshipit-source-id: 299d3d7941ae6aec31961149f926c2a4965ed970
2019-05-21 12:25:35 -07:00
Stanislau Hlebik
f0f09b2d39 mononoke: add deny_unknown_fields
Reviewed By: jsgf

Differential Revision: D15214954

fbshipit-source-id: 35a41329e6276c529c517321e05eda6654a973bd
2019-05-21 12:25:34 -07:00
Jeremy Fitzhardinge
4b35684cb7 mononoke/cmdlib: make get_repo_id return a proper error
Reviewed By: lukaspiatkowski

Differential Revision: D15046901

fbshipit-source-id: 603b4bc66e199e0ae12d000b6d7803b7e4bb72cb
2019-05-21 12:25:34 -07:00
Jeremy Fitzhardinge
207e6cacaa mononoke/repoconfig: use fs::read to read files
Summary: Use the existing library function to read a file into a `Vec<u8>`.

Reviewed By: aslpavel

Differential Revision: D15051894

fbshipit-source-id: 853b31450556c0a2e74a09fa06e7814ac68b1052
2019-05-21 12:25:33 -07:00
Pavel Aslanov
fcc83b5e93 remove all extern create statements
Summary: remove all `extern create` statements from `futures-ext` crate

Reviewed By: StanislavGlebik

Differential Revision: D15197798

fbshipit-source-id: 61280aa779148a24a0a9c78f25754ea06aa9ee49
2019-05-21 12:25:33 -07:00
Thomas Orozco
b15b433b80 mononoke: repo_read_write_status: fetch reason
Summary: This updates Mononoke's repo_read_write_status to fetch the reason from the database. The "Repo is locked in DB" default message is used as a fallback if the reason is NULL.

Reviewed By: HarveyHunt

Differential Revision: D15164791

fbshipit-source-id: f4cb68c28db1db996c7ef1a309b737cb781659d1
2019-05-21 12:25:32 -07:00
Stanislau Hlebik
9ee9bfad0a mononoke: check whitelists to see if connection is allowed
Differential Revision: D15164726

fbshipit-source-id: b959bfc3e901b40ff068077e09d8537b683e7b51
2019-05-21 12:25:32 -07:00
Stanislau Hlebik
aac6a6c835 mononoke: add security config
Summary:
The config will be used to whitelist connections with certain identities and
blacklist everything else.

Differential Revision: D15150921

fbshipit-source-id: e4090072ea6ba9714575fb8104d9f45e92c6fefb
2019-05-21 12:25:31 -07:00