-
Notifications
You must be signed in to change notification settings - Fork 188
Conversation
/run-all-tests |
/run-all-tests tidb=release-3.0 |
Codecov Report
@@ Coverage Diff @@
## master #363 +/- ##
===============================================
- Coverage 57.5617% 57.0677% -0.494%
===============================================
Files 163 164 +1
Lines 16471 16936 +465
===============================================
+ Hits 9481 9665 +184
- Misses 6065 6290 +225
- Partials 925 981 +56 |
/run-all-tests tidb=release-3.0 |
/run-all-tests tidb=release-3.0 |
|
||
defaultOperatePath = "/dm-operate" | ||
|
||
defaultEtcdTimeout = time.Duration(10 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also defined this in pkg/etcdutil/etcdutil.go. and and a CreateClient
in it in #367 . we can merge then later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, if your pr merged first I will use your function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WangXiangUSTC It's time to update this defaultEtcdTimeout
with the one in pkg/etcdutil/etcdutil.go now?
) | ||
|
||
func TestMaster(t *testing.T) { | ||
etcdMockCluster := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
/run-all-tests tidb=release-3.0 |
/run-all-tests tidb=release-3.0 |
/run-all-tests tidb=release-3.0 |
/run-all-tests tidb=release-3.0 |
/run-all-tests tidb=release-3.0 |
dm/ctl/master/show_leader.go
Outdated
"github.com/pingcap/dm/dm/pb" | ||
) | ||
|
||
// NewShowLeaderCmd creates a CheckTask command |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update the comment (not CheckTask
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
function show_master_leader_success() { | ||
run_dm_ctl $WORK_DIR "127.0.0.1:$MASTER_PORT" \ | ||
"show-master-leader" \ | ||
"\"result\": true" 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about checking any successful msg
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in 20524e7
dm/proto/dmmaster.proto
Outdated
message ShowMasterLeaderRequest { | ||
} | ||
|
||
// If have leader, result is true, and put leader information in msg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about defining the leader information as another message
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in 20524e7
dm/proto/operate.proto
Outdated
} | ||
|
||
enum OperateStage { | ||
UnknownStage = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need another stage like New
to differ with the default Unknown
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in 20524e7
server.etcdClient = etcdClient | ||
ctx, cancel := context.WithCancel(context.Background()) | ||
server.election = &election.Election{} | ||
server.election.SetIsLeader(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a comment to highlight the purpose here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated 0201e85
dm/master/server.go
Outdated
@@ -253,6 +267,21 @@ func errorCommonWorkerResponse(msg string, worker string) *pb.CommonWorkerRespon | |||
|
|||
// StartTask implements MasterServer.StartTask | |||
func (s *Server) StartTask(ctx context.Context, req *pb.StartTaskRequest) (*pb.StartTaskResponse, error) { | |||
log.L().Info("receive request and will save it to etcd", zap.Stringer("payload", req), zap.String("request", "StartTask")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove will save it to etcd
, because we must to save it into etcd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed f0931fb
dm/master/server.go
Outdated
}, nil | ||
} | ||
|
||
_, leaderID, err := s.election.LeaderInfo(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what‘s leaderID
in DM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it's better to add a function getDMLeaderMasterInfo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update in 20524e7
for { | ||
select { | ||
case <-ctx.Done(): | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some log to indicate that the goroutine exited, here or in defer function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add in b091a46
|
||
// only master leader need handle request | ||
if s.election.IsLeader() { | ||
go s.handleRequest(string(ev.Kv.Key), operate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we manage these goroutines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is unnecessary, just abandon these requests when leader is exit. dmctl will get error, and user can execute command again later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I care about is correctness. If the leader migrates and the transaction processing has not ended, will there be unexpected consequences?
/run-all-tests tidb=release-3.0 |
What problem does this PR solve?
use etcd as operate queue:
What is changed and how it works?
/dm-operate
. when getting events, will handle the request if the dm-master is leader.Check List
Tests
Side effects
Related changes