Commit Graph

48 Commits

Author SHA1 Message Date
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
Stanislau Hlebik
aae4562523 mononoke: revert D12945071
Summary: It causes test failures. REvert for now until they fixed

Reviewed By: farnz

Differential Revision: D13040073

fbshipit-source-id: fc05373c882baf42f7bd2a3a1c1173e8ba26a952
2018-11-13 05:02:29 -08:00
Simon Farnsworth
77a21cbef1 Have Changesets and Bookmarks spawn a new task for transactions
Summary:
We're seeing long transaction hold times in MyRouter during big
blobimports - let's see if it's just that we've got a huge amount of events
outstanding on single tasks

Reviewed By: HarveyHunt

Differential Revision: D12945071

fbshipit-source-id: 3aca0b8cb649fc572fca8cadec8f0d265be2d564
2018-11-12 15:43:03 -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
Lukas Piatkowski
7bcdf468bd changesets: fix for parentless commits with MySql
Reviewed By: StanislavGlebik

Differential Revision: D12838643

fbshipit-source-id: f9750a1d244c7ac37ac4bb551a520262bacac669
2018-10-30 06:41:15 -07:00
Lukas Piatkowski
09ce2e03fe sql: allow not passing type of write query
Summary: This will enable doing queries like DELETE, UPDATE or REPLACE without listing all possibilites in the macros

Reviewed By: StanislavGlebik

Differential Revision: D10499501

fbshipit-source-id: 3e2ba433722bd34ffb5960840c509dc27cc9eb5d
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
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
Stanislau Hlebik
f0b0fdad63 mononoke: prefetch caches of changesets from blobstore
Summary:
This diff adds a real implementation for CachingChangesetFetcher. Now it
fetches the data for the cache from the blobstore.

The rest is explained in the comments.

Reviewed By: farnz

Differential Revision: D9908320

fbshipit-source-id: 5427f3ed312cb7753434161423cb27b48744347f
2018-09-25 05:07:50 -07:00
Jeremy Fitzhardinge
d865e4dfad tp2/rust: update to Rust 1.29
Reviewed By: StanislavGlebik

Differential Revision: D9978034

fbshipit-source-id: 439ef4f558202980585ba8a4660986b31ade3061
2018-09-21 11:37:10 -07:00
Stanislau Hlebik
5dfb4d76b8 common/rust: renamed get_cached to get_cached_or_fill
Summary:
In the next diff I'm going to add a separate functions to look in the cache and
insert into the cache, so rename it to avoid confusion

Reviewed By: Imxset21

Differential Revision: D9869648

fbshipit-source-id: f2bd806b14d78660518d841d90a903970028eb37
2018-09-18 02:06:43 -07:00
Stanislau Hlebik
664c824764 mononoke: thrift serialization/deserialization of ChangesetEntry
Summary:
We have plans to add a cache of many changeset entries and store it in the
blobstore. The main reason is to speed up Mononoke's revsets and in turn speed
up getbundle wireproto request.

To cache we first need to serialize them. Let's use thrift serialization for
that.

Reviewed By: lukaspiatkowski

Differential Revision: D9738637

fbshipit-source-id: ba771545de9a955956acb6d169ee7bc424ef271b
2018-09-13 06:08:27 -07:00
Jeremy Fitzhardinge
c4ece89763 mononoke: use Chain for errors
Summary:
Use .chain_err() where appropriate to give context to errors coming up from
below. This requires the outer errors to be proper Fail-implementing errors (or
failure::Error), so leave the string wrappers as Context.

Reviewed By: lukaspiatkowski

Differential Revision: D9439058

fbshipit-source-id: 58e08e6b046268332079905cb456ab3e43f5bfcd
2018-09-06 14:24:08 -07:00
Simon Farnsworth
7fd5851f1e Use blocking in asynchronize as well as spawning a task
Summary:
`asynchronize` currently does not warn the event loop that it's
running blocking code, so we can end up starving the thread pool of threads.

