// Open must be called before sending requests to QueryEngine. func (qe *QueryEngine) Open(dbconfigs *dbconfigs.DBConfigs, schemaOverrides []SchemaOverride, mysqld *mysqlctl.Mysqld) { qe.dbconfigs = dbconfigs connFactory := dbconnpool.DBConnectionCreator(&dbconfigs.App.ConnectionParams, mysqlStats) // Create dba params based on App connection params // and Dba credentials. dba := dbconfigs.App.ConnectionParams if dbconfigs.Dba.Uname != "" { dba.Uname = dbconfigs.Dba.Uname dba.Pass = dbconfigs.Dba.Pass } dbaConnFactory := dbconnpool.DBConnectionCreator(&dba, mysqlStats) strictMode := false if qe.strictMode.Get() != 0 { strictMode = true } if !strictMode && dbconfigs.App.EnableRowcache { panic(NewTabletError(FATAL, "Rowcache cannot be enabled when queryserver-config-strict-mode is false")) } if dbconfigs.App.EnableRowcache { qe.cachePool.Open() log.Infof("rowcache is enabled") } else { // Invalidator should not be enabled if rowcache is not enabled. dbconfigs.App.EnableInvalidator = false log.Infof("rowcache is not enabled") } start := time.Now() // schemaInfo depends on cachePool. Every table that has a rowcache // points to the cachePool. qe.schemaInfo.Open(dbaConnFactory, schemaOverrides, qe.cachePool, strictMode) log.Infof("Time taken to load the schema: %v", time.Now().Sub(start)) // Start the invalidator only after schema is loaded. // This will allow qe to find the table info // for the invalidation events that will start coming // immediately. if dbconfigs.App.EnableInvalidator { qe.invalidator.Open(dbconfigs.App.DbName, mysqld) } qe.connPool.Open(connFactory) qe.streamConnPool.Open(connFactory) qe.txPool.Open(connFactory) qe.connKiller.Open(dbaConnFactory) }
// NewMysqld creates a Mysqld object based on the provided configuration // and connection parameters. // name is the base for stats exports, use 'Dba', except in tests func NewMysqld(name string, config *Mycnf, dba, repl *mysql.ConnectionParams) *Mysqld { if *dba == dbconfigs.DefaultDBConfigs.Dba { dba.UnixSocket = config.SocketFile } // create and open the connection pool for dba access mysqlStats := stats.NewTimings("Mysql" + name) dbaPool := dbconnpool.NewConnectionPool(name+"ConnPool", *dbaPoolSize, *dbaIdleTimeout) dbaPool.Open(dbconnpool.DBConnectionCreator(dba, mysqlStats)) return &Mysqld{ config: config, dba: dba, dbaPool: dbaPool, replParams: repl, TabletDir: TabletDir(config.ServerId), SnapshotDir: SnapshotDir(config.ServerId), } }