Commit Graph

424 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Pavel Aslanov
3b6081a6f5 make it possible to enable bookmark cache from configs
Summary: Now it is possible to configure and enable/disable bookmark cache from configs

Reviewed By: StanislavGlebik

Differential Revision: D14952840

fbshipit-source-id: 3080f7ca4639da00d413a949547705ad480772f7
2019-05-21 12:25:22 -07:00
Stanislau Hlebik
1d9039751a mononoke: add memcache leases
Summary:
Generating hg changesets might create too many connections to mysql. Let's
how many hg changesets generation we have in-flight

Reviewed By: lukaspiatkowski

Differential Revision: D15069236

fbshipit-source-id: 2b7265d1efa7d09458ed214bad7bc6f32bda8dbf
2019-05-21 12:25:21 -07:00
Stanislau Hlebik
2acbc38df7 mononoke: refactoring to make using memcache leases
Summary:
We'll start using memcache leases in the next diff, this diff refactors the
code to make it adding memcache leases simpler

Reviewed By: lukaspiatkowski

Differential Revision: D15069237

fbshipit-source-id: 875c398a3825d839b3453a9c77043edec496efa2
2019-05-21 12:25:20 -07:00
Stanislau Hlebik
a9ac9c0c20 mononoke: add logging of latency and depth to generate hg_from_bonsai
Summary:
Add more logging for generation of hg changesets from bonsai. We are interested
in depth (i.e. how many commits it had to generate), latency of the whole
request and latency of generation of a single hg changeset.

Reviewed By: ikostia

Differential Revision: D15046567

fbshipit-source-id: 1e9b0471fa5ed7df3d492c11bf230adc7ee0c1b8
2019-05-21 12:25:17 -07:00
Stanislau Hlebik
701a08a4c0 mononoke: include deleted files in the list of changed files
Summary: Turns out mercurial always includes deleted files

Reviewed By: farnz

Differential Revision: D15034961

fbshipit-source-id: 33e6ffe098b74a177346ff913d66d3ddf6e95eff
2019-05-21 12:25:17 -07:00
Stanislau Hlebik
869367c565 mononoke: remove unused get_bookmarks
Reviewed By: farnz

Differential Revision: D15018616

fbshipit-source-id: 8e0374a61dbad531ac885a86e02efd9d5a9a9d40
2019-05-21 12:25:15 -07:00
Stanislau Hlebik
e7719effbc mononoke: ods log when hg was generated from bonsai
Reviewed By: jsgf

Differential Revision: D15018615

fbshipit-source-id: 6e33f039ba774cb5e397f753b718fd316ea8f347
2019-05-21 12:25:15 -07:00
Jeremy Fitzhardinge
e97860a4d7 mononoke/blobstore factory: remove unused new_rocksdb_delayed, and unpub others
Summary:
`new_rocksdb_delayed` wasn't used at all, and the other
`new_files`/`rocksdb`/`sqlite` aren't used anywhere else, so make them private.

Reviewed By: StanislavGlebik

Differential Revision: D14862288

fbshipit-source-id: 41e02804fca37f4f27dddd53ee27e60b43798a99
2019-05-21 12:25:12 -07:00
Arun Kulshreshtha
2234c8616f Add method to get file parents to BlobRepo
Summary: We need a way to get the parents of a given filenode in the API server. Since this functionality is not presently available on BlobRepo, this diff adds a new method to fetch the parents.

Reviewed By: quark-zju

Differential Revision: D14907956

fbshipit-source-id: 66dc10793b192e6912af8c7fb31d7d7d6fcd6317
2019-05-21 12:25:11 -07:00
Thomas Orozco
cf6cd664fa remove HgNodeHash from HgChangesetEnvelopeMut
Summary: This removes HgNodeHash (and uses HgChangesetId instead) in HgChangesetEnvelopeMut.

Reviewed By: StanislavGlebik

Differential Revision: D14855029

fbshipit-source-id: c1f343870e18266ae3e636c1b36dfa05fce00bd3
2019-05-21 12:25:06 -07:00
Pavel Aslanov
a257f82f7c remove some extern crates and #[macro_use]
Summary:
Convert to `2018` version and remove `#[macro_use]` and `extern crate` from following folders:
- blobrepo
- blobstore
- mercurial_types
- mononoke_types

Reviewed By: StanislavGlebik

Differential Revision: D14827294

fbshipit-source-id: 4b8a2edb5d9ad1fe75083e172cd0da359fa6dc2e
2019-05-21 12:25:03 -07:00
Pavel Aslanov
1ba56177c4 implementation of listkeyspatterns wire protocol command
Summary: add support for `listkeyspattern` write protocol command

Reviewed By: StanislavGlebik

Differential Revision: D14727722

fbshipit-source-id: d0883d26109c70f8f5fcd1f0241baab0f5002f81
2019-05-21 12:25:01 -07:00
Stanislau Hlebik
eb67262de4 mononoke: return HgEntryId in find_path_in_manifest
Summary:
It's cheap so let's return it. It will be used in the next diffs

Context:
There are some commit cloud commits that take ages to compute. For some reason
commit cloud sends too many manifests, which mononoke doesn't filter out and
does a lot of unnecessary checks, which take ages. This stack fixes it.

Reviewed By: farnz

Differential Revision: D14666306

fbshipit-source-id: 75e39f7d88e139f3558825faec5d4e94f6987050
2019-05-21 12:24:57 -07:00
Igor Abramov
1bb5f676e4 add a command to mononoke_admin to list bookmark moves log
Summary:
Add a functionality to show the log of a bookmark i.e. show previous positions of the bookmark. It should look like

