Commit Graph

2375 Commits

Author SHA1 Message Date
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
Stanislau Hlebik
9ad20e4e75 mononoke: bump max_entries_in_fastlog_batch
Reviewed By: krallin

Differential Revision: D17225899

fbshipit-source-id: 6a964b533b4ded70043506f3836f9c3668f4984c
2019-09-09 09:54:41 -07:00
Stanislau Hlebik
609e01e237 mononoke: support merges in FastlogBatch
Summary:
Finally support merges. Whenever we have a merge a completely new batch is
created.

The one thing that surprised me was that ParentOffsets actually can be
negative. For example
```
     o
  /    \
 o       o
 |       |
 o       |
 |       |
 o <---  | --- ParentOffset of this commit can be negative!
   \   /
     o
```

It happens because of BFS order of traversal - parent can be visited befor the
child. Note that negative offsets shouldn't cause problems.

Reviewed By: aslpavel

Differential Revision: D17183355

fbshipit-source-id: b5165ffef7212ce220dd338079db9e26a3030f58
2019-09-09 09:54:41 -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
Mark Thomas
78af568a01 apiserver: implement SourceControlService commit_is_ancestor_of
Summary:
Implement the `commit_is_ancestor_of` call, which returns whether this commit
is an ancestor of some other commit.

Reviewed By: krallin

Differential Revision: D17183595

fbshipit-source-id: be7826e778c48dd86f116d7fbcaabe18bdffab44
2019-09-09 04:23:37 -07:00
Mark Thomas
f2e9e6a90a apiserver: implement SourceControlService commit_info
Summary: Implement the `commit_info` call, which returns the metadata for the commit.

Reviewed By: krallin

Differential Revision: D17183596

fbshipit-source-id: 500029b7c4b4705fd937a894d15c14d911129b3c
2019-09-09 04:23:37 -07:00
Mark Thomas
3360b4456e apiserver: implement SourceControlService commit_lookup
Summary:
Implement the `commit_lookup` call, which looks-up commits to see if they exist,
and maps between commit identity schemes.

Reviewed By: krallin

Differential Revision: D17183597

fbshipit-source-id: 3d21c9b0804ce3bbd576543716ce9647d7d1d7e2
2019-09-09 04:23:36 -07:00
Mark Thomas
75efc1c5fd apiserver: implement SourceControlService repo_list_bookmarks
Summary:
Implement the `repo_list_bookmarks` call, which lists bookmarks.

Listing scratch bookmarks requires the user to provide a prefix to match on an
a limit for the number of bookmarks to fetch.  There is currently no provision
for paging.

Reviewed By: krallin

Differential Revision: D17157497

fbshipit-source-id: 247f02299f40a9e9142c6ca838fca1d1de874382
2019-09-09 04:23:36 -07:00
Mark Thomas
879c6d9900 apiserver: implement SourceControlService repo_resolve_bookmark
Summary:
Implement the `repo_resolve_bookmark` call, which resolves a bookmark in a repo
to the commits that the bookmark points to.

Reviewed By: krallin

Differential Revision: D17157498

fbshipit-source-id: e7e53df2cb9e3efaddcd22a8d0db344a8d279f08
2019-09-09 04:23:36 -07:00
Mark Thomas
121a66da8b apiserver: implement SourceControlService list_repos
Summary:
Implement the `list_repos` call, which returns a list of the repos that
Mononoke knows about.

Reviewed By: krallin

Differential Revision: D16984064

fbshipit-source-id: 872ef5b53453ae7f9eb664044f03ec15c83d2152
2019-09-09 04:23:35 -07:00
Mark Thomas
0338560712 apiserver: create new Mononoke alongside apiserver Mononoke
Summary:
Instantiate the new Mononoke internal API's `Mononoke` object alongside the
existing apiserver `Mononoke` abstraction.  We will migrate all uses of the
existing one to the new one and then remove the apiserver's `Mononoke`.

For now, construct the new one by assembling it from the parts of the existing
`Mononoke` abstraction.  When that is removed, we will create the new one
directly.

Provide the new Mononoke object to the HTTP server and the Source Control
Service Thrift server, as both of these will need it.

Reviewed By: krallin

Differential Revision: D16984061

