Skip to content

Commit

Permalink
Fix createView NPE issue when region migration #14746 (#14747)
Browse files Browse the repository at this point in the history
Signed-off-by: OneSizeFitQuorum <tanxinyu@apache.org>
  • Loading branch information
OneSizeFitsQuorum authored Jan 22, 2025
1 parent b8fa0b6 commit ec84ae1
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 @@ -100,8 +100,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(TRegionReplicaSet regionReplicaSet, String storageGroup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,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 ec84ae1

Please sign in to comment.