Skip to content

Commit 3c90745

Browse files
committed
readyset: Verify estimated snapshot size at startup
When starting Readyset, try to determine how much space a snapshot of the upstream will consume, and fail the startup verification if it looks as though we won't have enough space to accommodate the entire snapshot. Our verification relies on a few assumptions: - The reported sizes of the upstream tables are basically correct - All databases (MySQL) or schemas (PostgreSQL) will be replicated - The tables will take about twice the space when stored in Readyset Skip this verification check if the user has specified any tables via the --replication-tables or --replication-tables-ignore arguments. We can consider a more granular approach in the future. Fixes: REA-5937 Release-Note-Core: Add pre-snapshot verification checks to help find potential configuration issues earlier. The argument --verify can be used to run only the verification checks and then exit. The argument --verify-skip can be used to skip the verification checks and continue with normal startup. Change-Id: I1a59c7bad465f87b59f1c1ce6062616d779579bb Reviewed-on: https://gerrit.readyset.name/c/readyset/+/10601 Reviewed-by: Michael Zink <michael.z@readyset.io> Tested-by: Buildkite CI
1 parent 765eec1 commit 3c90745

File tree

9 files changed

+216
-19
lines changed

9 files changed

+216
-19
lines changed

Cargo.lock

Lines changed: 106 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ derive_more = { version = "2.0.1", features = [
132132
"display",
133133
] }
134134
diff = "0.1.13"
135+
dir-size = "0.1"
135136
enum-display-derive = "0.1.1"
136137
enum-kinds = "0.5.1"
137138
enum_dispatch = "0.3.13"
@@ -241,6 +242,7 @@ streaming-iterator = "0.1"
241242
stringprep = "0.1.4"
242243
strum = { version = "0.27", features = ["derive"] }
243244
syn = { version = "2.0.87", default-features = false }
245+
sysinfo = "0.37"
244246
temp-dir = "0.1"
245247
tempfile = "3.10.1"
246248
test-strategy = "0.4.3"

readyset-server/src/lib.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,11 @@ pub struct WorkerOptions {
746746
}
747747

748748
impl WorkerOptions {
749-
pub fn storage_dir(&self) -> Option<PathBuf> {
750-
if let Some(s) = &self.storage_dir {
751-
return Some(s.to_path_buf());
752-
}
753-
None
749+
pub fn storage_dir(&self, deployment: &str) -> PathBuf {
750+
self.storage_dir
751+
.clone()
752+
.unwrap_or_else(|| PathBuf::from("."))
753+
.join(deployment)
754754
}
755755

756756
pub fn working_dir(&self) -> Option<PathBuf> {
@@ -837,14 +837,22 @@ mod tests {
837837
/// Test setting the storage directory
838838
#[test]
839839
fn storage_and_db_dirs() {
840+
let deployment = "readyset.db";
841+
840842
// test the unset variant
841843
let worker_opts = Wrapper::parse_from(["test"]).worker_opts;
842-
assert_eq!(None, worker_opts.storage_dir());
844+
assert_eq!(
845+
PathBuf::from(".").join(deployment),
846+
worker_opts.storage_dir(deployment)
847+
);
843848

844849
// the test the --storage-dir cli flag
845850
let storage_dir = "/tmp/cli-flag-storage";
846851
let worker_opts = Wrapper::parse_from(["test", "--storage-dir", storage_dir]).worker_opts;
847-
assert_eq!(Some(PathBuf::from(storage_dir)), worker_opts.storage_dir());
852+
assert_eq!(
853+
PathBuf::from(storage_dir).join(deployment),
854+
worker_opts.storage_dir(deployment)
855+
);
848856
}
849857

850858
#[test]

readyset-server/src/main.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::net::{IpAddr, SocketAddr};
2-
use std::path::PathBuf;
32
use std::process;
43
use std::sync::Arc;
54
use std::time::Duration;
@@ -221,12 +220,7 @@ fn main() -> anyhow::Result<()> {
221220
info!(%volume_id);
222221
}
223222

224-
let deployment_dir = opts
225-
.worker_options
226-
.storage_dir()
227-
.unwrap_or_else(|| PathBuf::from("."))
228-
.join(&opts.deployment);
229-
223+
let deployment_dir = opts.worker_options.storage_dir(&opts.deployment);
230224
let authority = opts.authority.clone();
231225
let authority_addr = match authority {
232226
AuthorityType::Standalone => deployment_dir

readyset/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ antithesis_sdk = { workspace = true }
1414
anyhow = { workspace = true }
1515
clap = { workspace = true, features = ["derive", "env"] }
1616
crossbeam-skiplist = { workspace = true }
17+
dir-size = { workspace = true }
1718
futures-util = { workspace = true }
1819
fail = { workspace = true }
1920
failpoint-macros = { path = "../failpoint-macros" }
2021
metrics = { workspace = true }
2122
mysql_common = { workspace = true }
2223
regex = { workspace = true }
2324
reqwest = { workspace = true, features = ["json"] }
25+
sysinfo = { workspace = true }
2426
thiserror = { workspace = true }
2527
tokio = { workspace = true, features = ["full"] }
2628
tokio-native-tls = { workspace = true }

readyset/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -793,10 +793,7 @@ where
793793

794794
let deployment_dir = options
795795
.server_worker_options
796-
.storage_dir()
797-
.unwrap_or_else(|| PathBuf::from("."))
798-
.join(&options.deployment);
799-
796+
.storage_dir(&options.deployment);
800797
let upstream_config = options.server_worker_options.replicator_config.clone();
801798

802799
if options.cleanup {

0 commit comments

Comments
 (0)