Skip to content

Commit

Permalink
readyset-mysql: Disable statement cache
Browse files Browse the repository at this point in the history
mysql_async has a "statement cache" feature, which limits the number of
prepared statements that exist on a given connection at one time. This
is enabled by default with a value of 32. When the number of prepared
statement exceeds 32, a previously-created prepared statement is
deallocated, which results in errors when a client attempts to execute
it.

This commit disables this statement cache to ensure that we can support
an arbitrary number of prepared statements (as we do for Postgres).

Release-Note-Core: Fixed an issue where the number of prepared
  statements for a MySQL connection was limited to 32
Change-Id: I1050e2df98a95a9d8c73c54b957ffd65e381b87b
  • Loading branch information
ethowitz committed Apr 23, 2024
1 parent ea4cba8 commit a44de3a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions readyset-mysql/src/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,17 @@ impl MySqlUpstream {
.as_deref()
.ok_or(ReadySetError::InvalidUpstreamDatabase)?;

let mut opts =
Opts::from_url(url).map_err(|e: UrlError| Error::MySql(mysql_async::Error::Url(e)))?;
let mut builder = {
let opts = Opts::from_url(url)
.map_err(|e: UrlError| Error::MySql(mysql_async::Error::Url(e)))?;
OptsBuilder::from_opts(opts).stmt_cache_size(0)
};

if let Some(cert_path) = upstream_config.ssl_root_cert.clone() {
let ssl_opts = SslOpts::default().with_root_certs(vec![cert_path.into()]);
opts = OptsBuilder::from_opts(opts).ssl_opts(ssl_opts).into();
builder = builder.ssl_opts(ssl_opts);
}
let opts: Opts = builder.into();

let span = info_span!(
"Connecting to MySQL upstream",
Expand Down

0 comments on commit a44de3a

Please sign in to comment.