Commit Graph

120 Commits

Author SHA1 Message Date
Mark Thomas
6f8737d116 mutationstore: a store for commit mutation information
Summary:
Add the Mononoke Mercurial mutation store.  This stores mutation information
for draft commits so that it can be shared between clients. The mutation
entries themselves are stored in a database, and the mutation store provides
abstractions for adding and querying them.

This commit adds the `all_predecessors` method to the mutation store, which
allows Mononoke to fetch all predecessors for a given set of commits.  This
will be used to serve mutation information to clients who are pulling draft
commits.

Reviewed By: krallin

Differential Revision: D20287381

fbshipit-source-id: b4455514cb8a22bef2b9bf0229db87c2a0404448
2020-04-23 08:58:09 -07:00
Mark Thomas
4ceb020d3a log: improve default log output
Summary:
Make the default output for `scsc log` shorter by only including the first line of the commit message, and omitting less interesting fields like commit extras.

The full details are hidden behind a `--verbose` flag, similar to `hg log`.

Reviewed By: mitrandir77

Differential Revision: D21202318

fbshipit-source-id: f15a0f8737f17e3189ea1bbe282d78a9c7199dd9
2020-04-23 08:36:43 -07:00
Stanislau Hlebik
dcf66ebc11 mononoke: add walker for fsnodes
Summary: Make it possible to traverse fsnodes in walker.

Reviewed By: ahornby

Differential Revision: D21153883

fbshipit-source-id: 047ab73466f48048a34cb52e7e0f6d04cda3143b
2020-04-23 01:24:20 -07:00
Alex Hornby
20b268cd68 mononoke: walker: add path to the OutgoingEdge
Summary:
For some nodes like FileContent from a BonsaiChangset, the file path is not part of node identity, but it is important for tracking which nodes are related to which paths.

This change adds an optional path field to the OutGoingEdge so that it can be used in route generation and as part of edge identity for sampling.

Its optional as some walks don't need the paths, for example scrub.

Reviewed By: farnz

Differential Revision: D20835653

fbshipit-source-id: f609c953da8bfa0cdfdfb26328149d567c73dbc9
2020-04-22 06:48:52 -07:00
Alex Hornby
de301b108e mononoke: walker: add blobstore usage by key type to scrub progress reporting
Summary: Report stats by the node type (e.g. FileContent, HgManifest etc) for blobstore usage when scrubbing so we can see how large each type is.

Reviewed By: StanislavGlebik

Differential Revision: D20564327

fbshipit-source-id: 55efd7671f893916d8f85fa9a93f95c97a098af4
2020-04-22 06:48:51 -07:00
Kostia Balytskyi
b59886c7f8 mononoke: fix how infinitepush is detected
Summary:
Correctly identify infinitepush without bookmarks as infinitepush instead of plain push.

Current behavior would sometimes pass `infinitepush` bundles through the `push` pipeline. Interestingly, this does not result in any user-visible effects at the moment. However, in the future we may want to diverge these pipelines:
- maybe we want to disable `push`, but enable `infinitepush`
- maybe there will be performance optimizations, applicable only to infinitepush

In any case, the fact that things worked so far is a consequence of a historical accident, and we may not want to keep it this way. Let's have correct identification.

Reviewed By: StanislavGlebik

Differential Revision: D18934696

fbshipit-source-id: 69650ca2a83a83e2e491f60398a4e03fe8d6b5fe
2020-04-22 05:13:36 -07:00
Lukas Piatkowski
449594be46 mononoke/hooks: fix to panic the server when AclChecker is unreachable
Summary:
In next diffs with permission_checker the panic is changed to anyhow::Error.

The previous behavior of this code was that when AclChecker updated failed
after 10s this fact was ignored and the hooks were simply not using ACLs. This
diff fixes it so that the server exits when AclChecheker update is timing out.

Reviewed By: johansglock

Differential Revision: D21155944

fbshipit-source-id: ab4a5071acbe6a1282a7bc5fdbf301b4bd53a347
2020-04-22 02:45:03 -07:00
Alex Hornby
12585058cf mononoke: walker: update compression-benefit to report progress by node type
Summary:
Allow us to see the sizes for each node type (e.g. manifests, bonsais etc), and extends the default reporting to all types.

The progress.rs changes update its summary by type reporting to be reusable, and then it is reused by the changes to sizing.rs.

Reviewed By: krallin

Differential Revision: D20560962

fbshipit-source-id: f09b45b34f42c5178ba107dd155abf950cd090a7
2020-04-21 08:29:21 -07:00
Thomas Orozco
aae2721caf mononoke_hg_sync_job: don't fail if the Globalrev counter is where we want it
Summary:
This was how this was supposed to work all along, but there was a bug in the
sense that if the counter is where want to set it, then the update affects 0
rows. This is a bit of a MySQL idiosyncrasy — ideally we would set
CLIENT_FOUND_ROWS on our connections in order to be consistent with SQLite.

That said, for now, considering we are the only ones touching this counter, and
considering this code isn't intended to be long-lived, it seems reasonable to
just check the counter after we fail to set it.

(see https://dev.mysql.com/doc/refman/8.0/en/mysql-affected-rows.html for
context)

Reviewed By: HarveyHunt

Differential Revision: D21153966

fbshipit-source-id: 663881c29a11a619ec9ab20c4291734ff13d798a
2020-04-21 06:09:19 -07:00
Alex Hornby
15f98fe58c mononoke: walker: fix flaky integration tests
Summary:
These failed when I did a local run against fbcode warm

count-objects.t and enabled-derive.t were flaky depending on the exact path taken through the graph.

Reviewed By: ikostia

Differential Revision: D21092866

