gh-ost
gh-ost copied to clipboard
Consolidate fetching of MySQL server info
Description
This PR consolidates the many queries and functions that fetch MySQL server runtime configuration into a single struct and function: mysql.ServerInfo and mysql.GetServerInfo(...) (*ServerInfo, error) respectively. This reduces the server-info-related MySQL queries from 6 -> 2
Now server information for both the applier and inspector are stored in the migration context as single structs
Notes:
- To handle cases where
@@global.portand@@global.extra_portareNULLagosql.NullInt64was used when cleaning upbase.ValidateConnection(...)- This required
Portfrommysql.InstanceKeyto becomeint64as there is nogosql.NullInt
- This required
- Removed duplicate
base.ValidateConnection(...)on the applier'sthis.singletonDBdatabase handle as it is the same host as the already-validatedthis.dbhandle- This resolves these confusing/duplicate log lines:
2022-12-10 04:20:29 INFO applier connection validated on primary:3306 2022-12-10 04:20:29 INFO applier connection validated on primary:3306
- This resolves these confusing/duplicate log lines:
- The
Applier initiated on %+v, version %+vlog-lines now include the@@global.version_comment(in brackets) for more info - Unit test added to
base.ValidateConnection(...)now that it takes inserverInfo *mysql.ServerInfovs a harder-to-testdb *sql.DB - Moved
migrationContext.RequiresBinlogFormatChange(...)to inspector because it's never called outside of inspector- Added unit test
- Remove unused
.validateAndReadTimeZone()func from applier
In case this PR introduced Go code changes:
- [x] contributed code is using same conventions as original code
- [x]
script/cibuildreturns with no formatting errors, build errors or unit test errors.
HI @timvaillancourt :wave: do you still want to add this one to 1.1.7 or should we push it out? I'm planning to cut a release this week or next