Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout handling for MariaDB + trilogy adapter compatibility #81

Closed
mateuszgorniak opened this issue Sep 12, 2024 · 1 comment
Closed

Comments

@mateuszgorniak
Copy link
Contributor

mateuszgorniak commented Sep 12, 2024

Description

In the current version of the gem, there is an issue with handling SQL timeout configurations for MariaDB databases. While the timeout setting logic works well for PostgreSQL and MySQL, it raises an error when used with MariaDB:

Mysql2::Error: Unknown system variable 'max_execution_time' (Mysql2::Error)

This error occurs because MariaDB does not support the max_execution_time system variable, which is specific to MySQL. Instead, MariaDB uses MAX_STATEMENT_TIME (available from version 10.2).

Another potential issue is the reliance on the mysql adapter. Since Rails 7.1, the trilogy adapter is the default.

Steps to Reproduce

  1. Set up a Rails application that connects to a MariaDB database.
  2. Define deploy_pin task and try to execute it.
  3. The query execution will fail with the aforementioned error.

Suggested Fix

To ensure compatibility with MariaDB and trilogy, we can:

  1. Determine whether the connection is to MariaDB or MySQL. Since both databases may use the same adapter (mysql2 or trilogy), differentiating them based solely on the adapter name is unreliable. I'd suggest rather configuring it as a part of the DeployPin configuration.
  2. Use the correct timeout statement based on the server type:
    • For MariaDB, use SET SESSION max_statement_time = %s.
    • For MySQL, continue using SET max_execution_time = %s.
    • For PostgreSQL, continue using SET statement_timeout TO %s.

I'd be happy to assist with the implementation if needed! 😊

@mateuszgorniak mateuszgorniak changed the title Timeout handling for MariaDB + trillogy adapter compatibility Timeout handling for MariaDB + trilogy adapter compatibility Sep 13, 2024
@skcc321
Copy link
Owner

skcc321 commented Sep 19, 2024

Hello @mateuszgorniak,
Feel free to submit a PR. I'm on board with adding support for MariaDB. Please include it in the CI matrix as well.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants