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

drainer: Refactor, eliminate duplicate code by introducing a taskGroup #572

Merged
merged 2 commits into from
May 1, 2019
Merged

drainer: Refactor, eliminate duplicate code by introducing a taskGroup #572

merged 2 commits into from
May 1, 2019

Conversation

suzaku
Copy link
Contributor

@suzaku suzaku commented Apr 29, 2019

What problem does this PR solve?

The code used by drainer.Server to start stuff like collector and syncer
are almost identical.

What is changed and how it works?

Create a wrapper of sync.WaitGroup that's similar to errgroup, but
provide a GoNoPanic method that automatically recover from goroutine panics
and log the error.

Check List

Tests

  • Unit test

Code changes

Side effects

Related changes

@suzaku
Copy link
Contributor Author

suzaku commented Apr 29, 2019

/run-all-tests

func (s *Server) heartbeat(ctx context.Context) <-chan error {
errc := make(chan error, 1)
err := s.updateStatus()
Copy link
Collaborator

Choose a reason for hiding this comment

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

the change is a little different. Before the change, calling heartbeat would must execute updateStatus, now it's not sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

heartbeat is only called in Start and Start calls updateStatus right before heartbeat, so even when the goroutine scheduler decides not to run another updateStatus immediately, it makes little difference.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok

@IANTHEREAL
Copy link
Collaborator

Rest LGTM. Good Job! keep to clear codes

@IANTHEREAL
Copy link
Collaborator

LGTM

@suzaku
Copy link
Contributor Author

suzaku commented Apr 30, 2019

/run-all-tests

Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

Rest LGTM.

drainer/util.go Outdated Show resolved Hide resolved
@suzaku suzaku merged commit 78f4d7f into pingcap:master May 1, 2019
@suzaku suzaku deleted the refactor-drainer-server branch May 1, 2019 00:40
IANTHEREAL pushed a commit that referenced this pull request May 7, 2019
* drainer/: Fix when pk is handle and value overflow int64 (#573)

* arbiter: Refactor and add more unit tests (#570)

* More tests for arbiter

* Log os.Hostname error

* drainer: Refactor, eliminate duplicate code by introducing a taskGroup (#572)

* Refactor, eliminate duplicate code by introducing a taskGroup

* Use zap.Stack directly

* binlogctl: refine log output when use help command (#580)

* Minor edits to README (#583)

* drainer: Refactor and add unit tests (#571)

* Add tests for drainer

* Use DeepEquals to simplify map testing

* Just import context

* Use Equals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants