-
Notifications
You must be signed in to change notification settings - Fork 714
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
Conversation
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
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. |
Thanks! @bradyjoestar Can you add a command like
in |
@nolunch sure. |
server/cluster.go
Outdated
@@ -557,6 +557,13 @@ func (c *RaftCluster) checkStores() { | |||
} | |||
} | |||
|
|||
// GetStores gets stores from cluster. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, 😁
server/core/store.go
Outdated
@@ -554,6 +554,15 @@ func (s *StoresInfo) GetMetaStores() []*metapb.Store { | |||
return stores | |||
} | |||
|
|||
// RemoveTombStoneStores remove all the record of tombstone Store. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!Thanks.
Codecov Report
@@ Coverage Diff @@
## master #1472 +/- ##
=========================================
Coverage ? 67.13%
=========================================
Files ? 158
Lines ? 15383
Branches ? 0
=========================================
Hits ? 10328
Misses ? 4112
Partials ? 943
Continue to review full report at Codecov.
|
server/core/store.go
Outdated
func (s *StoresInfo) RemoveTombStoneRecords() { | ||
for storeID, store := range s.stores { | ||
if store.IsTombstone() { | ||
delete(s.stores, storeID) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed , Thanks !
server/api/store.go
Outdated
return | ||
} | ||
|
||
cluster.RemoveTombStoneRecords() |
There was a problem hiding this comment.
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 | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. 👌
server/api/router.go
Outdated
@@ -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") |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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. 👌
@@ -70,6 +70,15 @@ func NewSetStoreWeightCommand() *cobra.Command { | |||
} | |||
} | |||
|
|||
// NewRemoveTombStoneCommandFunc returns a weight subcommand of storeCmd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weight?
server/core/kv.go
Outdated
@@ -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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/delete/deletes/g
There was a problem hiding this comment.
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. 😁
Co-Authored-By: bradyjoestar <bradyjoestar@gmail.com>
There was a problem hiding this 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 | ||
} | ||
} |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/rebuild |
/rebuild |
What problem does this PR solve?
#1468
Tests
Code changes
Side effects
Related changes
tidb-ansible
repository