Skip to content

Commit

Permalink
Force cache creation to set default schema
Browse files Browse the repository at this point in the history
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
Readyset server, we will not execute the dry-run on the second server
onwards. This will cause the cache creation to fail as the default
schema is not set.

This commit forces the default schema to be set before attempting to
create a cache.

Fixes: #31
  • Loading branch information
altmannmarcelo committed Dec 2, 2024
1 parent c58e79e commit 670e6ef
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,13 @@ impl QueryDiscovery {
queries_added_or_change = true;
if !proxysql.dry_run() {
proxysql.get_online_hosts().iter_mut().for_each(|host| {
host.cache_query(query).expect(
format!(
host.cache_query(query).unwrap_or_else(|_| {
panic!(
"Failed to create readyset cache on host {}:{}",
host.get_hostname(),
host.get_port()
)
.as_str(),
);
});
});
proxysql
.add_as_query_rule(query)
Expand Down

0 comments on commit 670e6ef

Please sign in to comment.