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

pump client: support change select pump's strategy #221

Merged
merged 4 commits into from
Mar 21, 2019

Conversation

WangXiangUSTC
Copy link
Contributor

What problem does this PR solve?

support change select pump's strategy
proposal: pingcap/tidb#9201

What is changed and how it works?

create a new selector when change strategy

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

@@ -241,14 +242,19 @@ func (c *PumpsClient) getPumpStatus(pctx context.Context) (revision int64, err e

// WriteBinlog writes binlog to a situable pump. Tips: will never return error for commit/rollback binlog.
func (c *PumpsClient) WriteBinlog(binlog *pb.Binlog) error {
c.RLock()
pumpNum := len(c.Pumps.AvaliablePumps)
selector := c.Selector
Copy link
Collaborator

@IANTHEREAL IANTHEREAL Mar 20, 2019

Choose a reason for hiding this comment

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

why putting it into a lock scope?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok,I think you can put lock in selector, and provide an update function. it's better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when change strategy will create a new selector. And selector is a member of pump client. so I think lock pump client seems better

@IANTHEREAL
Copy link
Collaborator

Rest LGTM

@IANTHEREAL
Copy link
Collaborator

@july2993 Please take a careful look

Copy link
Contributor

@july2993 july2993 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

  • you should try avoid global var tsMap, selectorLock which is shard by multi client.
  • currently support range and hash, but i think no different for usage, maybe just confuse people, test more about hash if expose this to user.

@WangXiangUSTC
Copy link
Contributor Author

  1. if not use a global tsMap, need set tsMap to new selector from old selector, seems it is a little tedious.
  2. when user change the strategy, and at the moment also have write binlog request, will have two selector, and the tsMap should use same one.
  3. one tidb instance should only have one pump client, so it dosen't matter

@july2993
Copy link
Contributor

july2993 commented Mar 20, 2019

i know it it doesn't matter now, you should encapsulate such thinks in your PumpsClient, but i am ok with this currently.

Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

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

LGTM

@IANTHEREAL
Copy link
Collaborator

In addition to the poor packaging, LGTM

@WangXiangUSTC
Copy link
Contributor Author

OK, I will refactor these code later. @GregoryIan

@WangXiangUSTC WangXiangUSTC merged commit 1e8b48f into pingcap:master Mar 21, 2019
@WangXiangUSTC WangXiangUSTC deleted the xiang/strategy branch March 21, 2019 06:58
WangXiangUSTC added a commit to WangXiangUSTC/tidb-tools that referenced this pull request Mar 25, 2019
IANTHEREAL pushed a commit that referenced this pull request Mar 29, 2019
… strategy config (#223)

* pump client: compatible with kafka version tidb-binlog && add unit test (#139)

* pump client: write commit binlog will never return error (#148)

* pkg watcher: move watcher from tidb-enterprise-tools (#146)

* pump client: increase retry time, and refine some code (#158)

* pump client: add initial log function (#165)

* pump client: support change select pump's strategy (#221)
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