Skip to content

Commit

Permalink
planner: fix DATA RACE on global binding (#58618)
Browse files Browse the repository at this point in the history
close #58616
  • Loading branch information
qw4990 authored Dec 30, 2024
1 parent a6416b8 commit 4b097bd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ type Domain struct {
store kv.Storage
infoCache *infoschema.InfoCache
privHandle *privileges.Handle
bindHandle bindinfo.GlobalBindingHandle
bindHandle atomic.Value
statsHandle atomic.Pointer[handle.Handle]
statsLease time.Duration
ddl ddl.DDL
Expand Down Expand Up @@ -2080,13 +2080,17 @@ func (do *Domain) PrivilegeHandle() *privileges.Handle {

// BindHandle returns domain's bindHandle.
func (do *Domain) BindHandle() bindinfo.GlobalBindingHandle {
return do.bindHandle
v := do.bindHandle.Load()
if v == nil {
return nil
}
return v.(bindinfo.GlobalBindingHandle)
}

// InitBindingHandle create a goroutine loads BindInfo in a loop, it should
// be called only once in BootstrapSession.
func (do *Domain) InitBindingHandle() error {
do.bindHandle = bindinfo.NewGlobalBindingHandle(do.sysSessionPool)
do.bindHandle.Store(bindinfo.NewGlobalBindingHandle(do.sysSessionPool))
err := do.BindHandle().LoadFromStorageToCache(true)
if err != nil || bindinfo.Lease == 0 {
return err
Expand Down

0 comments on commit 4b097bd

Please sign in to comment.