зеркало из https://github.com/github/vitess-gh.git
Let TableACL clear query plan cache on acl reload
This commit is contained in:
Родитель
7ee787d822
Коммит
b7736ff2ac
|
@ -83,19 +83,24 @@ func main() {
|
|||
}
|
||||
dbcfgs.App.EnableRowcache = *enableRowcache
|
||||
|
||||
if *tableAclConfig != "" {
|
||||
tableacl.Register("simpleacl", &simpleacl.Factory{})
|
||||
tableacl.Init(*tableAclConfig)
|
||||
} else if *enforceTableACLConfig {
|
||||
log.Error("table acl config has to be specified with table-acl-config flag because enforce-tableacl-config is set.")
|
||||
exit.Return(1)
|
||||
}
|
||||
|
||||
// creates and registers the query service
|
||||
qsc := tabletserver.NewServer()
|
||||
qsc.Register()
|
||||
binlog.RegisterUpdateStreamService(mycnf)
|
||||
|
||||
if *tableAclConfig != "" {
|
||||
tableacl.Register("simpleacl", &simpleacl.Factory{})
|
||||
tableacl.Init(
|
||||
*tableAclConfig,
|
||||
func() {
|
||||
qsc.ClearQueryPlanCache()
|
||||
},
|
||||
)
|
||||
} else if *enforceTableACLConfig {
|
||||
log.Error("table acl config has to be specified with table-acl-config flag because enforce-tableacl-config is set.")
|
||||
exit.Return(1)
|
||||
}
|
||||
|
||||
// Create mysqld and register the health reporter (needs to be done
|
||||
// before initializing the agent, so the initial health check
|
||||
// done by the agent has the right reporter)
|
||||
|
|
|
@ -63,8 +63,11 @@ type tableACL struct {
|
|||
// currentACL stores current effective ACL information.
|
||||
var currentACL tableACL
|
||||
|
||||
// aclCallback is the tablet callback executed on table acl reload.
|
||||
var aclCallback func()
|
||||
|
||||
// Init initiates table ACLs.
|
||||
func Init(configFile string) {
|
||||
func Init(configFile string, aclCB func()) {
|
||||
data, err := ioutil.ReadFile(configFile)
|
||||
if err != nil {
|
||||
log.Errorf("unable to read tableACL config file: %v", err)
|
||||
|
@ -83,6 +86,8 @@ func Init(configFile string) {
|
|||
log.Errorf("tableACL initialization error: %v", err)
|
||||
panic(fmt.Errorf("tableACL initialization error: %v", err))
|
||||
}
|
||||
aclCallback = aclCB
|
||||
aclCallback()
|
||||
}
|
||||
|
||||
// InitFromProto inits table ACLs from a proto.
|
||||
|
@ -129,9 +134,13 @@ func load(config *pb.Config) error {
|
|||
return err
|
||||
}
|
||||
currentACL.Lock()
|
||||
defer currentACL.Unlock()
|
||||
currentACL.entries = entries
|
||||
currentACL.config = *config
|
||||
defer func() {
|
||||
currentACL.Unlock()
|
||||
aclCallback()
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -209,6 +209,9 @@ type Controller interface {
|
|||
// IsHealthy returns the health status of the QueryService
|
||||
IsHealthy() error
|
||||
|
||||
// ClearQueryPlanCache clears internal query plan cache
|
||||
ClearQueryPlanCache()
|
||||
|
||||
// ReloadSchema makes the quey service reload its schema cache
|
||||
ReloadSchema()
|
||||
|
||||
|
|
|
@ -493,6 +493,11 @@ func (tsv *TabletServer) ReloadSchema() {
|
|||
tsv.qe.schemaInfo.triggerReload()
|
||||
}
|
||||
|
||||
// ClearQueryPlanCache clears internal query plan cache
|
||||
func (tsv *TabletServer) ClearQueryPlanCache() {
|
||||
tsv.qe.schemaInfo.ClearQueryPlanCache()
|
||||
}
|
||||
|
||||
// QueryService returns the QueryService part of TabletServer.
|
||||
func (tsv *TabletServer) QueryService() queryservice.QueryService {
|
||||
return tsv
|
||||
|
|
|
@ -92,6 +92,10 @@ func (tqsc *Controller) ReloadSchema() {
|
|||
tqsc.ReloadSchemaCount++
|
||||
}
|
||||
|
||||
//ClearQueryPlanCache is part of the tabletserver.Controller interface
|
||||
func (tqsc *Controller) ClearQueryPlanCache() {
|
||||
}
|
||||
|
||||
// RegisterQueryRuleSource is part of the tabletserver.Controller interface
|
||||
func (tqsc *Controller) RegisterQueryRuleSource(ruleSource string) {
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче