Repository navigation
dxf: derive current keyspace when acquiring task runtime #69434
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,6 @@ package scheduler | |
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "sync/atomic" | ||
| "testing" | ||
| "time" | ||
|
|
@@ -25,6 +24,7 @@ import ( | |
| "github.com/pingcap/failpoint" | ||
| "github.com/pingcap/tidb/pkg/domain/sqlsvrapi" | ||
| sqlsvrapimock "github.com/pingcap/tidb/pkg/domain/sqlsvrapi/mock" | ||
| "github.com/pingcap/tidb/pkg/dxf/framework/dxfutil" | ||
| "github.com/pingcap/tidb/pkg/dxf/framework/mock" | ||
| "github.com/pingcap/tidb/pkg/dxf/framework/proto" | ||
| mockScheduler "github.com/pingcap/tidb/pkg/dxf/framework/scheduler/mock" | ||
|
|
@@ -72,8 +72,11 @@ func expectRuntimeFromNewSession(ctrl *gomock.Controller, taskMgr *mock.MockTask | |
| server := sqlsvrapimock.NewMockServer(ctrl) | ||
| server.EXPECT().GetRuntime().Return(runtime).AnyTimes() | ||
| taskMgr.EXPECT().WithNewSession(gomock.Any()).DoAndReturn(func(fn func(sessionctx.Context) error) error { | ||
| se := utilmock.NewContext() | ||
| // Match the mock session store to the runtime so AcquireTaskRuntime takes the local-runtime path. | ||
| se.Store = runtime.Store() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 [Nit] se.Store assignment in expectRuntimeFromNewSession lacks a comment explaining its role in keyspace routingThe added |
||
| return fn(&sessionWithSQLServer{ | ||
| Context: utilmock.NewContext(), | ||
| Context: se, | ||
| server: server, | ||
| }) | ||
| }).AnyTimes() | ||
|
|
@@ -265,7 +268,9 @@ func newCrossKeyspaceStartCase(t *testing.T, taskID int64, taskKey string) *cros | |
| server := sqlsvrapimock.NewMockServer(ctrl) | ||
| taskMgr.EXPECT().GetTaskByID(gomock.Any(), task.ID).Return(task, nil) | ||
| taskMgr.EXPECT().WithNewSession(gomock.Any()).DoAndReturn(func(fn func(sessionctx.Context) error) error { | ||
| return fn(&sessionWithSQLServer{Context: utilmock.NewContext(), server: server}) | ||
| se := utilmock.NewContext() | ||
| se.Store = manager.store | ||
| return fn(&sessionWithSQLServer{Context: se, server: server}) | ||
| }) | ||
|
|
||
| return &crossKeyspaceStartCase{ | ||
|
|
@@ -286,7 +291,7 @@ func (tc *crossKeyspaceStartCase) expectRuntimeAcquiredAndReleased() *sqlsvrapim | |
| } | ||
|
|
||
| func (tc *crossKeyspaceStartCase) holderID() string { | ||
| return fmt.Sprintf("DXF/scheduler/%d", tc.task.ID) | ||
| return dxfutil.GenHolderID("scheduler", tc.task.ID) | ||
| } | ||
|
|
||
| func TestStartSchedulerCrossKeyspaceRuntime(t *testing.T) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.