Skip to content

Commit

Permalink
config: move storage check after initializeTempDir (pingcap#16257)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yisaer authored and sre-bot committed Apr 16, 2020
1 parent a6ba42e commit 8c54d68
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import (
"github.com/pingcap/tidb/util/signal"
"github.com/pingcap/tidb/util/storeutil"
"github.com/pingcap/tidb/util/sys/linux"
storageSys "github.com/pingcap/tidb/util/sys/storage"
"github.com/pingcap/tidb/util/systimemon"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/push"
Expand Down Expand Up @@ -167,6 +168,7 @@ func main() {
if config.GetGlobalConfig().OOMUseTmpStorage {
config.GetGlobalConfig().UpdateTempStoragePath()
initializeTempDir()
checkTempStorageQuota()
}
setGlobalVars()
setCPUAffinity()
Expand Down Expand Up @@ -231,6 +233,21 @@ func initializeTempDir() {
}
}

func checkTempStorageQuota() {
// check capacity and the quota when OOMUseTmpStorage is enabled
c := config.GetGlobalConfig()
if c.TempStorageQuota < 0 {
// means unlimited, do nothing
} else {
capacityByte, err := storageSys.GetTargetDirectoryCapacity(c.TempStoragePath)
if err != nil {
log.Fatal(err.Error())
} else if capacityByte < uint64(c.TempStorageQuota) {
log.Fatal(fmt.Sprintf("value of [temp-storage-quota](%d byte) exceeds the capacity(%d byte) of the [%s] directory", c.TempStorageQuota, capacityByte, c.TempStoragePath))
}
}
}

func setCPUAffinity() {
if affinityCPU == nil || len(*affinityCPU) == 0 {
return
Expand Down

0 comments on commit 8c54d68

Please sign in to comment.