Commit Graph

59 Commits

Author SHA1 Message Date
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
Stanislau Hlebik
c608944cfd mononoke: remove unused code
Summary:
Removed:

cmd-line cmd tool for filenodes and bookmarks. These should be a part of
mononoke_admin script

Outdates docs folder

Commitsim crate, because it's replaced by real pushrebase

unused hooks_old crate

storage crate which wasn't used

Reviewed By: aslpavel

Differential Revision: D13301035

fbshipit-source-id: 3ae398752218915dc4eb85c11be84e48168677cc
2018-12-05 05:58:07 -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
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
Stanislau Hlebik
f852e42f3c mononoke: make sure we go to slave for read connections
Summary:
Default ServiceType is ServiceType.Any, so it might go to master in a master
region. This diff changes it.

Reviewed By: lukaspiatkowski, farnz

Differential Revision: D13021674

fbshipit-source-id: 928cf59b095549f3048411241116c097e1193c7d
2018-11-12 06:52:10 -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
Simon Farnsworth
2ca140b86a Shard filenodes table across multiple databases
Summary:
We can already flatten a single XDB server with filenodes traffic, and
do if we start up a server instance without a warm memcache. This is only going
to get worse in the future.

Start the process of sharding across multiple servers. For now, we can only
deal with shard size == 1, but this code should be ready to handle shard sizes
greater than 1

Reviewed By: StanislavGlebik

Differential Revision: D12888927

fbshipit-source-id: 8e01694357c390837487fdb3710685fd09feaec0
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
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
aab7ca78ec sql: add support for WHERE foo IN (list) statements, add support for trailing commas
Reviewed By: StanislavGlebik

Differential Revision: D10483800

fbshipit-source-id: 8b2fedfb1c5270d14a2d0fbdd55c0be5ace3f4a7
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
7b9d0fb5df mononoke: memcache for filenodes
Summary:
We have a problem with service upgrades/restarts because many servers start
sending too many requests to mysql db.

Let's add a memcache that will prevent that.

Reviewed By: jsgf

Differential Revision: D10488624

fbshipit-source-id: 4575d359bc269e29fe72b47d7f47cda22bf4acd7
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
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
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
Lukas Piatkowski
44ad7ef408 sql: add wait_for_myrouter async function that the client can chain on to wait for myrouter to startup
Summary:
As per the comments added - MyRouter setup is such that it starts inside a tupperware container together with the binary that will be using it. This means that by the time the binary wants to use the MyRouter connection the MyRouter instance might not be ready yet. In order to mitigate this effect the myrouter::Builder will attempt to make a "Select 1" query and retry it with a backoff for a max of 2 min or until the connection is actually established.

Unfortunately the `queries!` macro had to be moved inside the `macro` module in order to make it usable from inside `myrouter` module, see this: https://stackoverflow.com/questions/31103213/import-macro-from-parent-module

Reviewed By: farnz

Differential Revision: D10270464

fbshipit-source-id: 9cf6ad936a0cabd72967fb96796d4af3bab25822
2018-10-11 10:52:05 -07:00
Lukas Piatkowski
cad69fedd0 filenodes: use sqlfilenodes instead of dieselfilenodes; pass myrouter_port around
Reviewed By: farnz

Differential Revision: D10338868

fbshipit-source-id: 60734d9635df442691cad3637aebd5bc838e03ad
2018-10-11 10:52:05 -07:00
Lukas Piatkowski
6de0ccc24e filenodes: add sqlfilenodes implementation using common/rust/sql instead of diesel
Reviewed By: farnz

Differential Revision: D10261151

fbshipit-source-id: fdae33f370123cd968e9ee6ef0e20c55d9f6e88b
2018-10-11 10:52:05 -07:00
Lukas Piatkowski
dd79d028dd filenodes: fix dieselfilenodes-cmd by calling it's code inside tokio
Reviewed By: farnz

Differential Revision: D10251659

fbshipit-source-id: 6f288a41d63d25521efd41349c4bd34b77a2a40b
2018-10-11 10:52:05 -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
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
Lukas Piatkowski
8748c72eea filenodes: use Memcache to cache get_all_filenodes results
Summary: Because get_all_filenodes can go above 1MB (but still less than 3MB) I added a chunking logic to speed up fetching of even the long histories

Reviewed By: farnz

Differential Revision: D9029774

fbshipit-source-id: c2d46a4b49bfebd3c778a0b9c5cf226857f34768
2018-07-27 13:21:20 -07:00
Lukas Piatkowski
4cf8e881e8 filenodes: move blake2_path_hash to a common place for all filenodes implementations
Summary: The blake2_path_hash is used only in MySql right now, but I want to use it in caching as well, so moving it to a more accessible place.

Reviewed By: jsgf

Differential Revision: D9028799

fbshipit-source-id: b055550fbfca5c6c419702490504f08812592470
2018-07-27 13:21:20 -07:00
Lukas Piatkowski
53b147435c filenodes: track the size of get_all_filenodes requests in thrift compact form
Summary:
This information is useful to decide if get_all_filenodes is small enough to fit into memcache.
Later it will be used to track how many elements are fitting into memcache nicely.

Reviewed By: jsgf

Differential Revision: D9028395