fbshipit-source-id: ac4371cf81128b4d38cd764d86fc45d44d639ecc
2020-04-21 05:23:16 -07:00
Kostia Balytskyi
e7df58e848 mononoke: [RFC] migrate bits of validation code to Small/Large newtypes
Summary:
This is a POC attempt to increase the type safety of the megarepo codebase by introducing the `Small`/`Large` [newtype](https://doc.rust-lang.org/rust-by-example/generics/new_types.html) wrappers for some of the function arguments.

As an example, compare these two function signatures:
```
pub async fn verify_filenode_mapping_equivalence<'a>(
    ctx: CoreContext,
    source_hash: ChangesetId,
    source_repo: &'a BlobRepo,
    target_repo: &'a BlobRepo,
    moved_source_repo_entries: &'a PathToFileNodeIdMapping,
    target_repo_entries: &'a PathToFileNodeIdMapping,
    reverse_mover: &'a Mover,
) -> Result<(), Error>
```
and
```
async fn verify_filenode_mapping_equivalence<'a>(
    ctx: CoreContext,
    source_hash: Large<ChangesetId>,
    large_repo: &'a Large<BlobRepo>,
    small_repo: &'a Small<BlobRepo>,
    moved_large_repo_entries: &'a Large<PathToFileNodeIdMapping>,
    small_repo_entries: &'a Small<PathToFileNodeIdMapping>,
    reverse_mover: &'a Mover,
) -> Result<(), Error>
```

In the first case, it is possible to call function with the source and target repo inverted accidentally, whereas in the second one it is not.

Reviewed By: StanislavGlebik

Differential Revision: D20463053

fbshipit-source-id: 5f4f9ac918834dbdd75ed78623406aa777950ace
2020-04-20 11:30:05 -07:00
Thomas Orozco
825b0a1daa mononoke/hg_sync: fix off-by-one error in globalrev sync
Summary:
The ID in Hgsql is supposed to the next globalrev to assign, not the last one
that was assigned. We would have otherwise noticed during the rollout since
we'd have seen that the counter in Mercurial wasn't `globalrev(master) + 1`
(and we could have fixed it up manually before it had any impact), but let's
fix it now.

Reviewed By: StanislavGlebik

Differential Revision: D21089653

fbshipit-source-id: 0a37e1b7299a0606788bd87f788799db6e3d55f4
2020-04-20 07:16:44 -07:00
Stanislau Hlebik
74fe56b5d8 mononoke: fix timeout in integration tests
Reviewed By: krallin

Differential Revision: D21129373

fbshipit-source-id: 7c47e5b5a156babfc8ad9819af44f807a1a036d1
2020-04-20 05:28:52 -07:00
Thomas Orozco
518167f581 mononoke: allow for HgsqlGlobalrevs name not matching the HgsqlName
Reviewed By: ahornby

Differential Revision: D21088256

fbshipit-source-id: 6ed2969d41ade83d1a603e319450be7decd3f151
2020-04-17 06:24:10 -07:00
Thomas Orozco
805a150bb6 mononoke/hook_tailer: support passing a list of changesets to tail
Summary:
This makes it easier to test performance on a specific set of commits. As part
of that, I've also updated our file reading to be async since why not.

Reviewed By: farnz

Differential Revision: D21064609

fbshipit-source-id: d446ab5fb5597b9113dbebecf97f7d9b2d651684
2020-04-17 04:52:28 -07:00
Thomas Orozco
d6d5129fa3 mononoke: add smoke tests for the hook tailer
Summary:
Let's try and make sure this doesn't bitrot again by adding a smoke test. Note
that there are no hooks configured here, so this exercises everything but the
actual hook running, but for now this is probably fine.

Note that this required updating the hook tailer to use the repository config
for the hook manager, since you can't start AclChecker in a test otherwise.

Reviewed By: StanislavGlebik

Differential Revision: D21063378

fbshipit-source-id: c7336bc883dca2722b189449a208e9381196300e
2020-04-17 04:52:27 -07:00
Arun Kulshreshtha
fc741586d2 Add integration test for EdenAPI server
Summary: Add a simple integration test for the EdenAPI server which just starts up a server and hits its health_check endpoint. This will be expanded in later diffs to perform actual testing.

Reviewed By: krallin

Differential Revision: D21054212

fbshipit-source-id: a3be8ddabb3960d709a1e83599bc6a90ebe49b25
2020-04-16 10:03:13 -07:00
Thomas Orozco
87622937f5 mononoke/blobstore_healer: remove more old futures from main
Summary:
This turns out quite nice because we had some futures there that were always
`Ok`, and now we can use `Output` instead of `Item` and `Error`.

Reviewed By: ahornby

Differential Revision: D21063119

fbshipit-source-id: ab5dc67589f79c898d742a276a9872f82ee7e3f9
2020-04-16 09:46:13 -07:00
Kostia Balytskyi
220edc6740 admin: add a subcommand to manipulate mutable_counters
Summary:
This is generally something I wanted to have for a long time: instead of having to open a writable db shell, now we can just use the admin command. Also, this will be easier to document in the oncall wikis.

NB: this is lacking the `delete` functionality atm, but that one is almost never needed.

Reviewed By: krallin

Differential Revision: D21039606

fbshipit-source-id: 7b329e1782d1898f1a8a936bc711472fdc118a96
2020-04-16 03:19:44 -07:00
Xavier Deguillard
4973c55030 exchange: always call prepushoutgoing hooks
Summary:
Previously, an extension adding the "changeset" pushop might forget to call the
prepushoutgoing hooks, preventing them from being called.

Reviewed By: DurhamG

Differential Revision: D21008487

fbshipit-source-id: a6bc506c7e1695854aca3d3b2cd118ef1c390c52
2020-04-15 20:22:18 -07:00
Mark Thomas
235c9a5cd9 getbundle: compute full set of new draft commits
Summary:
In getbundle, we compute the set of new draft commit ids.  This is used to
include tree and file data in the bundle when draft commits are fully hydrated,
and will also be used to compute the set of mutation information we will
return.

Currently this calculation only computes the non-common draft heads.  It
excludes all of the ancestors, which should be included.  This is because it
re-uses the prepare_phases code, which doesn't quite do what we want.

Instead, separate out these calculations into two functions:

  * `find_new_draft_commits_and_public_roots` finds the draft heads
    and their ancestors that are not in the common set, as well as the
    public roots the draft commits are based on.
  * `find_phase_heads` finds and generates phase head information for
    the public heads, draft heads, and the nearest public ancestors of the
    draft heads.

Reviewed By: StanislavGlebik

Differential Revision: D20871337

fbshipit-source-id: 2f5804253b8b4f16b649d737f158fce2a5102002
2020-04-15 11:00:33 -07:00
Xavier Deguillard
643e69e045 remotefilelog: do not write delta in bundle2
Summary:
Computing delta force the client to have the previous version locally, which it
may not have, forcing a full fetch of the blob, to then compute a delta. Since
delta are a way to save on bandwidth usage, fetching a blob to compute it
negate its benefits.

Reviewed By: DurhamG

Differential Revision: D20999424

fbshipit-source-id: ae958bb71e6a16cfc77f9ccebd82eec00ffda0db
2020-04-15 10:26:39 -07:00
Kostia Balytskyi
cf10fe8689 admin: make sure bookmark operations create syncable log entries
Summary:
This is important for various syncs.

Note: there's an obvious race condition, TOCTTOU is non-zero for existing bookmark locations. I don't think this is a problem, as we can always re-run the admin.

Reviewed By: StanislavGlebik

Differential Revision: D21017448

fbshipit-source-id: 1e89df0bb33276a5a314301fb6f2c5049247d0cf
2020-04-15 04:17:42 -07:00
Aida Getoeva
25eff1c91e mononoke/scs-log: integrate deleted manifest (linear)
Summary:
Use deleted manifest to search deleted paths in the repos with linear history. For merged history it returns error as there was no such path.
Commit, where the path was deleted, is returned as a first commit in the history stream, the rest is a history before deletion.

Reviewed By: StanislavGlebik

Differential Revision: D20897083

fbshipit-source-id: e75e53f93f0ca27b51696f416b313466b9abcee8
2020-04-14 18:27:39 -07:00
Kostia Balytskyi
f31680f160 admin: change "blacklisted" to "redacted" in admin and tests
Summary:
Some time ago we decided on the "redaction" naming for this feature. A few
places were left unfixed.

Reviewed By: xavierd

Differential Revision: D21021354

fbshipit-source-id: 18cd86ae9d5c4eb98b843939273cfd4ab5a65a3a
2020-04-14 16:18:35 -07:00
Thomas Orozco
69b09c0854 mononoke/hg_sync_job: use hgsql name in integration test
Summary: What it says in the title.

Reviewed By: farnz

Differential Revision: D20943176

fbshipit-source-id: 8fae9b0bad32e2b6ede3c02305803c857c93f5e7
2020-04-14 10:26:11 -07:00
Thomas Orozco
d84ba9caae mononoke/hg_sync_job: use the hgsql repo name for globalrevs
Summary:
The name for repository in hgsql might not match that of the repository itself.
Let's use the hgsql repo name instead of the repo name for syncing globalrevs.

Reviewed By: farnz

Differential Revision: D20943175

fbshipit-source-id: 605c623918fd590ba3b7208b92d2fedf62062ae1
2020-04-14 10:26:10 -07:00
Simon Farnsworth
92fce3d518 Clean out unused deps from our TARGETS files
Summary:
We had accumulated lots of unused dependendencies, and had several test_deps in deps instead. Clean this all up to reduce build times and speed up autocargo processing.

Net removal is of around 500 unneeded dependency lines, which represented false dependencies; by removing them, we should get more parallelism in dev builds, and less overbuilding in CI.

Reviewed By: krallin, StanislavGlebik

Differential Revision: D20999762

fbshipit-source-id: 4db3772cbc3fb2af09a16601bc075ae8ed6f0c75
2020-04-14 03:38:11 -07:00
Thomas Orozco
77149d7ee8 mononoke/lfs_server: don't return a 502 on batch error
Summary:
502 made a bit of sense since we can occasionally proxy things to upstream, but
it's not very meaningful because our inability to service a batch request is
never fully upstream's fault (it would not a failure if we had everything
internally).

So, let's just return a 500, which makes more sense.

Reviewed By: farnz

Differential Revision: D20897250

fbshipit-source-id: 239c776d04d2235c95e0fc0c395550f9c67e1f6a
2020-04-08 11:58:09 -07:00
Stefan Filip
d1ba21803a version: warn users when they are running an old build
Summary:
Old is defined by being based on a commit that is more than 30 days old.
The build date is taken from the version string.
One observation is that if we fail to release in more than 30 days then all
users will start seeing this message without any way of turning it off. Doesn't
seem worth while to add a config for silencing it though.

Reviewed By: quark-zju

Differential Revision: D20825399

fbshipit-source-id: f97518031bbda5e2c49226f3df634c5b80651c5b
2020-04-07 14:25:38 -07:00
Stanislau Hlebik
b2a8862a9a mononoke: add a test backfill derived data
Summary:
I decided to go with integration test because backfilling derived data at the
moment requires two separate calls - a first one to prefetch changesets, and a
second one to actually run backfill. So integration test is better suited for this
case than unit tests.

While doing so I noticed that fetch_all_public_changesets actually won't fetch
all changesets - it loses the last commit becauses t_bs_cs_id_in_range was
returning exclusive (i.e. max_id was not included). I fixed the bug and made the name clearer.

Reviewed By: krallin