mononoke_admin bookmarks log master
2d0e180d7fbec1fd9825cfb246e1fecde31d8c35 push March 18, 15:03
9740f4b7f09a8958c90dc66cbb2c79d1d7da0555 push March 17, 15:03
b05aafb29abb61f59f12fea13a907164e54ff683 manual move March 17, 15:03
...

Reviewed By: StanislavGlebik

Differential Revision: D14639245

fbshipit-source-id: 59d6a559a7ba9f9537735fa2e36fbd0f3f9db77c
2019-05-21 12:24:54 -07:00
Stanislau Hlebik
34e77e6d94 mononoke: append metadata in getpackv1
Summary:
getpackv1 needs to return copy metadata together with the content. This diff
fixes it

Reviewed By: kulshrax

Differential Revision: D14668319

fbshipit-source-id: 56a6ea2eb3a116433446773fa4fbe1f5a66c5746
2019-05-21 12:24:53 -07:00
Laurence Emms
491abcd4a8 Removed HgNodeHash from known()/lookup()/heads()/between() methods in
Summary:
Removed references to HgNodeHash in repo_client in the specified functions. In
addition, updated other files due to type related dependencies.

Reviewed By: StanislavGlebik

Differential Revision: D14543934

fbshipit-source-id: b0d860fe7085ed4b91a62ab1e27fb2907a642a1d
2019-05-21 12:24:52 -07:00
Jeremy Fitzhardinge
d76d128059 mononoke: move memblob and prefixblob out of the base blobstore crate
Summary: Slim down the blobstore trait crate as much as possible.

Reviewed By: aslpavel

Differential Revision: D14542675

fbshipit-source-id: faf09255f7fe2236a491742cd836226474f5967c
2019-03-25 12:34:36 -07:00
Stanislau Hlebik
a98f532abd mononoke: fix of the discovery problem
Summary:
This is the test to cover tricky case in the discovery logic.
Previously Mononoke's known() wireproto method returned `true` for both public
and draft commits. The problem was in that it affects pushrebase.

There are a few problems with the current setup. A push command like `hg push
-r HASH --to BOOK` may actually do two things - it can either move a bookmark
on the server or do a pushrebase. What it does depends on how discovery phase
of the push finishes.

Each `hg push` starts with a discovery algorithm that tries to figure out what commits
to send to the server. If client decides that server already has all the
commits then it'll just move the bookmark, otherwise it'll run the pushrebase.

During discovery client sends wireproto `known()` method to the server
with a list of commit hashes, and server returns a list of booleans telling if
a server knows the commit or not. Before this diff Mononoke returned true for
both draft commits and public commits, while Mercurial returned true it only
for public commits.

So if Mononoke already has a draft commit (it might have it because the commit was created
via `hg pushbackup` or was created in the previous unsuccessful push attempt),
then hg client discovery will decide to move a bookmark instead of
pushrebasing, which in the case of master bookmark might have disastrous
consequences.

To fix it let's  return false for draft commits, and also implement `knownnodes` which return true for draft commits (a better name for these methods would be `knownpublic` and `known`).

