Skip to content

Commit

Permalink
more placeholder adjustments
Browse files Browse the repository at this point in the history
Add more rules to replace_placeholders to remove "..." from
digest coming from proxysql.

Fixed warmup_time config in .cnf file.
  • Loading branch information
altmannmarcelo committed Oct 29, 2024
1 parent c92a27a commit a519420
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ This scheduler executes the following steps:
2. If `mode=(All|HealthCheck)` - Query `mysql_servers` and check all servers that have `comment='Readyset` (case insensitive) and `hostgroup=readyset_hostgroup`. For each server it checks if it can connect to Readyset and validate if `Snapshot Status` is `Completed`. In case it cannot connect or Readyset is still performing snapshot it adjust the server status to `SHUNNED` in ProxySQL.
3. If `mode=(All|QueryDiscovery)` Query the table `stats_mysql_query_digest` finding queries executed at `source_hostgroup` by `readyset_user` and validates if each query is supported by Readyset. The rules to order queries are configured by [Query Discovery](#query-discovery) configurations.
3. If the query is supported it adds a cache in Readyset by executing `CREATE CACHE FROM __query__`.
4. If `warmup_time` is NOT configure, a new query rule will be added redirecting this query to Readyset
5. If `warmup_time` is configured, a new query rule will be added to mirror this query to Readyset. The query will still be redirected to the original hostgroup
6. Once `warmup_time` seconds has elapsed since the query was mirrored, the query rule will be updated to redirect the query to Readyset instead of mirroring.
4. If `warmup_time_s` is NOT configure, a new query rule will be added redirecting this query to Readyset
5. If `warmup_time_s` is configured, a new query rule will be added to mirror this query to Readyset. The query will still be redirected to the original hostgroup
6. Once `warmup_time_s` seconds has elapsed since the query was mirrored, the query rule will be updated to redirect the query to Readyset instead of mirroring.



Expand Down Expand Up @@ -44,7 +44,7 @@ Configure `/etc/readyset_proxysql_scheduler.cnf` as follow:
* `readyset_password` - (Required) - Readyset application password
* `source_hostgroup` - (Required) - Hostgroup running your Read workload
* `readyset_hostgroup` - (Required) - Hostgroup where Readyset is configure
* `warmup_time` - (Optional) - Time in seconds to mirror a query supported before redirecting the query to Readyset (Default 0 - no mirror)
* `warmup_time_s` - (Optional) - Time in seconds to mirror a query supported before redirecting the query to Readyset (Default 0 - no mirror)
* `lock_file` - (Optional) - Lock file to prevent two instances of the scheduler to run at the same time (Default '/etc/readyset_scheduler.lock')
* `operation_mode` - (Optional) - Operation mode to run the scheduler. The options are described in [Operation Mode](#operation-mode) (Default All).
* `number_of_queries` - (Optional) - Number of queries to cache in Readyset (Default 10).
Expand Down
2 changes: 1 addition & 1 deletion readyset_proxysql_scheduler.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ readyset_user = 'root'
readyset_password = 'root'
source_hostgroup = 11
readyset_hostgroup = 99
warmup_time = 60
warmup_time_s = 60
lock_file = '/tmp/readyset_scheduler.lock'
operation_mode="All"
number_of_queries=10
Expand Down
5 changes: 3 additions & 2 deletions src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl QueryDiscovery {
rows.iter()
.map(|(digest_text, digest, schema)| {
Query::new(
digest_text.to_string(),
self.replace_placeholders(digest_text),
digest.to_string(),
schema.to_string(),
self.readyset_user.clone(),
Expand All @@ -257,6 +257,7 @@ impl QueryDiscovery {

fn replace_placeholders(&self, query: &str) -> String {
// date placeholder
query.replace("?-?-?", "?")
// multiple placeholders
query.replace("?,?,?,...", "?,?,?").replace("?-?-?", "?")
}
}

0 comments on commit a519420

Please sign in to comment.