This is an automated email from the ASF dual-hosted git repository. chaow pushed a commit to branch fix_plan_corrupt_bug in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit f2d6f84360e0ff2235dac59908bd9472bc04c9d1 Author: chaow <[email protected]> AuthorDate: Tue Mar 30 20:26:11 2021 +0800 fix stackoverflow when parse plan failed --- .../db/qp/physical/crud/InsertMultiTabletPlan.java | 3 +++ .../iotdb/db/qp/physical/crud/InsertRowsPlan.java | 3 +++ .../iotdb/db/qp/physical/crud/InsertTabletPlan.java | 2 +- .../qp/physical/sys/CreateMultiTimeSeriesPlan.java | 20 ++++++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertMultiTabletPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertMultiTabletPlan.java index 6f73a74..6749354 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertMultiTabletPlan.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertMultiTabletPlan.java @@ -199,6 +199,9 @@ public class InsertMultiTabletPlan extends InsertPlan { @Override public void checkIntegrity() throws QueryProcessException { + if (insertTabletPlanList.isEmpty()) { + throw new QueryProcessException("sub tablet is empty."); + } for (InsertTabletPlan insertTabletPlan : insertTabletPlanList) { insertTabletPlan.checkIntegrity(); } diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowsPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowsPlan.java index cdd35ab..28f4f3f 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowsPlan.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowsPlan.java @@ -81,6 +81,9 @@ public class InsertRowsPlan extends InsertPlan { @Override public void checkIntegrity() throws QueryProcessException { + if (insertRowPlanList.isEmpty()) { + throw new QueryProcessException("sub plan are empty."); + } for (InsertRowPlan insertRowPlan : insertRowPlanList) { insertRowPlan.checkIntegrity(); } diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertTabletPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertTabletPlan.java index 97b36cc..8ca7a40 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertTabletPlan.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertTabletPlan.java @@ -604,7 +604,7 @@ public class InsertTabletPlan extends InsertPlan { @Override public void checkIntegrity() throws QueryProcessException { super.checkIntegrity(); - if (columns == null) { + if (columns == null || columns.length == 0) { throw new QueryProcessException("Values are null"); } if (measurements.length != columns.length) { diff --git a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateMultiTimeSeriesPlan.java b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateMultiTimeSeriesPlan.java index 9ebc54b..4c0e854 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateMultiTimeSeriesPlan.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/physical/sys/CreateMultiTimeSeriesPlan.java @@ -19,6 +19,7 @@ package org.apache.iotdb.db.qp.physical.sys; import org.apache.iotdb.db.exception.metadata.IllegalPathException; +import org.apache.iotdb.db.exception.query.QueryProcessException; import org.apache.iotdb.db.metadata.PartialPath; import org.apache.iotdb.db.qp.logical.Operator; import org.apache.iotdb.db.qp.physical.PhysicalPlan; @@ -33,6 +34,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Objects; @@ -323,4 +325,22 @@ public class CreateMultiTimeSeriesPlan extends PhysicalPlan { public int hashCode() { return Objects.hash(paths, dataTypes, encodings, compressors); } + + @Override + public void checkIntegrity() throws QueryProcessException { + if (paths == null || paths.isEmpty()) { + throw new QueryProcessException("sub timeseries are empty"); + } + if (paths.size() != dataTypes.size()) { + throw new QueryProcessException( + String.format( + "Measurements length [%d] does not match " + " datatype length [%d]", + paths.size(), dataTypes.size())); + } + for (PartialPath path : paths) { + if (path == null) { + throw new QueryProcessException("Paths contain null: " + Arrays.toString(paths.toArray())); + } + } + } }