Note though that in order to trigger the problem the position of the bookmark on the server
should be different from the position of the bookmark on the client. This is
because of short-circuting in the hg client discovery logic (see
https://fburl.com/s5r76yle).

The potential downside of the change is that we'll fetch bookmarks more often,
but we'll add bookmark cache later if necessary.

Reviewed By: ikostia

Differential Revision: D14560355

fbshipit-source-id: b943714199576e14a32e87f325ae8059d95cb8ed
2019-03-25 02:20:53 -07:00
Harvey Hunt
3d724de339 mononoke: Allow dynamic repo read_only mode
Summary:
Allow using a database entry to determine if a repository
is in read-only mode.

If a repo is marked read/write in the config then we will communicate with the db.

Reviewed By: ikostia

Differential Revision: D14279170

fbshipit-source-id: 57abd597f939e57f274079011d2fdcc7e7037854
2019-03-18 08:53:53 -07:00
David Budischek
7b92ba7c25 Remove logging to scribe from blobrepo
Summary: See D14279065, this diff is simply to clean up the deprecated code

Reviewed By: StanislavGlebik

Differential Revision: D14279210

fbshipit-source-id: 10801fb04ad533a80bb7a2f9dcdf3ee5906aa68d
2019-03-12 04:50:45 -07:00
Stanislau Hlebik
e6c8ef00aa mononoke: fix computing of changed files
Summary:
The problem was in using `file_changes()` of a bonsai object. If a file
replaces a directory, then it just returns an added file, but not a removed
directory.

However `changed_entry_stream` didn't return an entry if just it's mode was changed (i.e. file became executable, or file became a symlink). This diff fixes it as well

Let's use the same computing changing files method instead of `file_changes()`.

Differential Revision: D14279470

fbshipit-source-id: 976b0abd93646f7d68137c83cb07a8564922ce17
2019-03-08 06:28:49 -08:00
Kostia Balytskyi
e561682ecd mononoke: rename crates to contain underscores instead of dashes
Summary: Let's not use dashes in crate names.

Reviewed By: StanislavGlebik

Differential Revision: D14341596

fbshipit-source-id: 85a7ded60cf2e326997ac70ee47a29116af97590
2019-03-06 07:18:28 -08:00
Stanislau Hlebik
94dcd8203c mononoke: change compute_changed_files
Summary:
Make compute_changed_files accept manifest id, it will be used in the next
diffs

Differential Revision: D14279468

fbshipit-source-id: eca92900ed8862bb6db38ff6c5ed5372d8206aa9
2019-03-04 06:18:13 -08:00
Stanislau Hlebik
0c5df091ea mononoke: rustfmt
Differential Revision: D14299676

fbshipit-source-id: 5da8769ef718abb44bbe65b5c670f5be13327359
2019-03-04 06:18:13 -08:00
Stanislau Hlebik
5951aaaac2 mononoke: rename p0/p1 to p1/p2
Summary: p1/p2 is more common, let's use that

Differential Revision: D14279469

fbshipit-source-id: 60c81e383cdbfeb2c9c0b30a682e37775c29d4e3
2019-03-04 06:18:13 -08:00
Stanislau Hlebik
25ad4aebf6 mononoke: fix combinatorial explosion when creating commits for mergy repos
Summary:
Some repos that are not that  big but they have a lot of merges
And sometimes there are a lot of merges where one merge parent
is ancestor of another merge parent, see example below:

  o  <- A
  |\
  | o <- B
  |/|
  o | <- C
  |\|
  | o
  |/|
  o |
  |\|
  ...
  |/|
  | ~
  o
  |\
  ~ ~

Turned out in the cases like that blobimport or push can hit a combinatorial explosion.
See an example. Commit A depends on commit B and C. So a future that creates a commit A also
need to wait until commit B and commit C are created i.e. roughly future for commit A looks like
`B.join(C).and_then(...)`. So when future A is polled it polls future B and after it polls future C.
The problem is that future B also polls future C and they do so all the way
down. So we poll every future a lot of times even when it's completely unnecessary.
This is similar to doing DFS without remembering visited nodes. In that case
event loop spends all the time polling nodes over and over again.

Note that combinatorial explosion depends and how many in-flight futures we
have. For example, reducing the number of commits that are computed simultaneously
(see `CONCURRENT_CHANGESETS` parameter of blobimport) avoids the issue, but
obviously it slows down blobimport for "normal" non-mergy repos. It's also
harder to repro in debug mode.

Differential Revision: D14100259

fbshipit-source-id: 8bcbc34a2843477f3704eb43cf5876e16ad4be61
2019-02-27 04:31:56 -08:00
David Budischek
79cbf5c245 post-commit send scribe message
Summary: New commits should be logged to scribe, these will be used to trigger the update for the hg clone streamfile.

Reviewed By: lukaspiatkowski

Differential Revision: D14022599

fbshipit-source-id: a8a68f12a8dc1e65663d1ccf1a5eafa54ca2daf0
2019-02-13 07:26:33 -08:00
Kostia Balytskyi
19f4c1cd8d mononoke: add a no-op code to preserve raw bundle2 contents in the blobstore
Summary:
This diff does not change anything on it's own, but rather adds the not
reachable (but already somewhat tested) code to preserve bundles when doing
pushes and pushrebases.

I want to land it now so that conflict resolution is easier.

Reviewed By: StanislavGlebik

Differential Revision: D14001738

fbshipit-source-id: e3279bc34946400210d8d013910e28f8d519a5f8
2019-02-11 14:48:37 -08:00
Lukas Piatkowski
c163368a07 blobrepo/src/file.rs: use HgFileNodeId instead of HgNodeHash and propagate it
Summary: HgFileNodeId is a stronger typed id, so it is prefered to use it instead of HgNodeHash whenever it is identifying a filenode

Reviewed By: aslpavel

Differential Revision: D13986172

fbshipit-source-id: c0334652345acb868e86c38b8c0045e9c023c176
2019-02-07 04:04:28 -08:00
Lukas Piatkowski
515a2909eb monononoke hashes: remove usages of borrows of hashes which are Copy
Summary: The Copy trait means that something is so cheap to copy that you don't even need to explicitly do `.clone()` on it. As it doesn't make much sense to pass &i64 it also doesn't make much sense to pass &<Something that is Copy>, so I have removed all the occurences of passing one of ouf hashes that are Copy.

Reviewed By: fanzeyi

Differential Revision: D13974622

fbshipit-source-id: 89efc1c1e29269cc2e77dcb124964265c344f519
2019-02-06 15:11:35 -08:00
Jeremy Fitzhardinge
b4dc225420 mononoke: split complex stuff out of blobstore crate
Summary: Move complex things out of `blobstore` to thin out the dep graph. This didn't work as well as I'd hoped because `blobstore`->`mononoke-types`->`thrift`/`sql`.

Reviewed By: StanislavGlebik

Differential Revision: D13915511

fbshipit-source-id: c210dda23fa7102168c0ca14a035ed5c03a6993c
2019-02-05 15:21:15 -08:00
Jeremy Fitzhardinge
a756ebe1ed mononoke: blobrepo -> Rust 2018
Reviewed By: StanislavGlebik

Differential Revision: D13915512

fbshipit-source-id: 8ba90fc254fd1b74508478bcbe0d796ad69ab8cf
2019-02-05 15:21:15 -08:00
Stanislau Hlebik
3b295d0724 mononoke: extract 2 crates from bundle2-resolver
Summary:
bundle2-resolver crate is huge and takes ages to compile. By extracting
independent parts like pushrebase and wirepack parser we can decrease
compilation time

Reviewed By: jsgf

Differential Revision: D13901610

fbshipit-source-id: d9608079e681d03f48fc412394cd218c4d208a01
2019-02-05 01:23:15 -08:00
Stanislau Hlebik
0b0a5b93b2 mononoke: extract blobrepo_factory and postcommit from blobrepo
Summary:
`blobrepo_factory` is a crate that knows how to create blobrepo given
a configuration i.e. it creates blobstores, filenodes, changesets etc and
initializes blobrepo with them.

`post_commit` is a small part of blobrepo which can also be extracted from
blobrepo crate.

There are a few upsides with this approach
1) Less dependencies on Blobrepo, meaning we have to rebuild it fewer times
2) BlobRepo compilation is faster

Reviewed By: jsgf

Differential Revision: D13896334

