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

*: add a API to clear tombstone store #1472

Merged
merged 17 commits into from Mar 25, 2019

Conversation

Projects
None yet
8 participants
@bradyjoestar
Copy link
Contributor

commented Mar 20, 2019

What problem does this PR solve?

#1468

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

  • Has configuration change
  • Has HTTP API interfaces change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation
  • Need to update the tidb-ansible repository
  • Need to be included in the release notes

bradyjoestar and others added some commits Mar 20, 2019

@sre-bot

This comment has been minimized.

Copy link

commented Mar 20, 2019

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

1 similar comment
@sre-bot

This comment has been minimized.

Copy link

commented Mar 20, 2019

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@rleungx rleungx added the contributor label Mar 21, 2019

@nolouch

This comment has been minimized.

Copy link
Member

commented Mar 21, 2019

Thanks! @bradyjoestar Can you add a command like

store clear [id]

in tools/pd-ctl.
and add some test in tests/cmd/pdctl_test.go

@bradyjoestar

This comment has been minimized.

Copy link
Contributor Author

commented Mar 21, 2019

@nolunch sure.
I am a newbie so it may takes some time to read the testcode.

@@ -557,6 +557,13 @@ func (c *RaftCluster) checkStores() {
}
}

// GetStores gets stores from cluster.

This comment has been minimized.

Copy link
@rleungx

rleungx Mar 21, 2019

Member

It seems this comment is not for this function?

This comment has been minimized.

Copy link
@bradyjoestar

bradyjoestar Mar 21, 2019

Author Contributor

Yeah, 😁

@@ -554,6 +554,15 @@ func (s *StoresInfo) GetMetaStores() []*metapb.Store {
return stores
}

// RemoveTombStoneStores remove all the record of tombstone Store.

This comment has been minimized.

Copy link
@rleungx

rleungx Mar 21, 2019

Member

ditto

This comment has been minimized.

Copy link
@bradyjoestar

bradyjoestar Mar 21, 2019

Author Contributor

Fixed!Thanks.

@codecov-io

This comment has been minimized.

Copy link

commented Mar 21, 2019

Codecov Report

❗️ No coverage uploaded for pull request base (master@f72cc23). Click here to learn what that means.
The diff coverage is 29.5%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1472   +/-   ##
=========================================
  Coverage          ?   67.13%           
=========================================
  Files             ?      158           
  Lines             ?    15383           
  Branches          ?        0           
=========================================
  Hits              ?    10328           
  Misses            ?     4112           
  Partials          ?      943
Impacted Files Coverage Δ
server/core/store.go 77.81% <0%> (ø)
server/cluster.go 75.06% <0%> (ø)
server/cluster_info.go 85.2% <0%> (ø)
server/core/kv.go 75.36% <0%> (ø)
tools/pd-ctl/pdctl/ctl.go 5% <0%> (ø)
server/api/store.go 63.3% <0%> (ø)
server/schedule/basic_cluster.go 88.67% <0%> (ø)
server/api/router.go 100% <100%> (ø)
tools/pd-ctl/pdctl/command/store_command.go 65.65% <94.44%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f72cc23...6816664. Read the comment docs.

swbsin added some commits Mar 21, 2019

func (s *StoresInfo) RemoveTombStoneRecords() {
for storeID, store := range s.stores {
if store.IsTombstone() {
delete(s.stores, storeID)

This comment has been minimized.

Copy link
@nolouch

nolouch Mar 22, 2019

Member

Only removed in the memory, restarting PD will appear again.

This comment has been minimized.

Copy link
@bradyjoestar

bradyjoestar Mar 22, 2019

Author Contributor

Fixed , Thanks !

swbsin added some commits Mar 22, 2019

return
}

cluster.RemoveTombStoneRecords()

This comment has been minimized.

Copy link
@nolouch

nolouch Mar 22, 2019

Member

should handle the error.

if err != nil {
return err
}
}

This comment has been minimized.

Copy link
@nolouch

nolouch Mar 22, 2019

Member

Better to add a log if delete successfully.

This comment has been minimized.

Copy link
@nolouch

nolouch Mar 24, 2019

Member

We want to know the deleted store through the log, so we also need to print the log if it is successfully deleted.

This comment has been minimized.

Copy link
@bradyjoestar

bradyjoestar Mar 24, 2019

Author Contributor

Got it. 👌

@@ -64,6 +64,7 @@ func createRouter(prefix string, svr *server.Server) *mux.Router {
storeHandler := newStoreHandler(svr, rd)
router.HandleFunc("/api/v1/store/{id}", storeHandler.Get).Methods("GET")
router.HandleFunc("/api/v1/store/{id}", storeHandler.Delete).Methods("DELETE")
router.HandleFunc("/api/v1/store/remove-tombstone", storeHandler.RemoveTombStone).Methods("DELETE")

This comment has been minimized.

Copy link
@rleungx

rleungx Mar 22, 2019

Member

I think it's better to put it into stores instead of store?

This comment has been minimized.

Copy link
@bradyjoestar

bradyjoestar Mar 22, 2019

Author Contributor

Fine, I'll move it to storesHandler tonight. 👌

Show resolved Hide resolved server/cluster.go Outdated
@@ -70,6 +70,15 @@ func NewSetStoreWeightCommand() *cobra.Command {
}
}

// NewRemoveTombStoneCommandFunc returns a weight subcommand of storeCmd.

This comment has been minimized.

Copy link
@rleungx

rleungx Mar 22, 2019

Member

weight?

@@ -114,6 +114,11 @@ func (kv *KV) SaveStore(store *metapb.Store) error {
return saveProto(kv.KVBase, kv.storePath(store.GetId()), store)
}

// DeleteStore delete one store from KV.

This comment has been minimized.

Copy link
@rleungx

rleungx Mar 22, 2019

Member

s/delete/deletes/g

This comment has been minimized.

Copy link
@bradyjoestar

bradyjoestar Mar 22, 2019

Author Contributor

Next time I will pay attention to it. 😁

rleungx and others added some commits Mar 22, 2019

Update server/cluster.go
Co-Authored-By: bradyjoestar <bradyjoestar@gmail.com>
@nolouch
Copy link
Member

left a comment

Cool!

if err != nil {
return err
}
}

This comment has been minimized.

Copy link
@nolouch

nolouch Mar 24, 2019

Member

We want to know the deleted store through the log, so we also need to print the log if it is successfully deleted.

swbsin added some commits Mar 24, 2019

@nolouch
Copy link
Member

left a comment

LGTM

@nolouch

This comment has been minimized.

Copy link
Member

commented Mar 25, 2019

/rebuild

@zhouqiang-cl

This comment has been minimized.

Copy link
Member

commented Mar 25, 2019

/rebuild

@disksing disksing merged commit 09aa89e into pingcap:master Mar 25, 2019

6 checks passed

ci/circleci Your tests passed on CircleCI!
Details
codecov/patch No report found to compare against
Details
codecov/project No report found to compare against
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
idc-jenkins-ci/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@bradyjoestar bradyjoestar deleted the bradyjoestar:issue-1468 branch Mar 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.