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

scheduler: there is error not handled in evict-leader-scheduler #8619

Closed
lhy1024 opened this issue Sep 12, 2024 · 2 comments · Fixed by #8632
Closed

scheduler: there is error not handled in evict-leader-scheduler #8619

lhy1024 opened this issue Sep 12, 2024 · 2 comments · Fixed by #8632
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. report/customer Customers have encountered this bug. severity/major type/bug The issue is confirmed as a bug.

Comments

@lhy1024
Copy link
Contributor

lhy1024 commented Sep 12, 2024

Bug Report

What did you do?

add an evict-leader-scheduler with error params

What did you expect to see?

report an error and it should be successful next time when I use the correct params

What did you see instead?

it failed again when I used correct params

it shows Failed! [500] "[PD:core:ErrPauseLeaderTransfer]store 75 is paused for leader transfer"

What version of PD are you using (pd-server -V)?

v6.5.10

@lhy1024 lhy1024 added the type/bug The issue is confirmed as a bug. label Sep 12, 2024
@lhy1024
Copy link
Contributor Author

lhy1024 commented Sep 12, 2024

Because the code doesn't handle the errors returned by BuildWithArgs.

handler.config.BuildWithArgs(args)

Suppose the parameters used to create the evict-leader-scheduler are incorrect or not parsed. In that case, there may be an inconsistency between the in-memory state and the persistence state, resulting in pd not being able to add the evict-leader-scheduler correctly.

It can be reproduced by unit test v6.5.10...rleungx:evict-leader

func TestEvictLeaderScheduler(t *testing.T) {
	re := require.New(t)
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
	cluster, err := tests.NewTestCluster(ctx, 1)
	re.NoError(err)
	defer cluster.Destroy()
	err = cluster.RunInitialServers()
	re.NoError(err)
	cluster.WaitLeader()
	pdAddr := cluster.GetConfig().GetClientURL()
	cmd := pdctlCmd.GetRootCmd()

	stores := []*metapb.Store{
		{
			Id:            1,
			State:         metapb.StoreState_Up,
			LastHeartbeat: time.Now().UnixNano(),
		},
		{
			Id:            2,
			State:         metapb.StoreState_Up,
			LastHeartbeat: time.Now().UnixNano(),
		},
		{
			Id:            3,
			State:         metapb.StoreState_Up,
			LastHeartbeat: time.Now().UnixNano(),
		},
		{
			Id:            4,
			State:         metapb.StoreState_Up,
			LastHeartbeat: time.Now().UnixNano(),
		},
	}
	leaderServer := cluster.GetServer(cluster.GetLeader())
	re.NoError(leaderServer.BootstrapCluster())
	for _, store := range stores {
		pdctl.MustPutStore(re, leaderServer.GetServer(), store)
	}

	pdctl.MustPutRegion(re, cluster, 1, 1, []byte("a"), []byte("b"))
	output, err := pdctl.ExecuteCommand(cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-leader-scheduler", "2"}...)
	re.NoError(err)
	re.Contains(string(output), "Success!")
	failpoint.Enable("github.com/tikv/pd/server/schedulers/buildWithArgsErr", "return(true)")
	output, err = pdctl.ExecuteCommand(cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-leader-scheduler", "1"}...)
	re.NoError(err)
	re.Contains(string(output), "Success!")
	failpoint.Disable("github.com/tikv/pd/server/schedulers/buildWithArgsErr")
	output, err = pdctl.ExecuteCommand(cmd, []string{"-u", pdAddr, "scheduler", "remove", "evict-leader-scheduler"}...)
	re.NoError(err)
	re.Contains(string(output), "Success!")
	output, err = pdctl.ExecuteCommand(cmd, []string{"-u", pdAddr, "scheduler", "add", "evict-leader-scheduler", "1"}...)
	re.NoError(err)
	re.Contains(string(output), "store 1 is paused for leader transfer")
}

@lhy1024 lhy1024 added affects-4.0 affects-5.3 affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. labels Sep 13, 2024
@seiya-annie
Copy link

/report customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Sep 20, 2024
@ti-chi-bot ti-chi-bot bot closed this as completed in 6b927e1 Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot bot added a commit that referenced this issue Sep 24, 2024
ref #8619

Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Sep 24, 2024
ti-chi-bot bot pushed a commit that referenced this issue Sep 24, 2024
close #8619

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: Ryan Leung <[email protected]>
ti-chi-bot bot pushed a commit that referenced this issue Oct 25, 2024
close #8619

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: Ryan Leung <[email protected]>
ti-chi-bot bot added a commit that referenced this issue Oct 29, 2024
close #8619

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: Ryan Leung <[email protected]>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
rleungx added a commit to ti-chi-bot/pd that referenced this issue Nov 7, 2024
ti-chi-bot bot pushed a commit that referenced this issue Nov 7, 2024
close #8619

Signed-off-by: ti-chi-bot <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>

Co-authored-by: Ryan Leung <[email protected]>
rleungx added a commit to ti-chi-bot/pd that referenced this issue Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.5 This bug affects the 7.5.x(LTS) versions. affects-8.1 This bug affects the 8.1.x(LTS) versions. report/customer Customers have encountered this bug. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants