Skip to content

MySQL EventListener: Ignore schema creation errors on startup if MySQL is down #26254

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielbelchior
Copy link

@danielbelchior danielbelchior commented Jul 21, 2025

Description

Currently, when the Trino coordinator starts, the MySQL Event Listener plugin attempts to connect to the MySQL database to validate the schema. However, if the MySQL server is temporarily unavailable (e.g., during restart or maintenance), the coordinator fails to start entirely, causing the entire Trino service to remain offline.

Additional context and related issues

  • Wrap the schema creation (dao.createTable()) in a try-catch block in MysqlEventListener.
  • Catch java.sql.SQLException specifically to handle connection issues such as timeouts or connection refused.
  • Log a warning and continue startup if a connection error occurs, so Trino does not fail to start when MySQL is unavailable.
  • Catch and log any other unexpected exceptions as well.
  • This ensures Trino remains available even if the MySQL database is temporarily down at startup.

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(X) Release notes are required, with the following suggested text:

## MySQL event Listener
* Handle MySQL connection failure gracefully during coordinator startup. ({issue}`26252`)

Closes: #26252

Copy link

cla-bot bot commented Jul 21, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@danielbelchior danielbelchior force-pushed the mysql-event-listener-catch-mysql-connection-error branch from a3f1164 to 7e211c7 Compare July 22, 2025 06:36
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

1 similar comment
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@danielbelchior danielbelchior force-pushed the mysql-event-listener-catch-mysql-connection-error branch from a3d2f77 to 1c755fc Compare July 22, 2025 09:09
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@danielbelchior danielbelchior force-pushed the mysql-event-listener-catch-mysql-connection-error branch from 1c755fc to d3ea939 Compare July 22, 2025 09:11
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@danielbelchior danielbelchior force-pushed the mysql-event-listener-catch-mysql-connection-error branch from d3ea939 to 7b7bd7d Compare July 22, 2025 21:44
Copy link

cla-bot bot commented Jul 22, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@ebyhr
Copy link
Member

ebyhr commented Jul 22, 2025

Please follow the commit message guideline. https://trino.io/development/process.html#pull-request-and-commit-guidelines-

@danielbelchior danielbelchior force-pushed the mysql-event-listener-catch-mysql-connection-error branch from 7b7bd7d to 3d3ddac Compare July 23, 2025 10:55
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

Add a new configuration key,
`mysql-event-listener.terminate-on-initialization-failure`, to
control how Trino behaves when the MySQL database is unreachable
during startup.

Previously, Trino would fail to start if MySQL was down. With this
option, users can choose whether startup should fail or continue,
improving resilience and flexibility in various deployment
scenarios.
@danielbelchior danielbelchior force-pushed the mysql-event-listener-catch-mysql-connection-error branch from 3d3ddac to 71184bd Compare July 23, 2025 11:08
Copy link

cla-bot bot commented Jul 23, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

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

Successfully merging this pull request may close these issues.

MySQL Event Listener - Trino coordinator fails to start if MySQL is unavailable during schema validation
3 participants