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

*: ignore tombstone stores #4223

Merged
merged 14 commits into from Feb 26, 2019
Merged

*: ignore tombstone stores #4223

merged 14 commits into from Feb 26, 2019

Conversation

overvenus
Copy link
Member

@overvenus overvenus commented Feb 15, 2019

What have you changed? (mandatory)

Ignore tombstone stores.

What are the type of the changes? (mandatory)

  • Bug fix (non-breaking change which fixes an issue)

How has this PR been tested? (mandatory)

Unit tests.

Does this PR affect documentation (docs) update? (mandatory)

No

Does this PR affect tidb-ansible update? (mandatory)

No.

Refer to a related PR or issue link (optional)

Fixes #4221
Cc pingcap/tidb#9269

Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus overvenus removed the S: WIP label Feb 15, 2019
if store.get_state() != metapb::StoreState::Tombstone {
Ok(store)
} else {
Err(Error::StoreTombstone(format!("{:?}", store)))
Copy link
Member

Choose a reason for hiding this comment

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

Why return error when the store is Tombstone?

Copy link
Member Author

Choose a reason for hiding this comment

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

Tombstone stores are no longer belongs to the cluster, other TiKVs should ignore such stores. See more pingcap/tidb#9269

Copy link
Contributor

Choose a reason for hiding this comment

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

seem we don't need to use a string for the StoreTombstone. maybe integer is enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

PD may return StoreTombston error too, but it does not contain a store id, so I choose string for simplicity.

let err = header.get_error();
match err.get_field_type() {
ErrorType::ALREADY_BOOTSTRAPPED => Err(Error::ClusterBootstrapped(header.get_cluster_id())),
ErrorType::NOT_BOOTSTRAPPED => Err(Error::ClusterNotBootstrapped(header.get_cluster_id())),
ErrorType::INCOMPATIBLE_VERSION => Err(Error::Incompatible),
_ => Err(box_err!(err.get_message())),
ErrorType::STORE_TOMBSTONE => Err(Error::StoreTombstone(err.get_message().to_owned())),
ErrorType::UNKNOWN => Err(box_err!(err.get_message())),
Copy link
Member

Choose a reason for hiding this comment

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

When the UNKNOWN error type will be returned?

Copy link
Member Author

Choose a reason for hiding this comment

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

It depends on PD.

@overvenus overvenus added the type/bugfix Type: PR - Fix a bug label Feb 15, 2019
src/pd/client.rs Outdated Show resolved Hide resolved
src/pd/client.rs Outdated Show resolved Hide resolved
@cwen0
Copy link
Member

cwen0 commented Feb 16, 2019

/test

src/pd/client.rs Outdated
}

fn get_all_stores(&self) -> Result<Vec<metapb::Store>> {
fn get_all_stores(&self, include_tombstone: bool) -> Result<Vec<metapb::Store>> {
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 PD support such API is more elegant. BTW, how lightning interact with this API?

Copy link
Contributor

Choose a reason for hiding this comment

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

Lightning doesn't interact with TiKV stores directly, Importer does (src/import/import.rs in this PR).

Importer uses this API to get all TiKV nodes to forward the "switch to import mode" or "compact cluster" command. It doesn't affect SST ingestion.

Copy link
Member

Choose a reason for hiding this comment

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

Got it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cc @nolouch What do you think? Is it ok to support this feature in PD side?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's ok to do that.

zhangjinpeng87
zhangjinpeng87 previously approved these changes Feb 18, 2019
Copy link
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

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

LGTM

src/import/client.rs Outdated Show resolved Hide resolved
@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

PTAL
/run-all-tests

zhangjinpeng87
zhangjinpeng87 previously approved these changes Feb 22, 2019
@overvenus
Copy link
Member Author

@huachaohuang PTAL, thanks!

@huachaohuang
Copy link
Contributor

When I first added this get_all_stores API, I didn't expect PD to return tombstone stores at all (yes, I implemented that API in PD too, sorry 😂). IMO, it's more elegant to fix this in PD, and we can add an option like include_tombstones in the request if we really need that in the future.

@overvenus
Copy link
Member Author

IMO, it's more elegant to fix this in PD, and we can add an option like include_tombstones in the request if we really need that in the future.

Yes, but it does not with to this PR, they all have the same API. Some users already met this bug, so I think we should merge this PR ASAP.

@huachaohuang
Copy link
Contributor

@overvenus how about just fixing this in PD?
tikv/pd#1440

@kennytm
Copy link
Contributor

kennytm commented Feb 22, 2019

Could we have a solution that can be easily cherry-picked to 2.1?

Signed-off-by: Neil Shen <overvenus@gmail.com>
@overvenus
Copy link
Member Author

PTAL, thanks!

Copy link
Member

@zhangjinpeng87 zhangjinpeng87 left a comment

Choose a reason for hiding this comment

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

LGTM

@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

/run-all-tests

@overvenus
Copy link
Member Author

/rebuild

@overvenus overvenus merged commit 9a66560 into tikv:master Feb 26, 2019
@overvenus overvenus deleted the ignore-tombstone branch February 26, 2019 15:50
overvenus added a commit to overvenus/tikv that referenced this pull request Feb 26, 2019
Signed-off-by: Neil Shen <overvenus@gmail.com>
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Signed-off-by: Neil Shen <overvenus@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bugfix Type: PR - Fix a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TiKV/Importer should ignore tombstoned stores
8 participants