fbshipit-source-id: 1f5701341f01fcefff4e5f9430ddc914b9496064
2019-02-05 01:23:15 -08:00
Stanislau Hlebik
3d06332693 mononoke: move changeset_fetcher out of blobrepo into separate crate
Summary:
Some crates, namely revsets and reachabilityindex, currently depend on
blobrepo, while all they need is the ability to fetch commits.

By moving changeset_fetcher outside this dependency will be removed. That may
make builds faster

Reviewed By: lukaspiatkowski

Differential Revision: D13878369

fbshipit-source-id: 9ee8973a9170557a4dede5404dd374aa4a000405
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
6bcddad1a6 mononoke: blobrepo errors & blob-changeset to a separate crates
Summary:
Hook manager depends on blob changeset, but it needs nothing else from
BlobRepo. Let's move it to separate crate. That also requires moving errors to
a separate crate, and that will also help with removing dependence from
skiplist to Blobrepo.

Reviewed By: lukaspiatkowski

Differential Revision: D13878207

fbshipit-source-id: 479716497f5af2da0265340cea1d44de47a3e03a
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
4d48415149 mononoke: split metaconfig crate
Summary:
Currently if a crate depends even on a single type from metaconfig then in
order to compile this trait buck first compiles metaconfig crate with all the
logic of parsing the configs.

This diff split metaconfig into two crates. The first one just holds the types for
"external consumption" by other crates. The second holds the parsing logic.

That makes builds faster

Reviewed By: jsgf, lukaspiatkowski

Differential Revision: D13877592

fbshipit-source-id: f353fb2d1737845bf1fa0de515ff8ef131020063
2019-01-31 00:41:48 -08:00
Stanislau Hlebik
a055f8e409 mononoke: move open_blobrepo to blobrepo crate and remove TestDelay blobrepo type
Summary:
The main reason to do it is to remove dependency from cmdlib to repo_client.
repo_client depends on a lot of other crates like bundle2-resolver, hooks etc.
And it means that in order to compile mononoke_admin we need to compile these
crates too. By moving open_blobrepo into blobrepo crate we are removing
unnecessary dependencies.

Also let's remove unused blobrepo type

Reviewed By: aslpavel

Differential Revision: D13848878

fbshipit-source-id: cd3d04354649cdb5b2947f08762051318725c781
2019-01-30 06:31:10 -08:00
David Budischek
1945a8aa6c Fetch HgChangesets asynchronously
Summary: The first request was way too slow as the cache was not yet warm. This speeds up the initial request substentially.

Reviewed By: StanislavGlebik

Differential Revision: D13817064

fbshipit-source-id: 0f2a01395743ef848e6bc4a5e71c0562b268c0cf
2019-01-29 03:42:28 -08:00
Stanislau Hlebik
67f220c89c mononoke: fix pushrebasing an empty commit
Summary:
Previously pushrebasing an empty commit failed because we assumed that root
manifest of a commit is always sent in a bundle. This diff removes this
assumption

Reviewed By: lukaspiatkowski

Differential Revision: D13818556

fbshipit-source-id: 44e96374ae343074f48e42a90c691b21e3c41386
2019-01-28 14:40:40 -08:00
Liubov Dmitrieva
23b3931529 add phases calculation for public roots
Summary:
this is required to cover corner cases when client has some stacks and part of those became public

calculation for public roots happen for draft heads only, it doesn't change performance of hg pull

Reviewed By: StanislavGlebik

Differential Revision: D13742685

fbshipit-source-id: d8c8bc357628b9b513bbfad4a82a7220d143f364
2019-01-22 05:58:46 -08:00
Pavel Aslanov
3a44162690 added: multiplexed blobstore scuba logging
Summary:
- Added scuba logging for put/get operation of `MultiplexedBlobstore`
- Added `blobstore_scuba_table` configuration field

Reviewed By: StanislavGlebik

Differential Revision: D13732064

fbshipit-source-id: 9ac0e31f9e1773321b2a7a4d8d561cce9289944b
2019-01-21 10:04:41 -08:00
Stanislau Hlebik
432138ac93 mononoke: remove CachingChangesets
Summary:
There is no much point in keeping since we have skiplist which should solve the
same problems in a better way.

The only way where CachingChangesets maybe useful is when many users fetch a
lot of commits simultaneously. It may happen when we merge a new big repository.
However current implementation of CachingChangesets won't help with it since we
do not update its indexes.

Reviewed By: lukaspiatkowski

Differential Revision: D13695201

fbshipit-source-id: 2a4600eccf8224453ca13047e5a2ef3a0af650e3
2019-01-17 02:33:35 -08:00
Stanislau Hlebik
8ef5d4ba64 mononoke: change the way file content blobs are hashed
Summary:
File content blobs are thrift encoded in Mononoke. This is done so
that we can change the encoding of content blobs easily. For example, we can
add compression or we can add split the blobs in chunks.

However there is a problem. At the moment file content blob key is a hash of
the actual data that's written to blobstore i.e. of a thrift encoded data. That
means that if we add compression or change thrift encoding in any way, then the
file content blob key changes and it changes the commit hashes.

This is wrong. To fix it let's use hash of the actual file content as the key.

Reviewed By: farnz

Differential Revision: D12884898

fbshipit-source-id: e60a7b326c39dad86e2b26c6f637defcb0acc8e8
2019-01-17 02:33:35 -08:00
Liubov Dmitrieva
fd7345bc58 calculate phases using bulk API
Summary:
The bulk api makes less queries to mysql and therefore is more efficient.

This is especially important for `hg pull` requests where the list of heads is very large.

Reviewed By: lukaspiatkowski

Differential Revision: D13677298

