Skip to content

Commit 16a8439

Browse files
committed
replicators: Allow --replication-tables-ignore '*.*'
Starting Readyset with --replication-tables-ignore '*.*' will now deny all tables. This is intended to be useful for deployments that want to initially start Readyset without replicating anything. If desired, tables can still be added to a Readyset process running in this mode via the ALTER READYSET ADD TABLES command. Addresses: REA-5257 Change-Id: If2502611902a1e9685dbd58475f386ff66d79938 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/8727 Tested-by: Buildkite CI Reviewed-by: Jason Brown <jason.b@readyset.io>
1 parent c9bcbc5 commit 16a8439

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

database-utils/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ pub struct UpstreamConfig {
119119
/// schema) or `<schema>.*` (all tables in a schema) for Postgres and `<database>.<table>`
120120
/// for MySQL.
121121
///
122+
/// You can also specify "*.*" to indicate that no tables should be replicated at all.
123+
///
122124
/// Tables specified in the list will not be eligible to be used by caches.
123125
#[arg(long, env = "REPLICATION_TABLES_IGNORE")]
124126
#[serde(default)]

replicators/src/table_filter.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ impl TableFilter {
132132
})
133133
}
134134

135+
fn deny_all() -> Self {
136+
Self {
137+
strategy_by_schema: HashMap::new(),
138+
allow_unregistered_schemas: false,
139+
}
140+
}
141+
135142
pub(crate) fn try_new(
136143
dialect: Dialect,
137144
replication_tables: Option<&str>,
@@ -148,9 +155,7 @@ impl TableFilter {
148155
return Ok(Self::allow_all());
149156
}
150157
if let Some("*.*") = replication_tables_ignore {
151-
return Err(ReadySetError::ReplicationFailed(
152-
"Cannot filter out all tables".to_string(),
153-
));
158+
return Ok(Self::deny_all());
154159
}
155160

156161
let allow_unregistered_schemas = replication_tables.is_none() && default_schema.is_none();
@@ -378,4 +383,16 @@ mod tests {
378383
assert!(!filter.should_be_processed("readyset", "t4"));
379384
assert!(filter.should_be_processed("readyset", "table"));
380385
}
386+
387+
#[test]
388+
fn wildcard_deny_list() {
389+
let filter = TableFilter::try_new(
390+
readyset_sql::Dialect::MySQL,
391+
None,
392+
Some("*.*"),
393+
Some("noria"),
394+
)
395+
.unwrap();
396+
assert!(!filter.should_be_processed("noria", "t1"));
397+
}
381398
}

0 commit comments

Comments
 (0)