Skip to content
/ server Public

MDEV-39008 FederatedX: set time_zone on connection change#4791

Open
PeterKoletzki wants to merge 1 commit intoMariaDB:10.11from
PeterKoletzki:bb-10.11-MDEV-39008-federatedx-timestamp-timezone
Open

MDEV-39008 FederatedX: set time_zone on connection change#4791
PeterKoletzki wants to merge 1 commit intoMariaDB:10.11from
PeterKoletzki:bb-10.11-MDEV-39008-federatedx-timestamp-timezone

Conversation

@PeterKoletzki
Copy link

@PeterKoletzki PeterKoletzki commented Mar 12, 2026

When the underlying connection to the remote server changes (e.g. load balancer switching nodes or driver reconnect), the session variable time_zone was not set again. TIMESTAMP values could then be wrong.

Track the connection (mysql.net.vio) and re-send SET time_zone='+00:00' when the vio changes so TIMESTAMP remains consistent.

When the underlying connection to the remote server changes (e.g. load
balancer switching nodes or driver reconnect), the session variable
time_zone was not set again. TIMESTAMP values could then be wrong.

Track the connection (mysql.net.vio) and re-send SET time_zone='+00:00'
when the vio changes so TIMESTAMP remains consistent.

Made-with: Cursor
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Mar 12, 2026
Copy link
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

I'd love if you would consider adding a regression test for this. It can be as simple as:

  1. open a federatedX conneciton
  2. restart the remote server
  3. try a query that requires a timezone
  4. try another query that requires a timezone
  5. cleanup

A slightly more advanced version would be to add a DBUG_EXECUTE_IF() with a unique key name, that, when set, will disconnect the federatedX session before the next query. And then do as the above, but instead of restarting the remote just set the flag on the federatedX server.

time_zone_set_vio= mysql.net.vio;
mysql.reconnect= 1;
}
else if (mysql.net.vio != time_zone_set_vio)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer that you develop a single boolean flag: e.g. needs_to_set_timezone and set it where it needs to be set. And then add a single check for it right before mysql_real_query() and set the timezone.

Note that this still has a potential for error: if you haven't detected the disconnect yet the first query you execute will be executed sans timezone set. The ones that follow will execute timezone set. But the first one will be off.

This is because automatic reconnect is done inside the client library. And it will automatically retry the same query right after re-connecting on its own.

So, MYSQL.reconnect should not be used for anything that can depend on session state. This is why the mariadb CLI is implementing its own, client app level reconnect.

If you really want to fix this in all cases, please consider removing the use of MYSQL.reconnect and do as mysql.cc does.

I will take the minor refactoring suggested in the first paragraph too. But I would like you to consider doing the full fix first.

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

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

4 participants