Skip to content

Commit 7515568

Browse files
authored
Fixed the NPE caused by concurrent "check for createTimeSeries" and deleteTimeSeries (apache#16742)
* befix * shi
1 parent b7f9f8d commit 7515568

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/ISchemaRegion.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ void createTimeSeries(final ICreateTimeSeriesPlan plan, final long offset)
146146
* @param aliasList a list of alias that you want to check
147147
* @return returns a map contains index of the measurements or alias that threw the exception, and
148148
* exception details. The exceptions describe whether the measurement or alias exists. For
149-
* example, a MeasurementAlreadyExistException means this measurement exists.
149+
* example, a MeasurementAlreadyExistException means this measurement exists. If there are
150+
* exceptions during check, this may return an empty map, then all the measurements will be
151+
* re-checked under consensus layer, which guarantees safety(Yet may cause unnecessary replay
152+
* of raft log)
150153
*/
151154
Map<Integer, MetadataException> checkMeasurementExistence(
152155
final PartialPath devicePath,

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionMemoryImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,11 @@ public void createAlignedTimeSeries(final ICreateAlignedTimeSeriesPlan plan)
874874
@Override
875875
public Map<Integer, MetadataException> checkMeasurementExistence(
876876
PartialPath devicePath, List<String> measurementList, List<String> aliasList) {
877-
return mTree.checkMeasurementExistence(devicePath, measurementList, aliasList);
877+
try {
878+
return mTree.checkMeasurementExistence(devicePath, measurementList, aliasList);
879+
} catch (final Exception e) {
880+
return Collections.emptyMap();
881+
}
878882
}
879883

880884
@Override

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/impl/SchemaRegionPBTreeImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,11 @@ public void createAlignedTimeSeries(final ICreateAlignedTimeSeriesPlan plan)
855855
@Override
856856
public Map<Integer, MetadataException> checkMeasurementExistence(
857857
PartialPath devicePath, List<String> measurementList, List<String> aliasList) {
858-
return mtree.checkMeasurementExistence(devicePath, measurementList, aliasList);
858+
try {
859+
return mtree.checkMeasurementExistence(devicePath, measurementList, aliasList);
860+
} catch (final Exception e) {
861+
return Collections.emptyMap();
862+
}
859863
}
860864

861865
@Override

0 commit comments

Comments
 (0)