Commit Graph

327 Commits

Author SHA1 Message Date
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