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

FLASH-674: check region version in executeTS #322

Merged
merged 13 commits into from
Nov 18, 2019
5 changes: 3 additions & 2 deletions dbms/src/Flash/Coprocessor/InterpreterDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,12 @@ void InterpreterDAG::executeTS(const tipb::TableScan & ts, Pipeline & pipeline)
info.version = dag.getRegionVersion();
info.conf_version = dag.getRegionConfVersion();
auto current_region = context.getTMTContext().getKVStore()->getRegion(info.region_id);
if (!current_region)
if (!current_region || current_region->version() != dag.getRegionVersion() || current_region->confVer() != dag.getRegionConfVersion())
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should add one more check:

if (current_region->isPendingRemove())
     // throw RegionException(..., RegionException::RegionReadStatus::PENDING_REMOVE);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, region status should also be checked here

{
std::vector<RegionID> region_ids;
region_ids.push_back(info.region_id);
throw RegionException(std::move(region_ids), RegionException::RegionReadStatus::NOT_FOUND);
throw RegionException(std::move(region_ids),
current_region ? RegionException::RegionReadStatus::NOT_FOUND : RegionException::RegionReadStatus::VERSION_ERROR);
}
if (!checkKeyRanges(dag.getKeyRanges(), table_id, storage->pkIsUInt64(), current_region->getRange()))
throw Exception("Cop request only support full range scan for given region", ErrorCodes::COP_BAD_DAG_REQUEST);
Expand Down