diff --git a/changelog/23.0/23.0.0/summary.md b/changelog/23.0/23.0.0/summary.md index d8cd8f8a2c7..a94c0bf7c0b 100644 --- a/changelog/23.0/23.0.0/summary.md +++ b/changelog/23.0/23.0.0/summary.md @@ -71,3 +71,9 @@ ALTER USER 'vt_repl'@'%' IDENTIFIED WITH caching_sha2_password BY 'your-existing ``` In future Vitess versions, the `mysql_native_password` authentication plugin will be disabled for managed MySQL instances. + +#### MySQL timezone environment propagation + +Fixed a bug where environment variables like `TZ` were not propagated from mysqlctl to the mysqld process. +As a result, timezone settings from the environment were previously ignored. Now mysqld correctly inherits environment variables. +⚠️ Deployments that relied on the old behavior and explicitly set a non-UTC timezone may see changes in how DATETIME values are interpreted. To preserve compatibility, set `TZ=UTC` explicitly in MySQL pods. diff --git a/go/vt/mysqlctl/mysqld.go b/go/vt/mysqlctl/mysqld.go index bcdd2dd4d48..cec4452d76e 100644 --- a/go/vt/mysqlctl/mysqld.go +++ b/go/vt/mysqlctl/mysqld.go @@ -1264,9 +1264,11 @@ func (mysqld *Mysqld) OnTerm(f func()) { } func buildLdPaths() ([]string, error) { + baseEnv := os.Environ() + vtMysqlRoot, err := vtenv.VtMysqlRoot() if err != nil { - return []string{}, err + return baseEnv, err } ldPaths := []string{ @@ -1274,7 +1276,7 @@ func buildLdPaths() ([]string, error) { os.ExpandEnv("LD_PRELOAD=$LD_PRELOAD"), } - return ldPaths, nil + return append(baseEnv, ldPaths...), nil } // GetVersionString is part of the MysqlExecutor interface. diff --git a/go/vt/mysqlctl/mysqld_test.go b/go/vt/mysqlctl/mysqld_test.go index a304e9e9f4c..6037cddf30d 100644 --- a/go/vt/mysqlctl/mysqld_test.go +++ b/go/vt/mysqlctl/mysqld_test.go @@ -350,3 +350,12 @@ func TestGetMycnfTemplateMySQL9(t *testing.T) { assert.Contains(t, template, "# This file is auto-included when MySQL 9.0 or later is detected.") assert.NotContains(t, template, "mysql_native_password = ON") } + +func TestBuildLdPathsTZ(t *testing.T) { + os.Setenv("TZ", "Europe/Berlin") + defer os.Unsetenv("TZ") + + env, err := buildLdPaths() + assert.NoError(t, err) + assert.Contains(t, env, "TZ=Europe/Berlin") +}