gh-ost icon indicating copy to clipboard operation
gh-ost copied to clipboard

Consolidate fetching of MySQL server info

Open timvaillancourt opened this issue 3 years ago • 1 comments

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.port and @@global.extra_port are NULL a gosql.NullInt64 was used when cleaning up base.ValidateConnection(...)
    • This required Port from mysql.InstanceKey to become int64 as there is no gosql.NullInt
  • Removed duplicate base.ValidateConnection(...) on the applier's this.singletonDB database handle as it is the same host as the already-validated this.db handle
    • 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
      
  • The Applier initiated on %+v, version %+v log-lines now include the @@global.version_comment (in brackets) for more info
  • Unit test added to base.ValidateConnection(...) now that it takes in serverInfo *mysql.ServerInfo vs a harder-to-test db *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/cibuild returns with no formatting errors, build errors or unit test errors.

timvaillancourt avatar Dec 12 '22 22:12 timvaillancourt

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

meiji163 avatar Dec 19 '24 02:12 meiji163