Commit Graph

30 Commits

Author SHA1 Message Date
Kostia Balytskyi
039d3942e8 sql: do not use shard_id in fb303 counter names
Summary:
Before this change, we would always include the shard id in our mysql-related fb303 counters. This is not perfect for two reasons:
- the the xdb blobstore we have 4K shards and 24 counters, so we were reporting 96K counters in total
- we rarely care about per-counter metrics anyway, since in most cases all queries are uniformly distributed

Therefore, let's change this approach to not use per-shard counters and use per-shardmap ones (when sharding is involved).

Reviewed By: krallin

Differential Revision: D16360591

fbshipit-source-id: b2df94a3ca9cacbf5c1f328b48e87b48cd18287e
2019-07-19 06:30:40 -07:00
Thomas Orozco
3897b5ab50 mononoke: retry in create_raw_xdb_connection
Summary: This adds a few retries in create_raw_xdb_connection. This is intended as a first step towards solving some of the flakiness we've observed when connecting to MySQL through direct connections (sometimes, we fail to acquire certificates).

Reviewed By: farnz

Differential Revision: D16228401

fbshipit-source-id: 0804797aecfe0b917099191cd2a36ce4c077b949
2019-07-17 12:57:42 -07:00
Thomas Orozco
4105638a1e mononoke: hoist up to_string() calls
Summary:
In earlier diffs in this stack, I updated the callsites that reference XDB tiers to use concrete &str types (which is what they were receiving until now ... but it wasn't spelled out as-is).

In this diff, I'm updating them to use owned `String` instead, which lets us hoist up `to_string()` and `clone()` calls in the stack, rather than pass down reference only to copy them later on.

This allows us to skip some unnecessary copies. Tt turns out we were doing quite a few "turn this String into a reference, pass it down the stack, then turn it back into a String".

Reviewed By: farnz

Differential Revision: D16260372

fbshipit-source-id: faec402a575833f6555130cccdc04e79ddb8cfef
2019-07-17 12:57:42 -07:00
Thomas Orozco
5a10c5fbf9 mononoke: convert DB connection instantiation to future
Summary:
Instantiating a new DB connection may require remote calls to be made to e.g. Hipster to allocate a new certificate (this is only the case when connecting to MySQL).

Currently, our bindings to our underlying DB locator make a blocking call to pretend that this operaiton is synchronous: https://fburl.com/ytmljxkb

This isn't ideal, because this call might actually take time, and we might also occasionally want to retry it (we've had issues in our MySQL tests with acquiring certificates that retrying should resolve). Running this synchronously makes doing so inefficient.

This patch doesn't update that, but it fixes everything on the Rust side of things to stop expecting connections to return a `Result` (and to start expecting a Future instead).

In a follow up diff, I'll work on making the changes in common/rust/sql to start returning a Future here.

Reviewed By: StanislavGlebik

Differential Revision: D16221857

fbshipit-source-id: 263f9237ff9394477c65e455de91b19a9de24a20
2019-07-16 03:17:58 -07:00
Stanislau Hlebik
8dddd95f01 mononoke: remove unnecessary extern crate
Reviewed By: HarveyHunt

Differential Revision: D16224057

fbshipit-source-id: 1cf937305c6cc1ad3ae64ea32413be634127d566
2019-07-12 11:37:06 -07:00
Stanislau Hlebik
30227f6c72 mononoke: rename get_all_filenodes to get_all_filenodes_maybe_stale
Summary:
New name better reflects what this function does - it might return cached
version of filenodes that might be out of date.

Reviewed By: aslpavel

Differential Revision: D15896734

fbshipit-source-id: caf4f1d3a9a29889327c3373ac886687ec916903
2019-06-20 01:50:46 -07:00
Jeremy Fitzhardinge
050ed79532 Convert scm/mononoke/filenodes/sqlfilenodes to Rust 2018
Summary:
Rust 2018 updates to:
  //scm/mononoke/filenodes/sqlfilenodes:sqlfilenodes
  //scm/mononoke/filenodes/sqlfilenodes:sqlfilenodes-unittest
  //scm/mononoke/filenodes/sqlfilenodes:sqlfilenodes_test
  //scm/mononoke/filenodes/sqlfilenodes:sqlfilenodes_test-rust-build-info-lib

Reviewed By: StanislavGlebik

Differential Revision: D15466055

fbshipit-source-id: ad3a4563e05763d31d4a0f3d47617a78ba574ee2
2019-05-24 10:40:39 -07:00
Stanislau Hlebik
3e12f12e2f mononoke: bump filenodes buffer sizes
Summary: It makes pushes faster, especially on non-master regions.

Reviewed By: quark-zju

Differential Revision: D15279259

fbshipit-source-id: c184b68cc8b7509938849cd86bb15ef5d5f33bdd
2019-05-21 12:25:45 -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
Stanislau Hlebik
2f4a56df43 mononoke: more efficient ensure_paths_exists implementation
Summary:
Before this diff we always wrote to master even if paths already exist. This
diff changes it - first check in replica if paths are there, and only then
write to master

Reviewed By: farnz

Differential Revision: D15063307

fbshipit-source-id: 802839f340c9953c7f2812e77d81bc66917c5e77
2019-05-21 12:25:21 -07:00
Jeremy Fitzhardinge
89ae5651a4 rust/sql: add stats for connection creation and reuse
Reviewed By: StanislavGlebik

Differential Revision: D14988868

fbshipit-source-id: e64c4ab57726d1743d11312592ba06107fdb78f4
2019-05-21 12:25:15 -07:00
Jeremy Fitzhardinge
08fd9ce03b rust/sql: add LABEL to SqlConstructors
Summary:
Add a LABEL constant to the SqlConstructors trait to make it easier to identify
which table is being used, for stats and logging.

Reviewed By: HarveyHunt

Differential Revision: D13457488

fbshipit-source-id: a061a9582bc1783604f249d5b7dcede4b1e1d3c5
2019-05-21 12:25:14 -07:00
Stanislau Hlebik
56a2ad455c mononoke: remove mysql schemas
Summary:
These are **not** the schemas that we use in production.
So at the moment they are not used for anything and they just create confusion.

Reviewed By: aslpavel

Differential Revision: D13986001

fbshipit-source-id: 7aae0a5da474f579c9cdf1bbf5dfe183835cae2d
2019-02-08 03:04:01 -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
Stanislau Hlebik
5dbdffdfe7 mononoke: fix sharded filenodes
Summary:
Previously to get copy/move source we had to join `paths` and `fixedcopyinfo`
table. That worked fine when we had just one shard. However now we have many
shards, and join no longer works. The reason is that move source path is in a
different shard compared to move destination path, and join returns no data.

Consider this situation. shardA contains all the data for pathA, shardB
contains all the data for pathB. That means that sharded `paths` table will
have pathA in shardA and pathB in shardB. Then if file pathA was copied form
pathB, then `fixedcopyinfo` table in shardA contains a path_hash of pathB.
However joining shardA's `fixedcopyinfo` with shardA's `paths` to convert
path_hash to path fails because pathB is in shardB.

The only possible fix is to split fetching path_hash from `fixedcopyinfo` and
converting path_hash to path.

I don't think we'll be able to keep the logic with join that we have at the
moment. It would require us to have all paths on all shards which is
unfeasible because it'll make writes much slower.

Reviewed By: aslpavel

Differential Revision: D13690141

fbshipit-source-id: 16b5cae6f23c162bb502b65c208f3ca9e443fb04
2019-01-17 02:33:35 -08:00
Stanislau Hlebik
712bab10f9 mononoke: rustfmt
Summary:
Going to change these files in the next diff. To make next diff smaller
splitting format changes to this diff.

Reviewed By: aslpavel

Differential Revision: D13690143

fbshipit-source-id: 124232b832d8c67ee7fe931ef174230cb09ff564
2019-01-17 02:33:35 -08:00
Lukas Piatkowski
1fc999ed61 sql_ext: add PoolSizeConfig to enable easy configuring of MyRouter pool sizes
Reviewed By: StanislavGlebik

Differential Revision: D13465182

fbshipit-source-id: c6c1b788c698bd853a9c26c1b1c1c2b7199e05e9
2019-01-15 09:38:26 -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
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
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
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
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