Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: Refactor runaway related code #55202

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/ddl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ go_library(
"//pkg/disttask/framework/taskexecutor/execute",
"//pkg/disttask/operator",
"//pkg/domain/infosync",
"//pkg/domain/resourcegroup",
"//pkg/errctx",
"//pkg/expression",
"//pkg/expression/context",
Expand All @@ -119,6 +118,7 @@ go_library(
"//pkg/parser/terror",
"//pkg/parser/types",
"//pkg/privilege",
"//pkg/resourcegroup",
"//pkg/resourcemanager/pool/workerpool",
"//pkg/resourcemanager/util",
"//pkg/sessionctx",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/pingcap/tidb/pkg/ddl/resourcegroup"
sess "github.com/pingcap/tidb/pkg/ddl/session"
ddlutil "github.com/pingcap/tidb/pkg/ddl/util"
rg "github.com/pingcap/tidb/pkg/domain/resourcegroup"
"github.com/pingcap/tidb/pkg/errctx"
"github.com/pingcap/tidb/pkg/expression"
"github.com/pingcap/tidb/pkg/infoschema"
Expand All @@ -52,6 +51,7 @@ import (
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/parser/terror"
"github.com/pingcap/tidb/pkg/privilege"
rg "github.com/pingcap/tidb/pkg/resourcegroup"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/sessiontxn"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddl/resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"github.com/pingcap/tidb/pkg/ddl/logutil"
"github.com/pingcap/tidb/pkg/ddl/resourcegroup"
"github.com/pingcap/tidb/pkg/domain/infosync"
rg "github.com/pingcap/tidb/pkg/domain/resourcegroup"
"github.com/pingcap/tidb/pkg/infoschema"
"github.com/pingcap/tidb/pkg/meta"
"github.com/pingcap/tidb/pkg/parser/ast"
"github.com/pingcap/tidb/pkg/parser/model"
rg "github.com/pingcap/tidb/pkg/resourcegroup"
"github.com/pingcap/tidb/pkg/util/dbterror"
kvutil "github.com/tikv/client-go/v2/util"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion pkg/distsql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ go_test(
shard_count = 27,
deps = [
"//pkg/distsql/context",
"//pkg/domain/resourcegroup",
"//pkg/errctx",
"//pkg/kv",
"//pkg/parser/charset",
"//pkg/parser/model",
"//pkg/parser/mysql",
"//pkg/resourcegroup",
"//pkg/sessionctx",
"//pkg/sessionctx/stmtctx",
"//pkg/sessionctx/variable",
Expand Down
2 changes: 1 addition & 1 deletion pkg/distsql/context/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ go_library(
importpath = "github.com/pingcap/tidb/pkg/distsql/context",
visibility = ["//visibility:public"],
deps = [
"//pkg/domain/resourcegroup",
"//pkg/errctx",
"//pkg/kv",
"//pkg/parser/mysql",
"//pkg/resourcegroup",
"//pkg/util/context",
"//pkg/util/execdetails",
"//pkg/util/memory",
Expand Down
4 changes: 2 additions & 2 deletions pkg/distsql/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ package context
import (
"time"

"github.com/pingcap/tidb/pkg/domain/resourcegroup"
"github.com/pingcap/tidb/pkg/errctx"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/resourcegroup"
contextutil "github.com/pingcap/tidb/pkg/util/context"
"github.com/pingcap/tidb/pkg/util/execdetails"
"github.com/pingcap/tidb/pkg/util/memory"
Expand Down Expand Up @@ -75,7 +75,7 @@ type DistSQLContext struct {
StoreBatchSize int
ResourceGroupName string
LoadBasedReplicaReadThreshold time.Duration
RunawayChecker *resourcegroup.RunawayChecker
RunawayChecker resourcegroup.RunawayChecker
TiKVClientReadTimeout uint64

ReplicaClosestReadThreshold int64
Expand Down
2 changes: 1 addition & 1 deletion pkg/distsql/request_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"testing"
"time"

"github.com/pingcap/tidb/pkg/domain/resourcegroup"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/resourcegroup"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
"github.com/pingcap/tidb/pkg/tablecodec"
"github.com/pingcap/tidb/pkg/types"
Expand Down
5 changes: 1 addition & 4 deletions pkg/domain/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ go_library(
"//pkg/domain/globalconfigsync",
"//pkg/domain/infosync",
"//pkg/domain/metrics",
"//pkg/domain/resourcegroup",
"//pkg/errno",
"//pkg/infoschema",
"//pkg/infoschema/metrics",
Expand All @@ -55,6 +54,7 @@ go_library(
"//pkg/parser/terror",
"//pkg/planner/core/metrics",
"//pkg/privilege/privileges",
"//pkg/resourcegroup/runaway",
"//pkg/sessionctx",
"//pkg/sessionctx/sessionstates",
"//pkg/sessionctx/sysproctrack",
Expand All @@ -66,8 +66,6 @@ go_library(
"//pkg/statistics/handle/logutil",
"//pkg/statistics/handle/util",
"//pkg/store/helper",
"//pkg/ttl/cache",
"//pkg/ttl/sqlbuilder",
"//pkg/ttl/ttlworker",
"//pkg/types",
"//pkg/util",
Expand Down Expand Up @@ -98,7 +96,6 @@ go_library(
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_pingcap_kvproto//pkg/metapb",
"@com_github_pingcap_kvproto//pkg/pdpb",
"@com_github_pingcap_kvproto//pkg/resource_manager",
"@com_github_pingcap_log//:log",
"@com_github_stretchr_testify//require",
"@com_github_tikv_client_go_v2//oracle",
Expand Down
7 changes: 3 additions & 4 deletions pkg/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
"github.com/pingcap/tidb/pkg/disttask/framework/taskexecutor"
"github.com/pingcap/tidb/pkg/domain/globalconfigsync"
"github.com/pingcap/tidb/pkg/domain/infosync"
"github.com/pingcap/tidb/pkg/domain/resourcegroup"
"github.com/pingcap/tidb/pkg/errno"
"github.com/pingcap/tidb/pkg/infoschema"
infoschema_metrics "github.com/pingcap/tidb/pkg/infoschema/metrics"
Expand All @@ -64,6 +63,7 @@ import (
"github.com/pingcap/tidb/pkg/parser/terror"
metrics2 "github.com/pingcap/tidb/pkg/planner/core/metrics"
"github.com/pingcap/tidb/pkg/privilege/privileges"
"github.com/pingcap/tidb/pkg/resourcegroup/runaway"
"github.com/pingcap/tidb/pkg/sessionctx"
"github.com/pingcap/tidb/pkg/sessionctx/sessionstates"
"github.com/pingcap/tidb/pkg/sessionctx/sysproctrack"
Expand Down Expand Up @@ -193,8 +193,7 @@ type Domain struct {
logBackupAdvancer *daemon.OwnerDaemon
historicalStatsWorker *HistoricalStatsWorker
ttlJobManager atomic.Pointer[ttlworker.JobManager]
runawayManager *resourcegroup.RunawayManager
runawaySyncer *runawaySyncer
runawayManager *runaway.Manager
resourceGroupsController *rmclient.ResourceGroupsController

serverID uint64
Expand Down Expand Up @@ -2075,7 +2074,7 @@ func (do *Domain) SetupPlanReplayerHandle(collectorSctx sessionctx.Context, work
}

// RunawayManager returns the runaway manager.
func (do *Domain) RunawayManager() *resourcegroup.RunawayManager {
func (do *Domain) RunawayManager() *runaway.Manager {
return do.runawayManager
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/infosync/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ go_library(
"//pkg/ddl/label",
"//pkg/ddl/placement",
"//pkg/ddl/util",
"//pkg/domain/resourcegroup",
"//pkg/errno",
"//pkg/kv",
"//pkg/metrics",
"//pkg/parser/model",
"//pkg/parser/mysql",
"//pkg/parser/terror",
"//pkg/resourcegroup",
"//pkg/session/cursor",
"//pkg/sessionctx/binloginfo",
"//pkg/sessionctx/variable",
Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/infosync/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ import (
"github.com/pingcap/tidb/pkg/ddl/label"
"github.com/pingcap/tidb/pkg/ddl/placement"
"github.com/pingcap/tidb/pkg/ddl/util"
"github.com/pingcap/tidb/pkg/domain/resourcegroup"
"github.com/pingcap/tidb/pkg/errno"
"github.com/pingcap/tidb/pkg/kv"
"github.com/pingcap/tidb/pkg/metrics"
"github.com/pingcap/tidb/pkg/parser/model"
"github.com/pingcap/tidb/pkg/parser/mysql"
"github.com/pingcap/tidb/pkg/parser/terror"
"github.com/pingcap/tidb/pkg/resourcegroup"
"github.com/pingcap/tidb/pkg/session/cursor"
"github.com/pingcap/tidb/pkg/sessionctx/binloginfo"
"github.com/pingcap/tidb/pkg/sessionctx/variable"
Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/infosync/resource_manager_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/golang/protobuf/proto"
"github.com/pingcap/kvproto/pkg/meta_storagepb"
rmpb "github.com/pingcap/kvproto/pkg/resource_manager"
"github.com/pingcap/tidb/pkg/domain/resourcegroup"
"github.com/pingcap/tidb/pkg/resourcegroup"
pd "github.com/tikv/pd/client"
)

Expand Down
Loading