Differential Revision: D20891457

fbshipit-source-id: f6c115e3fcc280ada26a6a79e1997573f684f37d
2020-04-07 08:44:25 -07:00
Thomas Orozco
edadb9307a mononoke/repo_client: record depth
Summary: As it says in the title!

Reviewed By: HarveyHunt

Differential Revision: D20869828

fbshipit-source-id: df7728ce548739ef2dadad1629817fb56c166b66
2020-04-07 04:36:06 -07:00
Thomas Orozco
1c982d5258 mononoke/unbundle_replay: report size of the unbundle
Summary: This is helpful to draw conclusions as to how fast it is.

Reviewed By: StanislavGlebik

Differential Revision: D20872108

fbshipit-source-id: d323358bbba29de310d6dfb4c605e72ce550a019
2020-04-07 01:05:32 -07:00
Mateusz Kwapich
549eb41059 run blobstore healer integration test with mysql
Summary: So we're sure that all the quries work not only in sqlite.

Reviewed By: krallin

Differential Revision: D20839958

fbshipit-source-id: 9d05cc175d65396af7495b31f8c6958ac7bd8fb6
2020-04-06 09:57:24 -07:00
Alex Hornby
7060cd47d6 mononoke: walker: use sampling blobstore in compression-benefit
Summary:
Use the new sampling blobstore and sampling key in existing compression-benefit subcommand and check the new vs old reported sizes.

The overall idea for these changes is that the walker uses a CoreContext tagged with a SamplingKey to correlate walker steps for a node to the underlying blobstore reads,  this allows us to track overall bytes size (used in scrub stats) or the data itself (used in compression benefit)  per node type.

The SamplingVisitor and NodeSamplingHandler cooperate to gather the sampled data into the maps in NodeSamplingHandler,  which the output stream from the walk then operates on, e.g. to compress the blobs and report on compression benefit.

The main new logic sits in sampling.rs, it is used from sizing.rs (and later in stack from scrub.rs)

Reviewed By: krallin

Differential Revision: D20534841

fbshipit-source-id: b20e10fcefa5c83559bdb15b86afba209c63119a
2020-04-02 09:08:05 -07:00
Mark Thomas
640f272598 migrate from sql_ext::SqlConstructors to sql_construct
Summary:
Migrate the configuration of sql data managers from the old configuration using `sql_ext::SqlConstructors` to the new configuration using `sql_construct::SqlConstruct`.

In the old configuration, sharded filenodes were included in the configuration of remote databases, even when that made no sense:
```
[storage.db.remote]
db_address = "main_database"
sharded_filenodes = { shard_map = "sharded_database", shard_num = 100 }

[storage.blobstore.multiplexed]
queue_db = { remote = {
    db_address = "queue_database",
    sharded_filenodes = { shard_map = "valid_config_but_meaningless", shard_num = 100 }
}
```

This change separates out:
* **DatabaseConfig**, which describes a single local or remote connection to a database, used in configuration like the queue database.
* **MetadataDatabaseConfig**, which describes the multiple databases used for repo metadata.

**MetadataDatabaseConfig** is either:
* **Local**, which is a local sqlite database, the same as for **DatabaseConfig**; or
* **Remote**, which contains:
    * `primary`, the database used for main metadata.
    * `filenodes`, the database used for filenodes, which may be sharded or unsharded.

More fields can be added to **RemoteMetadataDatabaseConfig** when we want to add new databases.

New configuration looks like:
```
[storage.metadata.remote]
primary = { db_address = "main_database" }
filenodes = { sharded = { shard_map = "sharded_database", shard_num = 100 } }

[storage.blobstore.multiplexed]
queue_db = { remote = { db_address = "queue_database" } }
```

The `sql_construct` crate facilitates this by providing the following traits:

* **SqlConstruct** defines the basic rules for construction, and allows construction based on a local sqlite database.
* **SqlShardedConstruct** defines the basic rules for construction based on sharded databases.
* **FbSqlConstruct** and **FbShardedSqlConstruct** allow construction based on unsharded and sharded remote databases on Facebook infra.
* **SqlConstructFromDatabaseConfig** allows construction based on the database defined in **DatabaseConfig**.
* **SqlConstructFromMetadataDatabaseConfig** allows construction based on the appropriate database defined in **MetadataDatabaseConfig**.
* **SqlShardableConstructFromMetadataDatabaseConfig** allows construction based on the appropriate shardable databases defined in **MetadataDatabaseConfig**.

Sql database managers should implement:

* **SqlConstruct** in order to define how to construct an unsharded instance from a single set of `SqlConnections`.
* **SqlShardedConstruct**, if they are shardable, in order to define how to construct a sharded instance.
* If the database is part of the repository metadata database config, either of:
    * **SqlConstructFromMetadataDatabaseConfig** if they are not shardable.  By default they will use the primary metadata database, but this can be overridden by implementing `remote_database_config`.
    * **SqlShardableConstructFromMetadataDatabaseConfig** if they are shardable.  They must implement `remote_database_config` to specify where to get the sharded or unsharded configuration from.

Reviewed By: StanislavGlebik

Differential Revision: D20734883

fbshipit-source-id: bb2f4cb3806edad2bbd54a47558a164e3190c5d1
2020-04-02 05:27:16 -07:00
Jun Wu
2aec2dbcb6 commitcloud: migrate to tech-debt-free repo.pull for pulling
Summary:
The new API does nothing that cloud sync does not want: bookmarks, obsmarkers,
prefetch, etc. Wrappers to disable features are removed.

This solves a "lagged master" issue where selectivepull adds `-B master` to
pull extra commits but cloud sync cannot hide them without narrow-heads. Now
cloud sync just does not pull the extra commits.

Reviewed By: sfilipco

Differential Revision: D20808884

fbshipit-source-id: 0e60d96f6bbb9d4ce02c04e8851fc6bda442c764
2020-04-01 19:40:57 -07:00
Lukas Piatkowski
bf34f084d0 mononoke: make blobrepo and its dependencies OSS buildable
Reviewed By: markbt

Differential Revision: D20495840

fbshipit-source-id: 3bbefae1923dc84e3daea158a24c0d2a802cc9a9
2020-03-31 04:02:45 -07:00
Thomas Orozco
11af551491 mononoke/benchmark_filestore: make it work again
Summary:
This bitrot with two different changes:

- D19473960 put it on a v2 runtime, but the I/O is v1 so that doesn't work (it
  panics).
