Caideyipi commented on code in PR #18821:
URL: https://github.com/apache/iotdb/pull/18821#discussion_r4244068736
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java:
##########
@@ -933,6 +938,9 @@ private RegionExecutionResult executeAlterTimeSeries(
AlterTimeSeriesNode node, WritePlanNodeExecutionContext context,
boolean receivedFromPipe) {
ISchemaRegion schemaRegion =
schemaEngine.getSchemaRegion((SchemaRegionId) context.getRegionId());
+ if (schemaRegion == null) {
+ return createSchemaRegionUnavailableResult();
+ }
Review Comment:
**[P2] Handle a region cleared after the availability check**
This guard handles a region that is already absent from the map. An
in-flight request can still obtain a non-null region and call
`fetchMeasurementPath()` after shutdown clears that same object. In Memory
mode, `SchemaRegionMemoryImpl.clear()` calls
[`MTreeBelowSGMemoryImpl.clear()`](https://github.com/apache/iotdb/blob/df08230b067f84b80c705f4b1edb3f29ce13d9c4/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java#L191-L194),
which sets `databaseMNode` to `null`;
[`getNodeByPath()`](https://github.com/apache/iotdb/blob/df08230b067f84b80c705f4b1edb3f29ce13d9c4/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java#L1041-L1046)
subsequently dereferences it. That `NullPointerException` reaches the outer
`execute()` catch, which still returns `INTERNAL_SERVER_ERROR` (305) if the
validation lock remains registered.
Please coordinate this local validation with region teardown, or convert the
failure to `NO_AVAILABLE_REGION_GROUP` (906) when the region is confirmed to
have been cleared. The existing validation lock alone is insufficient because
`SchemaEngine.clear()` does not acquire it.
The unavailable-region cases in the new tests start with `getSchemaRegion()`
returning `null`. Please add a case that pauses after region lookup, clears the
region, and resumes the request to cover this interleaving.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]