Skip to content

Commit

Permalink
util/timeutil: fix data race caused by forgetting set stats lease to 0 (
Browse files Browse the repository at this point in the history
  • Loading branch information
tiancaiamao authored and ngaut committed Nov 28, 2018
1 parent c14fceb commit 05bd727
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions util/kvencoder/kv_encoder_test.go
Expand Up @@ -49,6 +49,7 @@ func newStoreWithBootstrap() (kv.Storage, *domain.Domain, error) {
return nil, nil, errors.Trace(err)
}
session.SetSchemaLease(0)
session.SetStatsLease(0)
dom, err := session.BootstrapSession(store)
return store, dom, errors.Trace(err)
}
Expand Down
6 changes: 5 additions & 1 deletion util/timeutil/time.go
Expand Up @@ -117,9 +117,13 @@ func SystemLocation() *time.Location {
return loc
}

var setSysTZOnce sync.Once

// SetSystemTZ sets systemTZ by the value loaded from mysql.tidb.
func SetSystemTZ(name string) {
systemTZ = name
setSysTZOnce.Do(func() {
systemTZ = name
})
}

// getLoc first trying to load location from a cache map. If nothing found in such map, then call
Expand Down

0 comments on commit 05bd727

Please sign in to comment.