Commit Graph

25 Commits

Author SHA1 Message Date
Lukas Piatkowski
db2f711159 mononoke/hg_sync_job: make mononoke_hg_sync_job public (#37)
Summary:
Pull Request resolved: https://github.com/facebookexperimental/eden/pull/37

mononoke_hg_sync_job is used in integration tests, make it public

Reviewed By: krallin

Differential Revision: D22795881

fbshipit-source-id: 7a32c8e8adf723a49922dbb9e7723ab01c011e60
2020-07-30 02:52:56 -07:00
Arun Kulshreshtha
5f0181f48c Regenerate all Cargo.tomls after upgrade to futures 0.3.5
Summary: D22381744 updated the version of `futures` in third-party/rust to 0.3.5, but did not regenerate the autocargo-managed Cargo.toml files in the repo. Although this is a semver-compatible change (and therefore should not break anything), it means that affected projects would see changes to all of their Cargo.toml files the next time they ran `cargo autocargo`.

Reviewed By: dtolnay

Differential Revision: D22403809

fbshipit-source-id: eb1fdbaf69c99549309da0f67c9bebcb69c1131b
2020-07-06 20:49:43 -07:00
Stefan Filip
a688181255 mononoke: add MyAdmin implementation for ReplicaLagMonitor
Summary:
Simple implementation that queries the MyAdmin service to fetch replication
lag.

Caching like in sqlblob::facebook::myadmin will probably come in a follow
up change.

Reviewed By: StanislavGlebik

Differential Revision: D22104350

fbshipit-source-id: fbd90174d528ddae4045e957c343e6c213f70d26
2020-07-01 18:18:55 -07:00
Stefan Filip
bf61eb5c64 mononoke: add trait ReplicaLagMonitor
Summary:
ReplicaLagMonitor is aimed to generalize over different stategies of fetching
the replication lag in a SQL database. Querying a set of connections is one
such strategy.

Reviewed By: ikostia

Differential Revision: D22104348

fbshipit-source-id: bbbeccb55a664e60b3c14ee17f404982d09f2b25
2020-07-01 18:18:55 -07:00
Mark Thomas
60c5a1722b sql_ext: make sqlite LIKE case sensitive
Summary:
SQLite's `LIKE` operator is case insensitive by default.  This doesn't match MySQL, and
also seems like a surprising default.  Set the pragma on every connection to make it
case sensitive.

Reviewed By: farnz

Differential Revision: D22332419

fbshipit-source-id: 4f503eeaa874e110c03c27300467ddc02dc9b365
2020-07-01 11:08:43 -07:00
Stefan Filip
f586f46ca5 mononoke: move replication_lag utilities from blobstore_healer to sql_ext
Summary: I would like to use these utilities when building segmented changelog.

Reviewed By: krallin

Differential Revision: D21876432

fbshipit-source-id: 9022627e224bfcb155b47d696371d24e538e6f39
2020-06-11 12:38:50 -07:00
Stefan Filip
60966c93e7 autocargo: regenerate
Summary: maintenance

Reviewed By: StanislavGlebik

Differential Revision: D21640322

fbshipit-source-id: d0b2ce604735c05d540d06835c8e4c8a940fbf5c
2020-05-19 16:08:40 -07:00
Thomas Orozco
72b949340f mononoke: pretty-print root-cause
Summary:
Right now, we debug-print the root cause and pretty-print everything else. This
is pretty bad because the root cause is usually the one thing we would want to
pretty print so we can add instructions there (such as "your hooks failed, fix
it").

This fixes this so we stop pretty-printing the root cause, but also debug print
the whole error, which gives us more developer-friendly context and is easier
for automation to match on.

This is actually in common/rust ... but we're the only people using it AFAICT.

Reviewed By: StanislavGlebik

Differential Revision: D21522518

fbshipit-source-id: 10158811574b56024e14852229e4541da19d5609
2020-05-12 07:59:42 -07:00
Lukas Piatkowski
5975838cc8 mononoke/rust-shed: apply new coding style convention that separates oss-only code
Summary: To make it easier to navigate the codebase the oss-only code will be from now on stored in a separate module, similarly to how the fbcode-only code is stored.

Reviewed By: markbt

Differential Revision: D21429060

fbshipit-source-id: aa7e80961de2897dae31bd0ec83488c683633b7a
2020-05-07 04:52:16 -07:00
Lukas Piatkowski
2a1863c35d mononoke/server: make the main mononoke binary OSS buildable
Summary: Covering repo_listener and microwave plus some final touch and we have a buildable Mononoke binary.

Reviewed By: krallin

Differential Revision: D21379008

fbshipit-source-id: cca3fbb53b90ce6d2c3f3ced7717404d6b04dd51
2020-05-06 06:11:02 -07:00
Simon Farnsworth
92fce3d518 Clean out unused deps from our TARGETS files
Summary:
We had accumulated lots of unused dependendencies, and had several test_deps in deps instead. Clean this all up to reduce build times and speed up autocargo processing.

Net removal is of around 500 unneeded dependency lines, which represented false dependencies; by removing them, we should get more parallelism in dev builds, and less overbuilding in CI.

Reviewed By: krallin, StanislavGlebik

Differential Revision: D20999762

fbshipit-source-id: 4db3772cbc3fb2af09a16601bc075ae8ed6f0c75
2020-04-14 03:38:11 -07:00
Mark Thomas
5fb25674ea sql_ext: remove SqlConstructors
Summary: Now that everything is using `sql_construct`, we can remove the old `SqlConstructors` trait.

Reviewed By: StanislavGlebik

Differential Revision: D20734881

fbshipit-source-id: af46b41d17b40f6eb0839cdb9e85b00067360fe9
2020-04-02 05:27:16 -07:00
Mark Thomas
640f272598 migrate from sql_ext::SqlConstructors to sql_construct
Summary:
Migrate the configuration of sql data managers from the old configuration using `sql_ext::SqlConstructors` to the new configuration using `sql_construct::SqlConstruct`.

In the old configuration, sharded filenodes were included in the configuration of remote databases, even when that made no sense:
```
[storage.db.remote]
db_address = "main_database"
sharded_filenodes = { shard_map = "sharded_database", shard_num = 100 }

[storage.blobstore.multiplexed]
queue_db = { remote = {
    db_address = "queue_database",
    sharded_filenodes = { shard_map = "valid_config_but_meaningless", shard_num = 100 }
}
```

This change separates out:
* **DatabaseConfig**, which describes a single local or remote connection to a database, used in configuration like the queue database.
* **MetadataDatabaseConfig**, which describes the multiple databases used for repo metadata.

**MetadataDatabaseConfig** is either:
* **Local**, which is a local sqlite database, the same as for **DatabaseConfig**; or
* **Remote**, which contains:
    * `primary`, the database used for main metadata.
    * `filenodes`, the database used for filenodes, which may be sharded or unsharded.

More fields can be added to **RemoteMetadataDatabaseConfig** when we want to add new databases.

New configuration looks like:
```
[storage.metadata.remote]
primary = { db_address = "main_database" }
filenodes = { sharded = { shard_map = "sharded_database", shard_num = 100 } }

[storage.blobstore.multiplexed]
queue_db = { remote = { db_address = "queue_database" } }
```

The `sql_construct` crate facilitates this by providing the following traits:

* **SqlConstruct** defines the basic rules for construction, and allows construction based on a local sqlite database.
* **SqlShardedConstruct** defines the basic rules for construction based on sharded databases.
* **FbSqlConstruct** and **FbShardedSqlConstruct** allow construction based on unsharded and sharded remote databases on Facebook infra.
* **SqlConstructFromDatabaseConfig** allows construction based on the database defined in **DatabaseConfig**.
* **SqlConstructFromMetadataDatabaseConfig** allows construction based on the appropriate database defined in **MetadataDatabaseConfig**.
* **SqlShardableConstructFromMetadataDatabaseConfig** allows construction based on the appropriate shardable databases defined in **MetadataDatabaseConfig**.

Sql database managers should implement:

* **SqlConstruct** in order to define how to construct an unsharded instance from a single set of `SqlConnections`.
* **SqlShardedConstruct**, if they are shardable, in order to define how to construct a sharded instance.
* If the database is part of the repository metadata database config, either of:
    * **SqlConstructFromMetadataDatabaseConfig** if they are not shardable.  By default they will use the primary metadata database, but this can be overridden by implementing `remote_database_config`.
    * **SqlShardableConstructFromMetadataDatabaseConfig** if they are shardable.  They must implement `remote_database_config` to specify where to get the sharded or unsharded configuration from.

Reviewed By: StanislavGlebik

Differential Revision: D20734883

fbshipit-source-id: bb2f4cb3806edad2bbd54a47558a164e3190c5d1
2020-04-02 05:27:16 -07:00
Mark Thomas
662f8bfb1c sql_construct: add crate for constructing sql data managers
Summary:
Refactor `sql_ext::SqlConstructors` and its related traits into a separate
crate.  The new `SqlConstruct` trait is joined by `SqlShardedConstruct` which
allows construction of sharded databases.

The new crate will support a new configuration model where the distinction
between the database configuration for different repository metadata types
will be made clear.

Reviewed By: StanislavGlebik

Differential Revision: D20734882

fbshipit-source-id: b44cf9d1efd014c29df88e2ad933025e440119dc
2020-04-02 05:27:16 -07:00
Lukas Piatkowski
1bee1993a3 mononoke: make newfilenodes and blobstore/factory OSS buildable
Summary: In the process the blobstore/factory/lib.rs was split into submodules - this way it was easier to untangle the dependencies and refactor it, so I've left the split in this diff.

Reviewed By: markbt

Differential Revision: D20302068

fbshipit-source-id: caa3a2b5487c30198c62f7e4f4e9cb7c488dc8de
2020-03-31 04:02:45 -07:00
Lukas Piatkowski
9addbf08b1 mononoke: make metaconfig OSS buildable
Summary: This diff makes it possible to relay on the thrift structures from configerator in OSS.

Reviewed By: ahornby

Differential Revision: D20279457

fbshipit-source-id: 39df1c7a6f78b10a0a5bdeeebe476249ab674cc8
2020-03-27 08:13:47 -07:00
Lukas Piatkowski
963f3cc724 mononoke: make blobstore/sqlblob buildable in OSS
Summary:
This shifts the responsibility of mocking all facebook-specific code
to mononoke's sql_ext crate. If OSS code calls into any of that code it will
most likely result in a panic.

Reviewed By: ahornby

Differential Revision: D20247580

fbshipit-source-id: 43f158d91aa32adaa5df6e3786243fb89c9ce961
2020-03-27 08:13:47 -07:00
Lukas Piatkowski
6365fa6509 rust-shed: add no-op memcache_stub implementation to the shed
Reviewed By: mitrandir77

Differential Revision: D20304739

fbshipit-source-id: bd2956619f6a5cf1551bccb921780e7a542e9859
2020-03-10 01:07:46 -07:00
Lukas Piatkowski
7ddcdd818c mononoke: make sql_ext OSS buildable
Summary: separate out the Facebook-specific pieces of the sql_ext crate

Reviewed By: ahornby

Differential Revision: D20218219

fbshipit-source-id: e933c7402b31fcd5c4af78d5e70adafd67e91ecd
2020-03-06 01:33:38 -08:00
Thomas Orozco
c31b7d9ef9 mononoke/newfilenodes: introduce remote caching
Summary:
This introduces caching of filenodes to Memcache as in the old filenodes
implementation. The code is mostly was ported over from the existing filenodes
implementation, and converted to async / await. However, one key difference is
that the lookups happen once we hold the semaphore to talk to the underlying
MySQL shard.

The reason for this is:

- Reads to Memcache are really fast. They're often under 1ms. If you're going
  to miss in Memcache and have to go to SQL, it won't make you much slower.
- Reads to Memcache are kinda expensive CPU-wise. Data in Memcache is
  compressed, and we often see a lot of our CPU cycles spent talking to Memache
  when we're under load.
- Memcache isn't an infinite resource. If we're reading the exact same
  key a hundred times, that's going to hit the same Memcache box. A bit of
  deduplication on our end is a nice thing to strive for. Besides, our own
  thread pool we use to talk to Memcache is limited in size.

From a performance perspective, this doesn't make things any slower, but
reduces CPU usage when we'd otherwise have a lot of duplicate fetching.

Finally, note that this update also includes support for dirty-tracking in our
local cache. We use this to know if we should fill the remote cache (if we 100%
hit in local cache, we don't fill the remote cache).

Reviewed By: StanislavGlebik

Differential Revision: D19905390

fbshipit-source-id: 363f638bb24cf488c7cd3a8ecea43e93f8391d3f
2020-02-27 12:34:19 -08:00
Lukas Piatkowski
4aea99df4e mononoke/blobstore: remove rocksdb blobstore and replace its usages with sqliteblob
Summary:
This is the second (and last) step on removing RocksDB as a blobstore.
Check the task for more description.

Context for OSS:
> The issue with rocksblob (and to some extent sqlite) is that unless we
> introduce a blobstore tier/thift api (which is something I'm hoping to avoid
> for xdb blobstore) we'd have to combine all the mononoke function like hg,
> scs, LFS etc into one binary for it to have access to rocksdb, which would be
> quite a big difference to how we deploy internally

(Note: this ignores all push blocking failures!)

Reviewed By: farnz

Differential Revision: D20001261

fbshipit-source-id: c4b2b2a393b918d17680ad483aa1d77356f1d07c
2020-02-24 05:23:07 -08:00
Thomas Orozco
ef1ffa31e8 mononoke/sql_ext: log which shard we are waiting for in myrouter
Summary:
MyRouter needs to be told which shards to watch. Since I'm adding a new shard,
it'll be easier for everyone to know that they need to update their MyRouter
configuration if we start logging the shard name we're trying to hit.

Reviewed By: ikostia

Differential Revision: D20001704

fbshipit-source-id: 8a9ff3521bc7e3c9b7ed39c6ae33d0ddc1d467b7
2020-02-20 07:55:04 -08:00
Stanislau Hlebik
3d64ea8b50 mononoke: always prefer replica even if it's no the closest
Reviewed By: farnz

Differential Revision: D19906883

fbshipit-source-id: 6eadd7fc7e9b8f1bdce311e9beda1d185c72f94c
2020-02-14 11:03:55 -08:00
Lukasz Piatkowski
542d1f93d3 Manual synchronization of fbcode/eden and facebookexperimental/eden
Summary:
This commit manually synchronizes the internal move of
fbcode/scm/mononoke under fbcode/eden/mononoke which couldn't be
performed by ShipIt automatically.

Reviewed By: StanislavGlebik

Differential Revision: D19722832

fbshipit-source-id: 52fbc8bc42a8940b39872dfb8b00ce9c0f6b0800
2020-02-11 11:42:43 +01:00
Lukasz Piatkowski
e8d62b64d5 mononoke: move the codebase under eden/ directory
fbshipit-source-id: 43a0252cb3ec42aa365f20d1b6faa4d24d74c9b8
2020-02-06 13:46:04 +01:00