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
Merged

Conversation

bradyjoestar
Copy link
Contributor

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

@sre-bot
Copy link
Contributor

sre-bot 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
Copy link
Contributor

sre-bot 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.

@nolouch
Copy link
Contributor

nolouch 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
Copy link
Contributor Author

@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.
Copy link
Member

Choose a reason for hiding this comment

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

It seems this comment is not for this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, 😁

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

// RemoveTombStoneStores remove all the record of tombstone Store.
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!Thanks.

@codecov-io
Copy link

codecov-io 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.

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

@nolouch nolouch Mar 22, 2019

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed , Thanks !

return
}

cluster.RemoveTombStoneRecords()
Copy link
Contributor

Choose a reason for hiding this comment

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

should handle the error.

if err != nil {
return err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Better to add a log if delete successfully.

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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")
Copy link
Member

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

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

// NewRemoveTombStoneCommandFunc returns a weight subcommand of storeCmd.
Copy link
Member

Choose a reason for hiding this comment

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

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.
Copy link
Member

Choose a reason for hiding this comment

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

s/delete/deletes/g

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Next time I will pay attention to it. 😁

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

Cool!

if err != nil {
return err
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

LGTM

@nolouch
Copy link
Contributor

nolouch commented Mar 25, 2019

/rebuild

@zhouqiang-cl
Copy link
Contributor

/rebuild

@disksing disksing merged commit 09aa89e into tikv:master Mar 25, 2019
@bradyjoestar bradyjoestar deleted the issue-1468 branch March 25, 2019 09:51
rleungx pushed a commit to rleungx/pd that referenced this pull request Aug 26, 2019
sre-bot pushed a commit that referenced this pull request Aug 29, 2019
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants