This is an automated email from the ASF dual-hosted git repository.

JackieTien97 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 35886a5d392 Pipe: Fixed the bug that attribute sync may cause 
ArrayIndexOutOfBoundsException / eliminate the existing attributes at the 
receiver which == null at the sender (#17539)
35886a5d392 is described below

commit 35886a5d39227978fdc8f8804e72420b3eeed1b6
Author: Caideyipi <[email protected]>
AuthorDate: Wed Apr 22 18:43:38 2026 +0800

    Pipe: Fixed the bug that attribute sync may cause 
ArrayIndexOutOfBoundsException / eliminate the existing attributes at the 
receiver which == null at the sender (#17539)
---
 .../org/apache/iotdb/db/it/utils/TestUtils.java    |  7 ++---
 .../manual/enhanced/IoTDBPipeMetaIT.java           | 34 ++++++++++++++++++++--
 .../node/schema/CreateOrUpdateTableDeviceNode.java |  3 +-
 .../attribute/DeviceAttributeStore.java            |  7 +++++
 .../db/tools/schema/SRStatementGenerator.java      |  9 +++++-
 .../db/utils/SchemaRegionSnapshotParserTest.java   |  5 +++-
 pom.xml                                            |  2 +-
 7 files changed, 57 insertions(+), 10 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java 
b/integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java
index 9c2a09024c4..93f14dc572b 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java
@@ -1055,16 +1055,15 @@ public class TestUtils {
         null);
   }
 
-  public static void executeNonQueries(
-      BaseEnv env, List<String> sqlList, Connection defaultConnection) {
+  public static void executeNonQueries(BaseEnv env, List<String> sqlList, 
String sqlDialect) {
     executeNonQueries(
         env,
         sqlList,
         SessionConfig.DEFAULT_USER,
         SessionConfig.DEFAULT_PASSWORD,
         null,
-        TREE_SQL_DIALECT,
-        defaultConnection);
+        sqlDialect,
+        null);
   }
 
   public static void executeNonQueries(
diff --git 
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeMetaIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeMetaIT.java
index 936ca1f5097..f26aa171ae1 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeMetaIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeMetaIT.java
@@ -232,8 +232,7 @@ public class IoTDBPipeMetaIT extends 
AbstractPipeTableModelDualManualIT {
               "create database root.test",
               "alter database root.test with schema_region_group_num=2, 
data_region_group_num=3",
               "create timeSeries root.test.d1.s1 int32",
-              "insert into root.test.d1 (s1) values (1)"),
-          null);
+              "insert into root.test.d1 (s1) values (1)"));
 
       TestUtils.assertDataAlwaysOnEnv(
           receiverEnv,
@@ -418,4 +417,35 @@ public class IoTDBPipeMetaIT extends 
AbstractPipeTableModelDualManualIT {
       }
     }
   }
+
+  @Test
+  public void testAttributeSync() {
+    TestUtils.executeNonQueries(
+        receiverEnv,
+        Arrays.asList(
+            "create database test",
+            "use test",
+            "create table table1(a tag, b attribute, c attribute, d int32)",
+            "insert into table1 (time, a, b, c, d) values(1, 1, null, 1, 1), 
(2, 2, 2, null, 2)"),
+        BaseEnv.TABLE_SQL_DIALECT);
+
+    TestUtils.executeNonQueries(
+        senderEnv,
+        Arrays.asList(
+            "create database test",
+            "use test",
+            "create table table1(a tag, b attribute, c attribute, d int32)",
+            "insert into table1 (time, a, b, c, d) values(1, 1, 1, null, 1), 
(2, 2, null, 2, 2)",
+            String.format(
+                "create pipe a2b with source ('inclusion'='schema') with sink 
('node-urls'='%s')",
+                
receiverEnv.getDataNodeWrapperList().get(0).getIpAndPortString())),
+        BaseEnv.TABLE_SQL_DIALECT);
+
+    TestUtils.assertDataAlwaysOnEnv(
+        receiverEnv,
+        "show devices from table1",
+        "a,b,c,",
+        new HashSet<>(Arrays.asList("1,1,1,", "2,2,2,")),
+        "test");
+  }
 }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/schema/CreateOrUpdateTableDeviceNode.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/schema/CreateOrUpdateTableDeviceNode.java
index be4b1337e7e..1ee49df2bdf 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/schema/CreateOrUpdateTableDeviceNode.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/node/schema/CreateOrUpdateTableDeviceNode.java
@@ -31,6 +31,7 @@ import 
org.apache.iotdb.db.schemaengine.schemaregion.SchemaRegionPlanType;
 import org.apache.iotdb.db.schemaengine.schemaregion.SchemaRegionPlanVisitor;
 
 import org.apache.tsfile.file.metadata.IDeviceID;
+import org.apache.tsfile.utils.Constants;
 import org.apache.tsfile.utils.ReadWriteIOUtils;
 
 import java.io.DataOutputStream;
@@ -215,7 +216,7 @@ public class CreateOrUpdateTableDeviceNode extends 
WritePlanNode implements ISch
         ReadWriteIOUtils.writeObject(value, stream);
       }
       for (int i = 0; i < attributeNameList.size() - 
deviceAttributeValueList.length; ++i) {
-        ReadWriteIOUtils.writeObject(null, stream);
+        ReadWriteIOUtils.writeObject(Constants.NONE, stream);
       }
     }
   }
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/attribute/DeviceAttributeStore.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/attribute/DeviceAttributeStore.java
index ee0b5f98c8a..4349a7a49f1 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/attribute/DeviceAttributeStore.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/attribute/DeviceAttributeStore.java
@@ -27,6 +27,7 @@ import 
org.apache.iotdb.db.schemaengine.rescon.MemSchemaRegionStatistics;
 import 
org.apache.iotdb.db.schemaengine.schemaregion.attribute.update.UpdateDetailContainer;
 
 import org.apache.tsfile.utils.Binary;
+import org.apache.tsfile.utils.Constants;
 import org.apache.tsfile.utils.RamUsageEstimator;
 import org.apache.tsfile.utils.ReadWriteIOUtils;
 import org.slf4j.Logger;
@@ -163,6 +164,12 @@ public class DeviceAttributeStore implements 
IDeviceAttributeStore {
     final Map<String, Binary> attributeMap = deviceAttributeList.get(pointer);
     for (int i = 0; i < nameList.size(); i++) {
       final String key = nameList.get(i);
+      if (valueList.length <= i) {
+        break;
+      }
+      if (valueList[i] == Constants.NONE) {
+        continue;
+      }
       final Binary value = (Binary) valueList[i];
 
       originMemUsage =
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/schema/SRStatementGenerator.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/schema/SRStatementGenerator.java
index 239b55b521b..aa478491f19 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/schema/SRStatementGenerator.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/tools/schema/SRStatementGenerator.java
@@ -45,6 +45,7 @@ import 
org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.mem.mnode.info.T
 import 
org.apache.iotdb.db.schemaengine.schemaregion.mtree.impl.mem.snapshot.MemMTreeSnapshotUtil;
 
 import org.apache.tsfile.utils.Binary;
+import org.apache.tsfile.utils.Constants;
 import org.apache.tsfile.utils.Pair;
 import org.apache.tsfile.utils.ReadWriteIOUtils;
 import org.slf4j.Logger;
@@ -447,7 +448,13 @@ public class SRStatementGenerator implements 
Iterator<Object>, Iterable<Object>
           attributeNameList = new ArrayList<>(tableAttributes.keySet());
         }
         final List<Object> attributeValues =
-            
attributeNameList.stream().map(tableAttributes::remove).collect(Collectors.toList());
+            attributeNameList.stream()
+                .map(
+                    attributeKey -> {
+                      final Object attributeValue = 
tableAttributes.remove(attributeKey);
+                      return Objects.nonNull(attributeValue) ? attributeValue 
: Constants.NONE;
+                    })
+                .collect(Collectors.toList());
         tableAttributes.forEach(
             (attributeKey, attributeValue) -> {
               attributeNameList.add(attributeKey);
diff --git 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/SchemaRegionSnapshotParserTest.java
 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/SchemaRegionSnapshotParserTest.java
index 471a02c70b7..c7cbc78d210 100644
--- 
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/SchemaRegionSnapshotParserTest.java
+++ 
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/SchemaRegionSnapshotParserTest.java
@@ -48,6 +48,7 @@ import org.apache.tsfile.external.commons.io.FileUtils;
 import org.apache.tsfile.file.metadata.enums.CompressionType;
 import org.apache.tsfile.file.metadata.enums.TSEncoding;
 import org.apache.tsfile.utils.Binary;
+import org.apache.tsfile.utils.Constants;
 import org.apache.tsfile.utils.Pair;
 import org.junit.After;
 import org.junit.Assert;
@@ -313,7 +314,9 @@ public class SchemaRegionSnapshotParserTest {
                     Arrays.asList("a", "c"),
                     Arrays.asList(
                         new Binary[] {new Binary("b", 
TSFileConfig.STRING_CHARSET)},
-                        new Binary[] {null, new Binary("d", 
TSFileConfig.STRING_CHARSET)})),
+                        new Object[] {
+                          Constants.NONE, new Binary("d", 
TSFileConfig.STRING_CHARSET)
+                        })),
                 new CreateOrUpdateDevice(
                     databasePath.getNodes()[1],
                     anotherTable,
diff --git a/pom.xml b/pom.xml
index 1763a519f9e..dc46047da2e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -163,7 +163,7 @@
         <thrift.version>0.14.1</thrift.version>
         <xz.version>1.9</xz.version>
         <zstd-jni.version>1.5.6-3</zstd-jni.version>
-        <tsfile.version>2.2.1-260327-SNAPSHOT</tsfile.version>
+        <tsfile.version>2.3.0-260422-SNAPSHOT</tsfile.version>
     </properties>
     <!--
     if we claim dependencies in dependencyManagement, then we do not claim

Reply via email to