We can't use `blocking` directly, because it won't spawn a synchronous task
onto a fresh Tokio task, so your "parallel" futures end up running in series.
Instead, use it inside `asynchronize` so that we can pick up extra threads in
the thread pool as and when we need them due to heavy load.

While in here, fix up `asynchronize` to only work on synchronous tasks and
push the boxing out one layer. Filenodes needs a specific change that's
worth extra eyes.

Reviewed By: jsgf

Differential Revision: D9631141

fbshipit-source-id: 06f79c4cb697288d3fadc96448a9173e38df425f
2018-09-05 12:23:49 -07:00
Stanislau Hlebik
2c8d98447d mononoke: revert D8959535
Summary:
It makes startup unbearably slow, and doesn't add any benefits at all. Revert
it

Reviewed By: purplefox

Differential Revision: D9358741

fbshipit-source-id: 26469941304f737c856a6ffca5e577848ad30955
2018-08-16 03:06:14 -07:00
Jeremy Fitzhardinge
e0ce53ce36 rust: change asynchronize to use tokio-threadpool::blocking
Summary:
Should be functionally equivalent and semantically more appropriate

This also makes a couple of small API changes:
- The inner function is expected to just return a Result - IntoFuture is
  overkill if its supposed to be synchronous in the first place
- `asynchronize` itself returns `impl Future` rather than being intrinsically
  boxed.
- Restructure dieselfilenodes::add_filenodes to only asynchronize the insert
  itself.

Reviewed By: farnz

Differential Revision: D8959535

fbshipit-source-id: fef9164e3be0069bd0d93573642cd57bb5babb73
2018-08-13 14:51:45 -07:00
Simon Farnsworth
3733848cef Use Abomonation and cachelib to replace Asyncmemo
Summary:
Asyncmemo has two issues for our use:

1. Separate memory pool from cachelib caches.
2. Future fusion means that a `get` that should succeed will fail because there
was an earlier get still in progress.

The second is good for memoization, where the worst case from a failed get is
extra CPU work, but not so good for caching. Replace uses of Asyncmemo for
caches with a cachelib based cache

Reviewed By: StanislavGlebik

Differential Revision: D9013679

fbshipit-source-id: b85d4eec7294e0c8ee08faa671d26901b35cf1fc
2018-08-07 13:37:09 -07:00
Simon Farnsworth
1ffa07da46 Derive Abomonation for all interesting types
Summary:
These are the types that we currently need to be able to serialize if we're to
replace `Asyncmemo`'s caching uses with cachelib. Derive the `Abomonation`
trait for all of them.

Reviewed By: jsgf

Differential Revision: D9082597

fbshipit-source-id: 910e90476a3cc4d18ba758226b8572c3e8d264c6
2018-08-07 13:37:08 -07:00
Stanislau Hlebik
9abd29d4c3 mononoke: use ChangesetId in Changesets
Summary:
Alas, the diff is huge. One thing is changing Changesets to use ChangesetId.
This is actually quite straightforward. But in order to do this we need to
adapt our test fixtures to also use bonsai changesets. Modifying existing test
fixtures to work with bonsai changesets is very tricky. Besides, existing test
fixtures is a big pile of tech debt anyway, so I used this chance to get rid of
them.

Now test fixtures use `generate_new_fixtures` binary to generate an actual Rust
code that creates a BlobRepo. This Rust code creates a bonsai changeset, that
is converted to hg changeset later.
In many cases it results in the same hg hashes as in old test fixtures.
However, there are a couple of cases where the hashes are different:
1) In the case of merge we are generating different hashes because of different
changed file list (lukaspiatkowski, aslpavel, is it expected?). this is the case for test
fixtures like merge_even, merge_uneven and so on.
2) Old test fixtures used flat manifest hashes while new test fixtures are tree
manifest only.

Reviewed By: jsgf

Differential Revision: D9132296

