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

*: fix TestConcurrentlyReset #6318

Merged
merged 3 commits into from
Apr 13, 2023
Merged
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
5 changes: 5 additions & 0 deletions pkg/tso/global_allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,11 @@ func (gta *GlobalTSOAllocator) campaignLeader() {
}()

gta.member.EnableLeader()
defer resetLeaderOnce.Do(func() {
Copy link
Contributor

@binshi-bing binshi-bing Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to bring no difference.

You added defer resetLeaderOnce.Do(... at the bottom of the code shown below, but it's already invoked at the beginning. If my understanding is correct, what you added is duplicated.

This piece of code refers to pd server.campaignLeader() in which "defer resetLeaderOnce.Do(..." is invoked twice, and I thought the second one is duplicate so I intentionally didn't invoke it after line 545 gta.member.EnableLeader().

Did I miss anything?

	ctx, cancel := context.WithCancel(gta.ctx)
	var resetLeaderOnce sync.Once
	defer resetLeaderOnce.Do(func() {
		cancel()
		gta.member.ResetLeader()
	})

	// maintain the the leadership, after this, TSO can be service.
	gta.member.KeepLeader(ctx)
        ...

	gta.member.EnableLeader()
	defer resetLeaderOnce.Do(func() {
		cancel()
		gta.member.ResetLeader()
	})

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the PR description, we need to make sure that ResetLeader happens before ResetAllocatorGroup.

cancel()
gta.member.ResetLeader()
})

// TODO: if enable-local-tso is true, check the cluster dc-location after the primary is elected
// go gta.tsoAllocatorManager.ClusterDCLocationChecker()
log.Info("tso primary is ready to serve", zap.String("tso-primary-name", gta.member.Name()))
Expand Down