fbshipit-source-id: ae71486f9e9d60d7b54ce28b8c591c09b8925947
2018-07-27 13:21:20 -07:00
Lukas Piatkowski
cf906c3056 filenodes: move CachingFilenodes to it's own module
Summary: a bit of cleanup for the upcoming diffs

Reviewed By: farnz

Differential Revision: D9014639

fbshipit-source-id: d03e4969426eced70fd19b91a2c15b607bf52b39
2018-07-27 08:21:14 -07:00
Lukas Piatkowski
6b934172a6 filenodes: add thrift structures for FilenodeInfo
Summary: Those structures will be used in next diffs to store the FilenodeInfo inside memcache for caching purposes

Reviewed By: farnz

Differential Revision: D9014213

fbshipit-source-id: 4952a90415d4b8ab903387fd5cdfaf08d9870c07
2018-07-27 08:21:13 -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
Lukas Piatkowski
93cee8f271 filenodes: use connection to master only as fallback and for writes
Summary: we want most of the read traffic to be handled by replicas

Reviewed By: lukaspiatkowski

Differential Revision: D8548027

fbshipit-source-id: 297b070b5b33ec114026ecf3f1079fdb26f54b19
2018-06-20 17:37:22 -07:00
Lukas Piatkowski
18d475fb9a filenodes: separate pool of connection for writes from reads
Summary: There shouldn't be more than one thread writing to the database, because it causes lags in slaves and they race for database locks between themselves. One write connection should be sufficient enough.

Reviewed By: StanislavGlebik

Differential Revision: D8348604

fbshipit-source-id: ceef081ed89611978accfa55969883078d65a58f
2018-06-11 06:38:14 -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
Lukas Piatkowski
27bdcb40b2 filenodes: control size of the connection pool
Summary:
The new_blobimport job is having difficulties when the pool is too large, because the write transactions are taking too long. If the pool is configured to be 1 for it then everything seems fine and fast enough.
On the other hand the Mononoke server should have bigger connectino pool size to be able to quickly respond for read requests.

Reviewed By: farnz

Differential Revision: D8235413

fbshipit-source-id: 84e0013ce569c3f103a2096001605aab828d178c
2018-06-05 05:58:31 -07:00
Lukas Piatkowski
ca35624029 filenodes: remove transation over filenodes update
Summary:
The transaction is not necessary in there, since if any of the query fails then the commit is not written in changesets table.
We need to remove it, because with many writes to the filenodes table some of the transactions are timing out while waiting for the database's lock for transation

Reviewed By: farnz

Differential Revision: D8220722

fbshipit-source-id: 003b1369abb1a47e8ad37517745ab659116b95f6
2018-06-05 05:58:31 -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
Stanislau Hlebik
0b93cff8d4 mononoke: add a method to fetch all filenodes at once
Summary:
It will be used in getfiles wireproto method. It requires fetching the whole
file history, and doing lots of point lookups is too slow.

Reviewed By: lukaspiatkowski

Differential Revision: D8182050

fbshipit-source-id: b17cb2259b2237f0027bfb499fbe97d9b40b1a62
2018-05-29 04:11:47 -07:00
Stanislau Hlebik
ef4c28f4f1 mononoke: refactor dieselfilenodes
Summary:
Move functionality of converting FilenodeRow into FilenodeInfo into a separate
function. It will be used in the next diff

Reviewed By: lukaspiatkowski

Differential Revision: D8182051

fbshipit-source-id: f2276aa979200f71aa05808595842c09a9f5899f
2018-05-29 04:11:47 -07:00
Stanislau Hlebik
865b59eb46 mononoke: add has_copyinfo
Summary:
Motivation for this change is the following:
We want to avoid doing point lookups to the db to fetch the history, and
instead select the history for a file or a directory with a single select. That
should be many times faster.
After we select the data from filenodes table, we need to fetch  copy info
data. To do that we need to either do lots of point lookups to the fixedcopyinfo (which
undermines the point of doing single select) or construct a giant select
statement. First option is inefficient, the second can introduce big code
complexity.

Instead let's add a single field that says whether we have fixed copy info or
not. Db size increase should be tiny.

For the data that we've already imported I'm planning to run a script that will
fill the has_copyinfo field correctly.

Reviewed By: jsgf

Differential Revision: D8164029

fbshipit-source-id: c91c99b065808a93a9b361914cf9b3822d78cb60
2018-05-27 13:06:17 -07:00
Stanislau Hlebik
b3432410ae mononoke: use caching for filenodes
Summary: As with changesets and blobs, let's cache filenodes data

Reviewed By: jsgf

Differential Revision: D7831105

fbshipit-source-id: 334cb474f5cc3ef8dba0945d11273b2b3875e8ad
2018-05-03 10:31:32 -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
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
Stanislau Hlebik
0a6f16f39e mononoke: make async filenodes
Summary:
Just as with changesets, let's make filenodes async.

I had to make unit-tests use async_unit, otherwise tokio::spawn() failed with
SpawnedError. I'm not sure why it happened, but async_unit has fixed the issue

Reviewed By: lukaspiatkowski

Differential Revision: D7635554

fbshipit-source-id: c6130b95cee2d60d0b6eec0ab6c1b3e4f3a26ccd
2018-04-21 11:24:24 -07:00