fbshipit-source-id: 5c4effd8d56dfc0bca13c924683c19665e7bed31
2018-08-06 10:36:43 -07:00
Pulkit Goyal
fc880f518b Add Cargo.toml files to crates. (#7)
Summary:
This is a series of patches which adds Cargo.toml files to all the crates and tries to build them. There is individual patch for each crate which tells whether that crate build successfully right now using cargo or not, and if not, reason behind that.

Following are the reasons why the crates don't build:

  * failure_ext and netstring crates which are internal
  * error related to tokio_io, there might be an patched version of tokio_io internally
  * actix-web depends on httparse which uses nightly features

All the build is done using rustc version `rustc 1.27.0-dev`.
Pull Request resolved: https://github.com/facebookexperimental/mononoke/pull/7

Differential Revision: D8778746

Pulled By: jsgf

fbshipit-source-id: 927a7a20b1d5c9643869b26c0eab09e90048443e
2018-07-09 19:52:27 -07:00
Christopher Kuklewicz
6cc2cd49f8 Unifying sql code for Mononoke/Diesel
Summary:
Unify all uses of Sqlite and of Mysql

This superceded D8712926

Reviewed By: farnz

Differential Revision: D8732579

fbshipit-source-id: a02cd04055a915e5f97b540d6d98e2ff2d707875
2018-07-08 09:06:22 -07:00
Lukas Piatkowski
985e370f87 asyncmemo: add stats to track size of asyncmemo cache
Reviewed By: jsgf

Differential Revision: D8677107

fbshipit-source-id: f3ef30f36c918c1d4e06d3e2e7856ce429bad6cf
2018-06-28 09:21:31 -07:00
Stanislau Hlebik
1da09b3735 changesets: use connection to master only as fallback and for writes
Summary: Going to master adds a latency. Let's go to master only if we haven't found anything in the replica

Reviewed By: lukaspiatkowski

Differential Revision: D8548598

fbshipit-source-id: b0632ccf7f148d20e66763981c8ef4e615fd7f6c
2018-06-20 17:37:22 -07:00
Lukas Piatkowski
e6837e1671 stats: prepend "mononoke." prefix to stats exported from mononoke
Summary: this will make it easier to identify stats exported from mononoke vs external libraries

Reviewed By: StanislavGlebik

Differential Revision: D8331418

fbshipit-source-id: c151e76aa386fb13759fced7cc07b03ac67fe051
2018-06-08 04:20:42 -07:00
Rain ⁣
cfb1588d02 update username and email in Rust code
Summary: Going to take a while to get to everything, but here's a start.

Reviewed By: Imxset21

Differential Revision: D8311107

fbshipit-source-id: ada1908b320a5277eda2587d7e8f26b13b952154
2018-06-07 21:07:14 -07:00
Lukas Piatkowski
4f44c3f130 mercurial_types: remove D* types and move mercurial types around
Summary:
Now it is as it should be: mercurial_types have the types, mercurial has revlog related structures
burnbridge

Reviewed By: farnz

Differential Revision: D8319906

fbshipit-source-id: 256e73cdd1b1a304c957b812b227abfc142fd725
2018-06-07 13:19:16 -07:00
Jeremy Fitzhardinge
a2daf8c2d5 mononoke: no need to pass Mysql connection params by value
Summary: It only needs to borrow them.

Reviewed By: kulshrax

Differential Revision: D8244267

fbshipit-source-id: 2a24a3b7c6eb65177e4e26c57650dd7e096b4202
2018-06-04 08:51:25 -07:00
Lukas Piatkowski
244041ce2e changesets: compare old and new parent rows without IDs and ordered
Summary: As a bonus - put the whole rows in the error message to make it easier to spot what is the problem

Reviewed By: farnz

Differential Revision: D8186670

fbshipit-source-id: 719d302883b23733daa30878eaf27ea6df0180d7
2018-05-30 06:26:38 -07:00
Stanislau Hlebik
44ce21f2b4 mononoke: add stats
Summary: It can be useful to understand how often do we hit a db, write to blobstore, etc

Reviewed By: farnz

Differential Revision: D7806954

fbshipit-source-id: 9c85cbb11e184ae9f7751e05e961980b29b7568a
2018-05-01 06:07:53 -07:00
Stanislau Hlebik
4a731b2118 mononoke: do not fail if duplicate changeset was inserted
Summary:
Let's fail only if inconsistent data was inserted - for example, same commit
hash but different parents.
This matches core hg behavior, and also it's completely normal for commit cloud
to send more parent commits than necessary.

Reviewed By: lukaspiatkowski

Differential Revision: D7722649

fbshipit-source-id: 172a0985fb3fda27d55e9dce8916ec3793de5db9
2018-04-24 08:49:48 -07:00
Stanislau Hlebik
ca656e46cd mononoke: use asynchronize in Changesets
Summary:
This is a nice little improvement, that makes code readable.
`asynchronize()` does all the job of executing the job on the thread pool.

Reviewed By: lukaspiatkowski

Differential Revision: D7722648

fbshipit-source-id: 6d87178c11fa56ea9738738357fb3c3af012c81a
2018-04-24 08:49:48 -07:00
Stanislau Hlebik
3f600af142 mononoke: add Changesets cache
Summary:
Use asyncmemo to cache Changesets.

Unfortunately currently we are using separate asyncmemo cache, so we have to
specify the size for the caches separately. Later we'll have a single cache for
everything, and the number of config knobs will go down.

Reviewed By: lukaspiatkowski

Differential Revision: D7685376

fbshipit-source-id: efe8a3a95fcc72fab4f4af93564e706cd1540c2f
2018-04-22 04:59:27 -07:00
Jeremy Fitzhardinge
2e7a6fd668 tp2: update to rust-1.25.0
Summary:
Update x86 and aarch64 toolchains, rust-crates-io update.
The `use_nested_groups` feature is now stable, so we don't need to list it in
`#![feature(...)]` lines.

Reviewed By: kulshrax

Differential Revision: D7690730

fbshipit-source-id: 5f74bb01df6bd88a66ac00a82e446c18e3a1c43d
2018-04-21 22:45:55 -07:00
Lukas Piatkowski
f6c3f72745 CODEMOD: rename mercurial_types::HgChangesetId to DChangesetId
Summary: mercurial_types::DChangesetId should be replaced by types from mononoke_types in most cases and by mercurial::HgChangesetId in others. This rename should help with tracking this

Reviewed By: sid0

Differential Revision: D7618897

fbshipit-source-id: 78904f57376606be99b56662164e0c110e632c64
2018-04-16 03:40:24 -07:00
Stanislau Hlebik
2aa2d10263 mononoke: update changesets table
Summary:
We don't need parent_id in the index, because we'll search only using cs_id and
seq

Reviewed By: jsgf

Differential Revision: D7487275

fbshipit-source-id: 93ceb238b7d5f42e5d37c1a85eadb8e7aab5c1f4
2018-04-04 01:27:34 -07:00
Stanislau Hlebik
069200aaaa mononoke: use BIGINT for mysql changesets id
Summary: There can be a lot of changesets - let's not limit ourselves to 2B

Reviewed By: farnz

Differential Revision: D7429645

fbshipit-source-id: 9501214f6f10b87b8a37cb5b9503a9d231e241be
2018-03-28 13:54:01 -07:00
Jeremy Fitzhardinge
5c616f4ff6 mononoke: fix changesets unit tests
Summary:
They would hang on any failure rather than reporting properly.
Convert to using async_unit::tokio_unit_test() to make sure unwinds are caught.

Reviewed By: StanislavGlebik

Differential Revision: D7408174

fbshipit-source-id: 39b41bd66557e0d455f87ad29a2df73768cfb9c6
2018-03-27 17:39:52 -07:00
Jeremy Fitzhardinge
3373c16b62 scm/mononoke: run changeset operations in worker threads
Summary:
Run changeset db operations in worker threads to make them async as
far as the rest of the system is concerned.

Reviewed By: farnz

Differential Revision: D7350002

fbshipit-source-id: 66fadf9ad2f16929e0c07a6907aa9d5f5a7075a8
2018-03-23 13:47:55 -07:00
Jeremy Fitzhardinge
d6504de44c scm/mononoke: make Changesets::add take ChangesetInsert by value
Summary:
There's no point passing it by reference since callers don't need to
retain it, and the async implementation needs to move it into another context.

Reviewed By: farnz

Differential Revision: D7350001

fbshipit-source-id: 5947557a84621afae801dc20e3994496244e3a10
2018-03-23 13:47:54 -07:00
Jeremy Fitzhardinge
dabdef6e7e mononoke/changesets: use pooled connections for mysql
Summary:
Use connection pooling for mysql. We can't use it for sqlite because each
"connection" ends up being to a separate db.

Reviewed By: sid0

Differential Revision: D7350000

fbshipit-source-id: 37be71b863810c48ae69da579cf74358058f7d2f
2018-03-23 13:47:54 -07:00
Simon Farnsworth
e108e9b258 Make it possible to create tables if missing in SQLite changesets
Summary:
For testing, I want to be able to persist state in SQLite (so that
when we have in-process caching, I can restart and see cold cache behaviour).
This means that I want to open a database, and create the tables ignoring
failures. Make it possible

Reviewed By: StanislavGlebik

Differential Revision: D7353231

fbshipit-source-id: 0d0926c501e7951dfaf82998ed58d152e80ace7e
2018-03-23 13:09:13 -07:00
Lukas Piatkowski
5ba5c0b0e0 mercurial_types: distinguish between HgManifestId and HgChangesetId in sql types
Summary: the diesel schemas should prevent from reading a manifest hash as changeset and vice versa

Reviewed By: StanislavGlebik

Differential Revision: D7339725

fbshipit-source-id: c619ab7ecabfd10f42e64a38c0f16abd114d4a31
2018-03-21 05:14:37 -07:00
Stanislau Hlebik
f023874ed9 mononoke: remove unused parameter
Reviewed By: farnz

Differential Revision: D7324591

fbshipit-source-id: 53b16d0a44fea0011a15634939b3f385658288e4
2018-03-19 15:36:01 -07:00
Siddharth Agarwal
b338897dc4 prefix ChangesetId, ManifestId and BlobHash with Hg
Summary:
Mononoke will introduce its own ChangesetId, ManifestId and BlobHash, and it
would be good to rename these before that lands.

Reviewed By: farnz

Differential Revision: D7293334

fbshipit-source-id: 7d9d5ddf1f1f45ad45f04194e4811b0f6decb3b0
2018-03-15 17:45:29 -07:00
Arun Kulshreshtha
9f091474bb Fill in missing code in MysqlChangesets
Summary: Add in the missing code to establish a MySQL connection to the `changesets` crate. Also add unit tests for `MysqlChangesets`.

Reviewed By: jsgf

Differential Revision: D7174371

fbshipit-source-id: b531c5d5efb95eeb5e39188c4d608540f0c0261f
2018-03-06 17:07:46 -08:00
Enji Cooper
21de6e7785 Fix typos ("and and" -> "and")
Reviewed By: yfeldblum

Differential Revision: D7091797

fbshipit-source-id: cbba7e5c17e1b6d4446570fb7a2b888db8bcd17e
2018-02-27 16:36:59 -08:00
Siddharth Agarwal
1e5ddafbd4 initial complete table backend using diesel
Summary:
Diesel looks quite promising overall, as long as we can ensure async operations
work.

Some basic notes:

* This just looks async but isn't really -- doing that would need a way to send
queries over to a thread pool. (cc kulshrax)
* It is unfortunate that we must use a macro for the exact same `add` code across
MySQL and SQLite. There doesn't appear to be a way out though -- there is no
trait bound that we can apply to the `add` method here.

This is currently pretend-async -- it would be good to make this really async, but that should wait for a future diff IMO

Reviewed By: StanislavGlebik

Differential Revision: D6932028

fbshipit-source-id: ac1cfde3b96bb790f00b73d49c6d90ed128f0255
2018-02-22 17:08:59 -08:00