fbshipit-source-id: eb8c237dfa6d82a96d4cb0baf29e4bfa39119bc9
2019-09-09 04:23:35 -07:00
Mark Thomas
180f5a7363 apiserver: implement source_control service
Summary:
Make the Mononoke apiserver implement the new source_control service.  None of
the methods are defined yet.

Reviewed By: krallin

Differential Revision: D16984062

fbshipit-source-id: 997e3aad6fc0b31eb546260f912c046c6803e176
2019-09-09 04:23:35 -07:00
Mark Thomas
cfd62d35f5 mononoke_api: implement From<MononokeError> for source control exceptions
Summary:
Implement `From<MononokeError>` for the source control service thrift exceptions.

This isn't really the right place, as the `mononoke_api` crate shouldn't need
to know anything about thrift, however Rust trait rules mean we have to declare
the implementation in the same crate as `MononokeError`.

Reviewed By: krallin

Differential Revision: D17208631

fbshipit-source-id: f74f16bbde1da9c6dc0c9e1aede769dca6e9a114
2019-09-09 04:23:35 -07:00
Mark Thomas
cb8857b0e0 mononoke_api: support Mercurial hashes as changeset specifiers
Summary:
Make it so that full Mercurial hashes can be used to specify changesets, as
well as full bonsai changeset hashes.

Reviewed By: krallin

Differential Revision: D16803204

fbshipit-source-id: 14db530bf77eb6b76e83697e00d6e2cf46586a0c
2019-09-09 04:23:34 -07:00
Mark Thomas
2e35cfcb0b mononoke_api: create new Mononoke internal API
Summary:
Start the creation of a new Mononoke internal API within the `mononoke_api` crate.

This abstraction will be used by the API server, as well as any future server types.

To create a new Mononoke instance the caller instantiates a `Mononoke` object,
passing it the configuration to load.

Queries begin by calling a method on the `Mononoke` instance, passing a
`CoreContext` for that request.  For example, calling the `repo` method returns
a `RepoContext` object which is bound to the repository and the request
`CoreContext`.  Further methods on these context objects can be called, which
will return either new data or new, more specialized, context objects.

For example, to find the author of a commit, the caller can use:
```
    let ctx = CoreContext::new(...);
    let author = mononoke.repo(ctx, "reponame").changeset(changeset_specifier).author();
```

Reviewed By: StanislavGlebik

Differential Revision: D16803206

fbshipit-source-id: 20a8e08f0075476844df4b8c5015ac3faa22d423
2019-09-09 04:23:34 -07:00
Pavel Aslanov
8a52e7f34c improve unodes generation for large commits
Summary: Improve unodes generation for large commits

Reviewed By: farnz

Differential Revision: D17226939

fbshipit-source-id: 5e0878f65b28d886b1ca8398dc0dd08f8222d61d
2019-09-09 03:59:50 -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
Pavel Aslanov
f8e13c366d create traces for slow derivations
Summary: Store traces for slow derivations.

Reviewed By: StanislavGlebik

Differential Revision: D17205438

fbshipit-source-id: 7cf936687b81f335cd53e2383198bc39983c9127
2019-09-09 03:59:50 -07:00
Pavel Aslanov
a7b5abe15a batch derived data mapping updates
Summary: This commit tries to improve performance by batching multiple updates of `DerivedDataMapping` into one

Reviewed By: StanislavGlebik

Differential Revision: D17156437

fbshipit-source-id: dd80169b39b43c58cb90b0347cfe95e24e341d0b
2019-09-09 03:59:49 -07:00
Thomas Orozco
f1387a1622 mononoke/lfs_server: add health endpoint
Summary: This is helpful for Tupperware.

Reviewed By: HarveyHunt

Differential Revision: D17227429

fbshipit-source-id: 5b30833eb5b7f4618ee3360daca486d13b8142b3
2019-09-09 03:32:18 -07:00
Thomas Orozco
fac2a69a72 mononoke/lfs_server: initial logging
Summary: Not much to see here. This is just a POC of some logging being setup.

Reviewed By: StanislavGlebik

Differential Revision: D17203576

fbshipit-source-id: 14e0d8d3d91b9142029e4198fa7be688e666952f
2019-09-09 03:32:18 -07:00
Thomas Orozco
fd467a89f2 mononoke/lfs_server: add TLS
Summary: This updates the lfs_server to support TLS.

Reviewed By: StanislavGlebik