fbshipit-source-id: 3dec1b3462c520c11481325e82523ef7a6ae6516
2019-01-16 08:22:54 -08:00
Lukas Piatkowski
eba422a209 blobstore healer: minimalistic implementation
Summary:
This version still misses:
- proper production-ready logging
- smarter handling of case where the queue entries related to each other do not fit in the limit or `older_than` limit, so the healer will heal much more entries without realizing it shouldn't do so.

Reviewed By: aslpavel

Differential Revision: D13528686

fbshipit-source-id: 0245becea7e4f0ac69383a7885ff3746d81c4add
2019-01-15 10:41:07 -08:00
Lukas Piatkowski
b9ecb39676 sqlblob: add support for MyRouter
Reviewed By: StanislavGlebik

Differential Revision: D13465323

fbshipit-source-id: a9d6b7626617fcd85d91b4118b22ad9a7db3aa32
2019-01-15 09:38:26 -08:00
Lukas Piatkowski
b36dd037ad sqlblob: initial implementation of the sql based blobstore
Summary: MyRouter and cache support will come in next diffs

Reviewed By: StanislavGlebik

Differential Revision: D13465146

fbshipit-source-id: 0ede0e875d4a49794ff71173bd0d1563abb3ff08
2019-01-15 07:05:33 -08:00
Pavel Aslanov
1eea4fdb09 asynchronous blobrepo constructor
Summary:
- Support for gluster blubstore
- Asynchronous blobrepo constructor

Reviewed By: StanislavGlebik

Differential Revision: D13630033

fbshipit-source-id: 3e7f5a7be4451063dca3df2f5a7f70d30a2def58
2019-01-14 09:31:58 -08:00
Pavel Aslanov
2efacff245 rustfmt effected files
Summary: Format files effected by next commit in a stack

Reviewed By: StanislavGlebik

Differential Revision: D13650639

fbshipit-source-id: d4e37acd2bcd29b291968a529543c202f6944e1a
2019-01-14 09:31:58 -08:00
Kostia Balytskyi
ede7fd7185 mononoke: back out shared-future-based bookmark cache
Summary:
It breaks the pushrebase test.

Original commit: 4e084bee13ff4941d1a42d1f75fe501575858a63
Original diff: D13573105

Reviewed By: StanislavGlebik

Differential Revision: D13651039

fbshipit-source-id: b67c32e0fc4acc953265a089e746ede3d4426b6f
2019-01-14 07:09:23 -08:00
Kostia Balytskyi
013318ee87 mononoke: shared future bookmarks cache
Summary:
After some discussion with Pavel Aslanov, Lukas Piatkowski and Stanislau Hlebik, it was evident that shared future is the best approach for the bookmarks cache.

The cache in this implementation maintains a shared future for each repo, fetching the full list of bookmarks. When a list of bookmarks with a  given prefix is required, a filter is applied to a full list future.

Two locks are used in this implementation: one for adding new repos to the hashtable and one for updating the cache. In both cases the optimistic strategy: "let's first first grab a read  lock and try checking if it is good enough" is applied.

Reviewed By: StanislavGlebik

Differential Revision: D13573105

fbshipit-source-id: 4e084bee13ff4941d1a42d1f75fe501575858a63
2019-01-11 10:20:34 -08:00
Lukas Piatkowski
813375d66a blobimport: add tracing and uploading traces on every blobimport run
Reviewed By: StanislavGlebik

Differential Revision: D13464745

fbshipit-source-id: 3e2ca21e70089c88a8c510cec1de2f20054a444b
2019-01-08 11:03:32 -08:00
Mark Thomas
20ccd1216f don't store filenodes for draft commits in the filenodes table
Summary:
When receiving and infinitepush bundle, don't store the filenodes for the
commit in the filenodes table.

When a client pulls these commits, we will reconstruct the filenode info from
the blobstore data.  However, they will receive null linknodes, and will need
to use adjustlinknode to compute the correct linknode.

Reviewed By: StanislavGlebik

Differential Revision: D13467110

fbshipit-source-id: 739b06f30a530a159352ffbf612d136c9c831aeb
2019-01-04 03:12:57 -08:00
Mark Thomas
76bce93083 return null linknodes if filenodeinfo is not available
Summary:
For draft commits we will stop storing the filenodeinfo for filenodes
introduced by that commit in the database.  This means the filenodeinfo lookup
may fail.  For these cases, reconstruct the filenodeinfo from the blob in the
blobstore, setting the missing linknode to the null changeset id.

Reviewed By: StanislavGlebik

Differential Revision: D13467112

fbshipit-source-id: 27ad406723a6affd80e7c3b2dc538b03004451ec
2019-01-04 03:12:57 -08:00
Jeremy Fitzhardinge
408e7665d9 mononoke: move RepositoryId into mononoke-types
Summary: There's nothing Mercurial-specific about identifying a repo. This also outright removes some dependencies on mercurial-types.

Reviewed By: StanislavGlebik

Differential Revision: D13512616

fbshipit-source-id: 4496a93a8d4e56cd6ca319dfd8effc71e694ff3e
2018-12-19 10:24:27 -08:00
Pavel Aslanov
eb75d48a95 correctly handle configurations with multiple blobstores
Summary: Correctly handle repository with multiple blobstores

Reviewed By: StanislavGlebik

Differential Revision: D13434206

fbshipit-source-id: f4ab70ec037deba150ed5c1ee8e53d23317b8e09
2018-12-18 06:55:56 -08:00
Liubov Dmitrieva
e75e5576a9 add get_bookmarks api for blobrepo
Summary: similar to get_bookmarks_maybe_stale but read from master db

Reviewed By: markbt

Differential Revision: D13417055