- The clap update a couple months ago made duplicate arguments illegal, and a
  month before that we had put `debug` in the logger args (arguably where it
  belong), so this binary was now setting `debug` twice, which would now panic.

Evidently, just static typing wasn't quite enough to keep this working through
time (though that's perhaps due to the fact that both of those changes were
invisible to the type system), so I also added a smoke test for this.

Reviewed By: farnz

Differential Revision: D20618785

fbshipit-source-id: a1bf33783885c1bb2fe99d3746d1b73853bcdf38
2020-03-30 07:32:20 -07:00
Thomas Orozco
8315336b2c mononoke/unbundle_replay: run hooks
Summary:
As the name indicates, this updates unbundle_replay to run hooks. Hook failures
don't block the replay, but they're logged to Scuba.

Differential Revision: D20693851

fbshipit-source-id: 4357bb0d6869a658026dbc5421a694bc4b39816f
2020-03-30 06:25:08 -07:00
Thomas Orozco
066cdcfb3d mononoke/unbundle_replay: also report recorded duration
Summary: This will make it easier to compare performance.

Differential Revision: D20674164

fbshipit-source-id: eb1a037b0b060c373c1e87635f52dd228f728c89
2020-03-30 06:25:07 -07:00
Thomas Orozco
213276eff5 mononoke/unbundle_replay: add Scuba reporting
Summary: This adds some Scuba reporting to unbundle_replay.

Differential Revision: D20674162

fbshipit-source-id: 59e12de90f5fca8a7c341478048e68a53ff0cdc1
2020-03-30 06:25:07 -07:00
Thomas Orozco
13f24f7425 mononoke/unbundle_replay: unbundle concurrently, derive filenodes concurrently
Summary:
This updates unbundle_replay to do things concurrently where possible.
Concretely, this means we do ingest unbundles concurrently, and filenodes
derivation concurrently, and only do the actual pushrebase sequentially. This
lets us get ahead on work wherever we can, and makes the process faster.

Doing unbundles concurrently isn't actually guaranteed to succeed, since it's
*possible* that an unbundle coming in immediately after a pushrebase actually
depends the commits created in said pushrebase. In this case, we simply retry
the unbundle when we're ready to proceed with the pushrebase (in the code, this
is the `Deferred` variant). This is fine from a performance perspective

As part of this, I've also moved the loading of the bundle to processing, as
opposed to the hg recording client (the motivation for this is that we want to
do this loading in parallel as well).

This will also let us run hooks in parallel once I add this in.

Reviewed By: StanislavGlebik

Differential Revision: D20668301

fbshipit-source-id: fe2c62ca543f29254b4c5a3e138538e8a3647daa
2020-03-30 06:25:07 -07:00
Thomas Orozco
8ce3d94187 mononoke/unbundle_replay: add support for replaying a bookmark
Summary:
This adds support for replaying the updates to a bookmark through unbundle
replay. The goal is to be able to run this as a process that keeps a bookmark
continuously updated.

There is still a bit of work here, since we don't yet allow the stream to pause
until bookmark update becomes available (i.e. once caught up, it will exit).
I'll introduce this in another diff.

Note that this is only guaranteed to work if there is a single bookmark in the
repo. With more, it could fail if a commit is first introduced in a bookmark that
isn't the one being replayed here, and later gets introduced in said bookmark.

Reviewed By: StanislavGlebik

Differential Revision: D20645159

fbshipit-source-id: 0aa11195079fa6ac4553b0c1acc8aef610824747
2020-03-30 06:25:04 -07:00
Thomas Orozco
6b1894cec9 mononoke/unbundle_replay: derive filenodes
Summary:
We normally derive those lazily when accepting pushrebase, but we do derive
them eagerly in blobimport. For now, let's be consistent with blobimport.

This ensures that we don't lazily generate them, which would require read traffic,
and gives a picture a little more consistent with what an actual push would look like.

Reviewed By: ikostia

Differential Revision: D20623966

fbshipit-source-id: 2209877e9f07126b7b40561abf3e6067f7a613e6
2020-03-30 06:25:04 -07:00
Thomas Orozco
7ca14665a2 mononoke/unbundle_replay: use repo pushrebase hooks
Summary:
This updates unbundle_replay to account for pushrebase hooks, notably to assign
globalrevs.

To do so, I've extracted the creation of pushrebase hooks in repo_client and
reused it in unbundle_replay. I also had to update unbundle_replay to no longer
use `args::get_repo` since that doesn't give us access to the config (which we
need to know what pushrebase hooks to enable).

Reviewed By: ikostia

Differential Revision: D20622723

fbshipit-source-id: c74068c920822ac9d25e86289a28eeb0568768fc
2020-03-30 06:25:03 -07:00
Thomas Orozco
3804f1ca16 mononoke: introduce unbundle_replay
Summary:
This adds a unbundle_replay Rust binary. Conceptually, this is similar to the
old unbundle replay Python script we used to have, but there are a few
important differences:

- It runs fully in-process, as opposed to pushing to a Mononoke host.
- It will validate that the pushrebase being produced is consistent with what
  is expected before moving the bookmark.
- It can find sources to replay from the bookmarks update log (which is
  convenient for testing).

Basically, this is to writes and to the old unbundle replay mechanism what
Fastreplay is to reads and to the traffic replay script.

There is still a bit of work to do here, notably:

- Make it possible to run this in a loop to ingest updates iteratively.
- Run hooks.
- Log to Scuba!
- Add the necessary hooks (notably globalrevs)
- Set up pushrebase flags.

I would also like to see if we can disable the presence cache here, which would
let us also use this as a framework for benchmarking work on push performance,
if / when we need that.

Reviewed By: StanislavGlebik

Differential Revision: D20603306

fbshipit-source-id: 187c228832fc81bdd30f3288021bba12f5aca69c
2020-03-30 06:25:03 -07:00
Aida Getoeva
5e7c092cba mononoke/scs-log: do not accept timestamps <= 0
Summary:
SCS log accepts two dates/timestamps to filter history by the commit creation time. Each timestamp is a `i64` and zero or negative timestamp still represents a pretty valid time in past.
The time filters are pretty expensive: they require sequential changeset info fetching and checking the date.

It turned out that some of the requests have time filters but seem not meaning it: their both after and before timestamps equals to zero. And there are lots of such queries: https://fburl.com/scuba/mononoke_scs_server/g345na72. This cause SCS log traverse the whole history for a path, which turns into hours of fetching cs infos and fastlog batches.

I've decided to consider a valid timestamp only the timestamp greater than 0: only after 1970-01-01 00:00:00 UTC.

Reviewed By: StanislavGlebik

Differential Revision: D20670210

fbshipit-source-id: f59c425779a37ecac489dbba2ed3fd547987ee62
2020-03-26 14:06:31 -07:00
Jun Wu
8bd55436a4 pull: automatically pull selective bookmarks unless it's a no-argument pull
Summary:
This enforces certain selective pull logic in core. Namely, rewrite `pull -r X`
to `pull -r X -B master`.

Unlike selectivepull in remotenames, `pull` (pulls everything) won't be
rewritten to `pull -B master` (which pulls less commits and names).

Therefore this change always adds more commits to pull, and therefore should not
break existing users. Eventually we want the "not pulling everything" behavior,
but right now this just fixes `pull -r X` to also update important remote names.

Reviewed By: markbt

Differential Revision: D20531121

fbshipit-source-id: af457b5ddb1265b61956eb2ee6afb7b7208293e0
2020-03-26 10:54:09 -07:00
Aida Getoeva
54575f37be mononoke/scs: separate blame integration test from test-scs.t
Summary:
This diff moves blame integration tests out from the main `test-scs.t`.
The change makes `test-scs.t` be able to complete and not time out anymore.

Reviewed By: ikostia

Differential Revision: D20629281

fbshipit-source-id: 67ba047442e7216a8addd0945c94d2f932eca08a
2020-03-25 09:00:20 -07:00