Differential Revision: D17203298

fbshipit-source-id: aa91a1b6304c7203018cd5f9feb90645e085cb31
2019-09-09 03:32:17 -07:00
Thomas Orozco
f3149a4799 mononoke/lfs_server: add a LFS server for Mononoke
Summary:
This introduces a LFS server for Mononoke, which is designed to also act as a
reverse proxy to a fallback LFS server. The goal of this LFS server is to
uphold the following guarantees:

- If a client uploads successfully, then the LFS content will be present in
  Mononoke as well as the upstream server.
- If a piece of content is present in either Mononoke or the upstream server,
  then downloading this content will succeed. If the content is available in
  Mononoke, it'll be served there. Otherwise, the client will be redirected to
  the upstream server.

Note that while the LFS server for Mononoke exposes a route per repo, that
isn't the case for the upstream server.

Also, note that this only does proxying for the batch endpoint and uploads.
Clients must have access to the upstream to download from there blobs that
don't exist in Mononoke.

Implementation-wise, this uses async Rust and the Gotham web framework (Gotham
is based on Hyper, which we also use to talk to upstream LFS). Note that
neither Gotham nor Mononoke's filestore doesn't use Tokio 0.2 yet, so we still
have to run on Tokio 0.1 as the executor.

Reviewed By: StanislavGlebik

Differential Revision: D17182753

fbshipit-source-id: 24c9c9c7183506c38d7534665a19d42acf4b3442
2019-09-09 03:32:17 -07:00
Thomas Orozco
1fcd8f4180 mononoke/filestore: implicitly fuse ChunkStream
Summary:
I noticed while testing the LFS proxy that we could occasionally poll the
stream underlying a `ChunkStream` when it had already indicated it had no more
data. This is bad because it might panic on some streams.

I initially thought this might have to do with the `poll()` shenanigans we do
in `prepare()`, but that doesn't appear to be the case (getting rid of those
doesn't fix anything).

Regardless, we can fix this by implicitly fusing things in `ChunkStream`, which
seems to be the problem here (in the LFS server, uploads that don't get chunked
don't crash, which makes sense we only use stdlib combinators to concatenate
the incoming stream).

Reviewed By: StanislavGlebik

Differential Revision: D17225985

fbshipit-source-id: 76ad21744461cdbd1376c6ce810e0a7a10b37ef0
2019-09-09 03:32:17 -07:00
Thomas Orozco
e191abb929 mononoke: fix the build
Summary:
I had a diff that removed `safe_writes` that landed at about the same time
ikostia's diff that added a new command that includes `safe_writes`, so the
`mononoke-buck` build is broken as a result. This fixes that.

I also noticed a build warning (unused future) while checking that the build
was fixed, so I also fixed that.

Reviewed By: ikostia, StanislavGlebik

Differential Revision: D17257765

fbshipit-source-id: 47ac7e46b5263878f8aa7fd3e3326e356fecbbe6
2019-09-09 02:47:15 -07:00
Stanislau Hlebik
55d702aba5 mononoke: add new_from_raw_list to FastlogBatch
Summary:
Let's make a function that creates FastlogBatch smarter - it now makes sure
that size of `latest` and `previous_batches` fields is bounded.

It will be useful in the next diffs where I add support for handling merge
commits.

Reviewed By: krallin

Differential Revision: D17181156

fbshipit-source-id: 8c058cd39abf51f3bc1ebdbe76a5bb3e1b001f98
2019-09-06 09:13:59 -07:00
Stanislau Hlebik
52ac64cbe3 mononoke: find modified unodes in merge commits
Summary:
This is the first step in supporting merges in apiserver's fastlog.

To generate FastlogBatches we need to find unodes that were modified.
For a commit with single parent it's just a diff between this commit and it's
parent.

That would work for merges as well, however it might do unnecessary work.
For example, let's say first parent introduced file A, second parent introduced
file B. Diff between merge commit and first parent would return file B, and
we'd try to generate FastlogBatch for it even though this FastlogBatch is
already generated. That might be a problem in case of big merges.

To avoid this problem let's filter out unodes that exist in any of the parents.

Reviewed By: krallin

Differential Revision: D17180324

