Skip to content

Commit 91a66b6

Browse files
Force cache creation to set default schema
Force connection to set the default schema before attempting to create a cache. We use one single connection per host. During cache creation dry-run we enforce the default schema to be set, but During actual cache creation we do not. In case a client has more than one schema, we might end up attempting to create the cache in the wrong schema or cache creation might fail due to the table not being found.
1 parent fd19b11 commit 91a66b6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/hosts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ impl Host {
222222
)))
223223
}
224224
Some(conn) => {
225+
conn.query_drop(format!("USE {}", query.get_schema()))?;
225226
conn.query_drop(format!(
226227
"CREATE CACHE d_{} FROM {}",
227228
query.get_digest(),

src/queries.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,13 @@ impl QueryDiscovery {
195195
queries_added_or_change = true;
196196
if !proxysql.dry_run() {
197197
proxysql.get_online_hosts().iter_mut().for_each(|host| {
198-
host.cache_query(query)
199-
.expect("Failed to create readyset cache");
198+
host.cache_query(query).unwrap_or_else(|_| {
199+
panic!(
200+
"Failed to create readyset cache on host {}:{}",
201+
host.get_hostname(),
202+
host.get_port()
203+
)
204+
});
200205
});
201206
proxysql
202207
.add_as_query_rule(query)

0 commit comments

Comments
 (0)