Skip to content

Commit

Permalink
Fix createView NPE issue when region migration #14746
Browse files Browse the repository at this point in the history
Signed-off-by: OneSizeFitQuorum <[email protected]>
  • Loading branch information
OneSizeFitsQuorum authored Jan 21, 2025
1 parent cac80f0 commit 2448945
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ private DataNodeRegionManager() {}

public ReentrantReadWriteLock getRegionLock(ConsensusGroupId consensusGroupId) {
return consensusGroupId instanceof DataRegionId
? dataRegionLockMap.get((DataRegionId) consensusGroupId)
: schemaRegionLockMap.get((SchemaRegionId) consensusGroupId);
? dataRegionLockMap.get(consensusGroupId)
: schemaRegionLockMap.get(consensusGroupId);
}

public TSStatus createSchemaRegion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,14 @@ public RegionWriteExecutor(
@SuppressWarnings("squid:S1181")
public RegionExecutionResult execute(ConsensusGroupId groupId, PlanNode planNode) {
try {
WritePlanNodeExecutionContext context =
new WritePlanNodeExecutionContext(groupId, regionManager.getRegionLock(groupId));
return planNode.accept(executionVisitor, context);
ReentrantReadWriteLock lock = regionManager.getRegionLock(groupId);
if (lock == null) {
return RegionExecutionResult.create(
false,
"Failed to get the lock of the region because the region is not existed.",
RpcUtils.getStatus(TSStatusCode.NO_AVAILABLE_REGION_GROUP));
}
return planNode.accept(executionVisitor, new WritePlanNodeExecutionContext(groupId, lock));
} catch (Throwable e) {
LOGGER.warn(e.getMessage(), e);
return RegionExecutionResult.create(
Expand Down

0 comments on commit 2448945

Please sign in to comment.