fbshipit-source-id: ecfa6748937159fdcdab9c7f08d964230f87739a
2019-09-06 09:13:58 -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
Thomas Orozco
0e62edbd3c mononoke/multiplexedblob: log canary id
Summary: This makes it easier to measure performance differences across canary runs.

Reviewed By: StanislavGlebik

Differential Revision: D17225082

fbshipit-source-id: bfabfddaaaca711ed4f973bfbcdd93d618f90b33
2019-09-06 07:17:45 -07:00
Kostia Balytskyi
1ece1d8688 mononoke: add a tool for megarepo manipulations
Reviewed By: StanislavGlebik

Differential Revision: D17181600

fbshipit-source-id: 87565ac13f8bca36a65a09c0a6169c3dcf692ff9
2019-09-06 05:28:18 -07:00
Mark Thomas
3a124c9d82 debugmutation: improve format and render successors
Summary:
Update the debugmutation format to collapse long chains.  Add
`hg debugmutation -s` to follow the successor relationship (printing what the
commit became) instead of the predecessor relationship.

Reviewed By: mitrandir77

Differential Revision: D17156463

fbshipit-source-id: 44a68692e3bdea6a2fe2ef9f53b533199136eab1
2019-09-06 00:42:03 -07:00
Aida Getoeva
284acf32f4 mononoke: add get_last_commit_on_path method to the API
Summary: `get_last_commit_on_path` - new implementation of the [SCMQuery `last_commit_on_path`](https://our.intern.facebook.com/intern/diffusion/FBS/browse/master/fbcode/scm/scmquery/server/server.py?commit=4a9599e3674b5be886f4ef40f640eadfad46ed19&lines=850) based on Unodes

Reviewed By: StanislavGlebik

Differential Revision: D17094912

fbshipit-source-id: 5d42c955743abe7ad2bdd5265f7e9fdd7c24aef7
2019-09-05 13:54:57 -07:00
Daniel Grzegorzewski
94f41ba5aa Added option to use reponame insted of repo-id
Summary: Currently in mononoke_admin tool we have to use repo-id to identify repository. Sometimes it can be inconvenient. Changed it, so we can use either repo-id or reponame.

Reviewed By: StanislavGlebik

Differential Revision: D17202962

fbshipit-source-id: d33ad55f53c839afc70e42c26501ecd4421e32c0
2019-09-05 09:36:27 -07:00
Stanislau Hlebik
6e0bb66ec6 mononoke: remove unnecessary diff logic in apiserver
Summary:
ManifestOps::diff() returns empty stream if entries are the same and it
returns root difectory if entries are not the same.

No need to repeat this logic here

Reviewed By: krallin

Differential Revision: D17179427

fbshipit-source-id: 54a6c83bf35883cf57ba385ea17bc2e51c0cc71e
2019-09-05 09:16:18 -07:00
Kostia Balytskyi
7c66fc1fff mononoke: bump getbundle timeout to 30 minutes
Reviewed By: krallin

Differential Revision: D17204083

fbshipit-source-id: c95b757f0901700767a49a24b38821f863a65907
2019-09-05 05:38:30 -07:00
Stanislau Hlebik
6ae42d120e mononoke-apiserver: bookmark cache with generated derived data
Summary:
Apiserver response can be slow, and we've noticed that it's often caused by
derived data generation (e.g. unodes and hg changesets). Usually that happens
when request to "master" bookmark is sent.

This diff trade offs staleness of bookmarks with latency of read path. Instead
of reading bookmarks from repo object directly let's keep in-memory cache which
is updated only after all derived data is generated.

Reviewed By: aslpavel

Differential Revision: D17201325

fbshipit-source-id: 4e9efab4e42b9eddc22fd37fa2122c6615ad086f
2019-09-05 04:29:19 -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
Pavel Aslanov
e32ad7b25d extend benchmark to support unodes
Summary: Extend benchmark to support unodes

Reviewed By: StanislavGlebik

Differential Revision: D17162863

fbshipit-source-id: f87f7604274b25443b8fa9d9bd8328d7b7af0dc8
2019-09-04 04:01:31 -07:00
Daniel Grzegorzewski
34e2ed6901 Changed deprecated futures::finished/failed to futures::future::ok/err
Reviewed By: krallin

Differential Revision: D17163207

fbshipit-source-id: f4e45631856cf7395b5aabdcdc178a4be35e436d
2019-09-03 08:10:48 -07:00
Stanislau Hlebik
6e6e1491c7 mononoke: move FastlogBatch/FastlogBatchId to mononoke_types
Summary: Mainly addressing comments from D17153209

Reviewed By: aslpavel

Differential Revision: D17161355

fbshipit-source-id: b1b30e49929bfb174dab0f432ac13349c4288188
2019-09-03 07:30:55 -07:00
Stanislau Hlebik
5f500b09d5 mononoke: fix fastlog batching for empty commits
Summary:
I ran into a tricky case while deriving FastlogBatch for empty commits:
* If a commit is empty then new unode manifest is not created [1]
* But FastlogBatch's derived data logic was still creating a new FastlogBatch.
This batch would point not to the commit that created the unode, but to the
latest empty commit.

This is obviously not a huge deal because it affects only root entry only for
empty commits. But it can be confusing and tricky to investigate, so I think
it's better to fix it.

[1] There is one exception - empty commit with no parents

Reviewed By: krallin

Differential Revision: D17160654

fbshipit-source-id: 949d35860efe2f3df6ec1c11b4c6c4d077982c95
2019-09-03 07:30:55 -07:00
Stanislau Hlebik
f50e19a70e mononoke: compress file history
Summary:
This diff adds handling of "overflows" i.e. making sure that each FastlogBatch
doesn't store more than 60 entries.
The idea is that FastlogBatch has "latest" entries and "previous_batches". New
entry is prepended to "latest", but if "latest" has more than 10 entries then
new FastlogBatch is uploaded and prepended to "previous_batches". If
"previous_batches" has more than 5 entries than the oldest entries is removed
from the batch.

Note that merges are still not handled in this diff, this functionality will be added in the next
diffs

Reviewed By: krallin

Differential Revision: D17160506

fbshipit-source-id: 956bc5320667c6c5511d2a567740a4f6ebd8ac1b
2019-09-03 07:30:55 -07:00
Stanislau Hlebik
0a317d9ea2 mononoke: add Storable/Loadable for FastlogBatch
Reviewed By: aslpavel

Differential Revision: D17153209

fbshipit-source-id: 9c3a8c28490aa698979f61bba5fc99584f8fb8e2
2019-09-03 07:30:54 -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
Stanislau Hlebik
31b9b4eca7 mononoke: implement fastlog batching for files with linear history
Summary:
This diff adds batching of linear file or directory history (i.e. no merges).

Note that it still doesn't handle "overflows" i.e. FastlogBatch is not yet
compressed if it has too many entries. This will be added in the next diffs

Reviewed By: krallin

Differential Revision: D17152698

fbshipit-source-id: 05706444bcdcdb5ed0fd453c5c0684f8911603c6
2019-09-03 04:29:33 -07:00
Stanislau Hlebik
00f4165a22 mononoke: initial diff for history batching
Summary:
In order to answer file history requests history we need to avoid doing serial
fetches from a blobstore.

This diff is a first attempt in implementing it. The general idea is to store precalculated history in the blobstore.
Note that at the moment it covers only the very basic case - file history for a commit with no parents, so there's quite a few "TODOs" and "unimplemented!()" in the codebase. This functionality will be extended in the next diffs

Reviewed By: krallin

Differential Revision: D17070901

fbshipit-source-id: 8150afb2509fcd2a428d2369bab58468ab774d72
2019-09-03 04:29:33 -07:00
Stanislau Hlebik
90a4d40551 mononoke: do not generate hgchangeset unnecessarily
Summary:
We were generating hgchangesets in list_directory_unodes() method, however this
is not always necessary - if a client sends a bookmark then we can fetch bonsai
changesets and generate unodes directly bypassing hg changeset generation stage.
Same goes for is_ancestor method.

Reviewed By: krallin

Differential Revision: D17146609

fbshipit-source-id: 9613e28f8bacbce5d8de94a6ab88b152d19b0a08
2019-09-02 04:18:16 -07:00
Pavel Aslanov
f43b19c431 remove not needed BlobRepo::*{store|fetch} methods
Summary: `BlobRepo::*{store|fetch}` methods are subsumed by `Storable|Loadable`

Reviewed By: krallin

Differential Revision: D17133306

fbshipit-source-id: 6379aea6335d57f0d90a9669ba5ef0300f82a399
2019-08-30 13:34:29 -07:00