fbshipit-source-id: 805cbe3953a6c0a2380c0168eb403c6e9e0551c9
2018-12-13 11:51:34 -08:00
Stanislau Hlebik
ed3a163b7c mononoke: remove get_changesets method
Summary: It's useless

Reviewed By: HarveyHunt

Differential Revision: D13305842

fbshipit-source-id: 72426e92ab9e2a4c3795a70f6fac0100f1e0375c
2018-12-06 10:22:15 -08:00
Stanislau Hlebik
706e98799b mononoke: support many blobstores in metaconfig
Summary: Restructure the configs so that we can specify more than one blobstore

Reviewed By: lukaspiatkowski

Differential Revision: D13234286

fbshipit-source-id: a98ede17921ed6148add570288ac23636b086398
2018-12-05 05:58:07 -08:00
Lukas Piatkowski
5d9a151d85 mononoke: pass CoreContext down to blobstore
Reviewed By: jsgf

Differential Revision: D13324220

fbshipit-source-id: af7a2a650338ea66e504ea0acae1d103af10f8e3
2018-12-04 11:40:15 -08:00
Stanislau Hlebik
04fb5f514b mononoke: reverse dependencies between BlobRepo and metaconfig
Summary:
Previously metaconfig depended on BlobRepo, and so ManifoldArgs had to be
definided in BlobRepo. That was an weird dependency, but a necessary one
because of Mononoke config repo. In the previous diffs we got rid of the
Mononoke config repo, so now we can reverse the dependencies.

Reviewed By: lukaspiatkowski

Differential Revision: D13180160

fbshipit-source-id: efe713ce3b160c98d56fc13559c57a920146841f
2018-12-04 03:52:26 -08:00
Lukas Piatkowski
d8476a6527 mononoke: pass CoreContext down to filenodes
Reviewed By: StanislavGlebik

Differential Revision: D13304158

fbshipit-source-id: d73597ed64822d7a986f6a8d46a96cfbbe99a8e7
2018-12-04 01:16:32 -08:00
Lukas Piatkowski
02e79837a4 mononoke: pass CoreContext down to bookmarks
Reviewed By: StanislavGlebik

Differential Revision: D13302943

fbshipit-source-id: 356ec3cd3c47f843a5869edb7079d4cbd0ee33aa
2018-12-04 01:16:32 -08:00
Jeremy Fitzhardinge
ec86d453ae rust/stats: don't require users to import lazy_static
Summary:
Now that Rust macros can be `use`d like normal symbols, `stats` can
simply import the `lazy_static!` macro without requiring its users to do it.

Reviewed By: Imxset21

Differential Revision: D13281897

fbshipit-source-id: a6780fbace07dd784308e642d4a384322a17c367
2018-12-02 14:34:39 -08:00
Lukas Piatkowski
14636545aa mononoke: pass CoreContext down to changesets
Reviewed By: StanislavGlebik

Differential Revision: D13277448

fbshipit-source-id: 6e9a8dac77af8ab991005d14f654e315c234fe44
2018-11-30 10:14:22 -08:00
Lukas Piatkowski
08db0a35eb mononoke: pass CoreContext down to bonsai-hg-mapping
Reviewed By: aslpavel

Differential Revision: D13277450

fbshipit-source-id: 97cfbd917b321727bb4d960c91a784787660eb5b
2018-11-30 10:14:22 -08:00
Stanislau Hlebik
af03216ee2 mononoke: admin command to build and read skiplist indexes
Summary:
Let's add a command that builds and reads a skiplist indexes. This indexes will
be used by getbundle wireproto request to decrease the latency and cpu usage.

Note that we are saving only the longest "jump" from the skiplist. This is done
in order to save space.

Reviewed By: jsgf

Differential Revision: D13169018

fbshipit-source-id: 4d654284b0c0d8a579444816781419ba6ad86baa
2018-11-29 08:19:30 -08:00
Stanislau Hlebik
402f03056d mononoke: use ChangesetFetcher in skiplist code
Summary:
Let's make it use the same ChangesetFethcer as getbundle already does. It will
be used in the next diffs

Reviewed By: lukaspiatkowski

Differential Revision: D13122344

fbshipit-source-id: 37eba612935a209098a245f4be0af3bc18c5787e
2018-11-29 08:19:29 -08:00
Stanislau Hlebik
631556ed0d mononoke: migrate skiplist to bonsai changesets
Summary:
Most of our revsets are already migrated, let's migrate skiplists as well since
we want to use them in getbundle requests.

Reviewed By: lukaspiatkowski

Differential Revision: D13083910

fbshipit-source-id: 4c3bc40ccff95c3231c76b9e920af5db31b80d01
2018-11-29 08:19:29 -08:00
Stanislau Hlebik
cfb3dd2e15 mononoke: batching of bonsai-hg mapping request
Summary:
We've recently found that `known()` wireproto request gets much slower when we
send more traffic to Mononoke jobs. Other wireproto methods looked fine, cpu
and memory usage was fine as well.

Background: `known()` request takes a list of hg commit hashes and returns
which of them Mononoke knows about.

One thing that we've noticed is that `known()` handler sends db requests sequentially.
Experiments with sending `known()` requests with commit hashes that Mononoke
didn't know about confirmed that it's latency got higher the more parallel
requests we sent. We suspect this is because Mononoke has to send a requests to
db master, and we limit the number of master connections.

A thing that should help is batching the requests i.e. do not send many
requests asking if a single hg commit exists, but sending the same request for
many commits at once.

That change also required doing changes to the bonsai-mapping caching layer to
do batch cache requests.

Reviewed By: lukaspiatkowski

Differential Revision: D13194775

fbshipit-source-id: 47c035959c7ee12ab92e89e8e85b723cb72738ae
2018-11-27 09:40:52 -08:00
Stanislau Hlebik
e6b9f3e0f7 mononoke: read bookmarks from local replica
Summary:
Currently we read all bookmarks from primary replica a few times during `hg
pull`. First time when we do listkeys, second time when we get heads.
That might create a high load on primary replica.

However the delay between primary and secondary replicas is fairly small, and so it
*should* be fine to read bookmarks from secondary local replica as long as there is only
one replica per region (because if we have a few replicas per region, then
heads and listkeys response might be inconsistent).

Reviewed By: lukaspiatkowski

Differential Revision: D13039779

fbshipit-source-id: e1b8050f63a3a05dc6cf837e17a448c3b346b723
2018-11-23 01:19:04 -08:00
Anastasiya Zhyrkevich
d713993c60 mononoke: [lfs] upload blake2 ->sha256 mapping on fetch
Summary:
According to [Git-LFS Plan](https://www.mercurial-scm.org/wiki/LfsPlan), `getfiles` instead of file content should return file in the [following format](https://www.mercurial-scm.org/wiki/LfsPlan#Metadata_format)
```
oid: sha256.SHA256HASH
size: size_int
```

Hg client requests files using sha1 hgfilenode hash. To calculate sha256 of the content, Mononoke is fetching the file from blobstore to memory, and calculate sha256.
It does not give any profit in time and memory consumptions, comparing to non-LFS transfer of Mononoke.

*Solution:*
To put a `key-value` to blobstore, after first request of the file. This means, that after hg client requested sha256 of the file for the first time, after calculation, put it to the blobstore.
Next request of the sha256 of the file content avoid recalcualtion of sha256 in Mononoke. It return sha256 saved in the blob.

Reviewed By: StanislavGlebik

Differential Revision: D13021826

fbshipit-source-id: 692e01e212e7d716bd822fa968e87abed5103aa7
2018-11-22 10:27:46 -08:00
Anastasiya Zhyrkevich
322945ad81 get rid of hardcoded blobstore_key prefixes
Summary:
Mononoke requires several references to the same blob in the blobstore.
Sha256 aliases are good example. [post](https://fb.facebook.com/groups/scm.mononoke/permalink/739273266435251/)

Short description of alias mechanism:
- we have `key: value` blob in blobstore.
- put a `key1: key` blob in blobstore to have 2-step access from `key1` to `value`.

All the keys in Mononoke are of the form `type_prefix.hash_name.hash`

I expanded MononokeId interface to have an access to the prefix `type_prefix.hash_name` for verification `key` content (see alias mechanism description).

Reviewed By: farnz

Differential Revision: D13084145

fbshipit-source-id: 5b8a4e80869481414a7356ccd7c9aab6e24a5138
2018-11-20 01:43:06 -08:00
Anastasiya Zhyrkevich
3919c0eb4c LFS verification tool
Summary:
Purpose:
- Sha256 alias link to file_content is a required part of LFS getfiles works correct.
LFS protocol uses SHA-256 to refer to the file content. Mononoke uses Blake2.
To support LFS in Mononoke we need to set up a link from SHA-256 hash of the content to blake2 of the content.
These links are called aliases.

- Aliases are uploading together with file content blobs.
But only for new push operations.
- If repo is blobimported from somewhere, we need to make sure, that all the links are in blobstore.
If repo was blobimported before aliases were added then it may miss aliases for some blobs.
- This tool can be used to
   - find if any aliases are missing
   - fill missing aliases.

Implementation:
- Run in repo.
- Iterate through all changesets.
- Go through all the file_content blobs in the changesets
- Verify/generate alias256 links to file_content blobs.

Mode supported:
- verify, count the number of errors and print to console
- generate, if blob is missing to add it to the blobstore

Reviewed By: StanislavGlebik

Differential Revision: D10461827

fbshipit-source-id: c2673c139e2f2991081c4024db7b85953d2c5e35
2018-11-08 03:41:40 -08:00
Walter Schulze
fb5393f77e add stats collection in ChangesetFetcher
Summary:
Added a get_stats() Hashmap<String, Box<Any>> method for all ChangesetFetchers.
The CachingChangesetFetcher now returns statistics for cache.misses: usize, cache.hits: usize, fetches.from.blobstore: usize and max.latency: Duration.

Reviewed By: StanislavGlebik

Differential Revision: D10852637

fbshipit-source-id: 34114fd94c47aa26ea525fcc4ff76ad60827bc71
2018-11-07 15:14:30 -08:00
Simon Farnsworth
1818b9917f Make it possible to configure a sharded database
Summary:
Sharding filenodes by path should stop us knocking over databases -
make it configurable.

Reviewed By: StanislavGlebik

Differential Revision: D12894523

fbshipit-source-id: e27452f9b436842e1cb5e9e0968c1822f422b4c9
2018-11-05 10:28:40 -08:00
Lukas Piatkowski
fc352b60fe mononoke: remove diesel from codebase
Reviewed By: StanislavGlebik

Differential Revision: D10512736

fbshipit-source-id: 9cd8d3abdc896a9e7b01aaec63ff69380efc4f0c
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
744c909225 bookmarks: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10512737

fbshipit-source-id: 7c2612c7799972a63d9865c77f1599f39da0c762
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
64e722dba4 changeset: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10491452

fbshipit-source-id: ec1dcecf09acfa29a236fb4eddf2250b2ea762be
2018-10-29 05:18:29 -07:00
Lukas Piatkowski
4adfa5732b bonsai-hg-mapping: convert from diesel to sql
Reviewed By: StanislavGlebik

Differential Revision: D10483793

fbshipit-source-id: 0d76843e702d510fc655eed52a8c0a68b169d06c
2018-10-29 05:18:29 -07:00
Stanislau Hlebik
c0ad6637c3 mononoke: remove useless println
Reviewed By: Anastasiya-Zhyrkevich

Differential Revision: D10869138

fbshipit-source-id: 304a47d78a748c4e4338abef9940fc924de792e4
2018-10-29 02:36:20 -07:00
Stanislau Hlebik
b058eabc13 mononoke: memcache for changesets
Reviewed By: jsgf

Differential Revision: D10505048

fbshipit-source-id: 1a7accbce29b952a5c8dc99a985eb528d282ddef
2018-10-25 02:08:53 -07:00
Lukas Piatkowski
fe6e5f056c sql_ext: add SqlConstructors trait to avoid copying the same sql code in Mononoke
Reviewed By: StanislavGlebik

Differential Revision: D10483792

fbshipit-source-id: ebae1d0fc7ff6ee750df8f0743824b326901466a
2018-10-22 10:20:47 -07:00
Stanislau Hlebik
911c338e46 mononoke: use get_bonsai_bookmark in Mononoke
Summary:
Bookmarks point to Bonsai changesets. So previously we were fetching bonsai
changeset for a bookmark then converting it to hg changeset in `get_bookmark`
method, then converting it back to bonsai in `pushrebase.rs`.

This diff adds method `get_bonsai_bookmark()` that removes these useless
conversions.

Reviewed By: farnz

Differential Revision: D10427433

fbshipit-source-id: 1b15911fc5d77483b5a135a8d4484fccff23c774
2018-10-22 05:19:52 -07:00
Lukas Piatkowski
28bb85795e Back out "filenodes: revert using myrouter, use dieselfilenodes again"
Summary: Original commit changeset: 07da917455ae

Reviewed By: farnz

Differential Revision: D10446126

fbshipit-source-id: 918f77873cfb35744e489d9afb8b630764cbb199
2018-10-18 08:17:19 -07:00
Tim Fox
35cbe06f80 Expose is_sym_link function in hooks
Summary: ${title}

Reviewed By: StanislavGlebik

Differential Revision: D10423278

fbshipit-source-id: b14cee2f5640cc7152d54506371ce452776749e4
2018-10-17 07:23:19 -07:00
Anastasiya Zhyrkevich
d2a4f4e042 getfiles, config lfs threshold
Summary:
getfiles implementation for lfs

The implementation is the following:
- get file size from file envelope  (retrieve from manifold by HgNodeId)
- if file size > threshold from lfs config
   - fetch file to memory, get sha256 of the file, will be fixed later, as this approach consumes a lot of memory, but we don't have any mapping from sha256 - blake2 [T35239107](https://our.intern.facebook.com/intern/tasks/?t=35239107)
   - generate lfs metadata file according to [LfsPlan](https://www.mercurial-scm.org/wiki/LfsPlan)
   - set metakeyflag (REVID_STORED_EXT) in the file header
- if file size < threshold, process usual way

Reviewed By: StanislavGlebik

Differential Revision: D10335988

fbshipit-source-id: 6a1ba671bae46159bcc16613f99a0e21cf3b5e3a
2018-10-17 02:20:06 -07:00
Lukas Piatkowski
f377fb4ed7 filenodes: revert using myrouter, use dieselfilenodes again
Summary: Reverting the myrouter based filenodes for now as they cause some problems

Reviewed By: jsgf

Differential Revision: D10405364

fbshipit-source-id: 07da917455ae5af9ef81a24d99f516171101c8a7
2018-10-16 09:53:21 -07:00
Anastasiya Zhyrkevich
885960087e LFS push: processing files in metadata format from hg client
Summary:
According to [Mercurial Lfs Plan](https://www.mercurial-scm.org/wiki/LfsPlan), on push, for files which size is above the threshold (lfs.threshold config) hg client is sending LFS metadata instead of actual files contents. The main part of LFS metadata is SHA-256 of the file content (oid).

The format requires the following mandatory fields: version, oid, size.

When lfs metadata is sent instead of a real file content then lfs_ext_stored flag is in the request's revflags.
If this flag is set, We are ignoring sha-1 hash verification inconsistency.
Later check that the content is actually loaded to the blobstore and create filenode envelope from it, load the envelope to the blobstore.

Filenode envelope requires the following info:
- size - retrieved on fetching the actual data from blobstore.
- copy_from - retrieved from the file, sent by hg client.

Mononoke still does the same checks for LFS push as for non-lfs push (i.e. checks that all the necessary manifests/filelogs were uploaded by a client)

Reviewed By: StanislavGlebik

Differential Revision: D10255314

fbshipit-source-id: efc8dac4c9f6d6f9eb3275d21b7b0cbfd354a736
2018-10-16 04:24:20 -07:00
Pavel Aslanov
38c5145e9b hadle change only in executable bit same way as Hg
Summary:
Mercurial stores executable bit as part of the manifest, so if changeset only changes that attribute of a file Hg reuses file hash. But mononoke has been creating additional file node. So this change tries to handle this special case. Note this kind of reuse only happens if file has only one parent [P60183653](P60183653)

Some of our fixtures repo were effected, hence this hashes were replaced with updated ones
```
396c60c14337b31ffd0b6aa58a026224713dc07d => a5ab070634ab9cbdfc92404b3ec648f7e29547bc
339ec3d2a986d55c5ac4670cca68cf36b8dc0b82 => c10443fa4198c6abad76dc6c69c1417b2e821508
b47ca72355a0af2c749d45a5689fd5bcce9898c7 => 6d0c1c30df4acb4e64cb4c4868d4c974097da055
```

Reviewed By: farnz

Differential Revision: D10357440

fbshipit-source-id: cdd56130925635577345b08d8ed0ae6e229a82a7
2018-10-15 02:16:50 -07:00