Skip to content

Size configuration on the TIKV side may cause PD panic #8323

Closed
@JmPotato

Description

Bug Report

If set coprocessor.region-split-size to a value that is less than 1 MiB, it will cause PD panic due to the following code:

if smallSize := size % c.GetRegionSplitSize(); smallSize <= mergeSize && smallSize != 0 {

GetRegionSplitSize() will return a zero value parsed by ParseMBFromText(), which will return 0 if the given size is less than 1 MiB.

// ParseMBFromText parses MB from text.
func ParseMBFromText(text string, value uint64) uint64 {
b := ByteSize(0)
err := b.UnmarshalText([]byte(text))
if err != nil {
return value
}
return uint64(b / units.MiB)
}

[2024/06/25 14:30:37.095 +08:00] [FATAL] [log.go:72] [panic] [recover="\"integer divide by zero\""] [stack="[github.com/tikv/pd/pkg/logutil.LogPanic\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/pkg/logutil/log.go:72\nruntime.gopanic\n\t/usr/local/go/src/runtime/panic.go:884\nruntime.panicdivide\n\t/usr/local/go/src/runtime/panic.go:239\ngithub.com/tikv/pd/server/config.(*StoreConfig).CheckRegionSize\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/config/store_config.go:143\ngithub.com/tikv/pd/server/schedule/checker.(*MergeChecker).Check\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/schedule/checker/merge_checker.go:158\ngithub.com/tikv/pd/server/schedule/checker.(*Controller).CheckRegion\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/schedule/checker/checker_controller.go:124\ngithub.com/tikv/pd/server/cluster.(*coordinator).tryAddOperators\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/cluster/coordinator.go:265\ngithub.com/tikv/pd/server/cluster.(*coordinator).checkRegions\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/cluster/coordinator.go:168\ngithub.com/tikv/pd/server/cluster.(*coordinator).patrolRegions\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/cluster/coordinator.go:143](http://github.com/tikv/pd/pkg/logutil.LogPanic/n/t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/pkg/logutil/log.go:72/nruntime.gopanic/n/t/usr/local/go/src/runtime/panic.go:884/nruntime.panicdivide/n/t/usr/local/go/src/runtime/panic.go:239/ngithub.com/tikv/pd/server/config.(*StoreConfig).CheckRegionSize/n/t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/config/store_config.go:143/ngithub.com/tikv/pd/server/schedule/checker.(*MergeChecker).Check/n/t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/schedule/checker/merge_checker.go:158/ngithub.com/tikv/pd/server/schedule/checker.(*Controller).CheckRegion/n/t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/schedule/checker/checker_controller.go:124/ngithub.com/tikv/pd/server/cluster.(*coordinator).tryAddOperators/n/t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/cluster/coordinator.go:265/ngithub.com/tikv/pd/server/cluster.(*coordinator).checkRegions/n/t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/cluster/coordinator.go:168/ngithub.com/tikv/pd/server/cluster.(*coordinator).patrolRegions/n/t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/pd/server/cluster/coordinator.go:143)"]

Metadata

Assignees

No one assigned

    Labels

    affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.impact/panicseverity/majortype/bugThe issue is confirmed as a bug.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions