Skip to content

Commit bfb538a

Browse files
authored
Fix tree schema snapshot database creation on master (#17964) (#17979)
(cherry picked from commit dd3153e)
1 parent aaa5729 commit bfb538a

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiver.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,14 +539,13 @@ private TSStatus loadSchemaSnapShot(
539539
throws IllegalPathException, IOException {
540540
final String databaseName = parameters.get(ColumnHeaderConstant.DATABASE);
541541
final PartialPath databasePath = new PartialPath(databaseName);
542-
543542
final String pathPattern = parameters.get(ColumnHeaderConstant.PATH_PATTERN);
544-
if (!shouldLoadSchemaSnapshotDatabase(pathPattern, databaseName)) {
545-
return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
546-
}
547543
final PipePattern pipePattern =
548544
PipePattern.parsePatternFromString(pathPattern, IoTDBPipePattern::new);
549545

546+
if (!shouldLoadTreeSchemaSnapshotDatabase(pipePattern, databaseName)) {
547+
return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
548+
}
550549
final TSStatus createDatabaseStatus = createSchemaSnapshotDatabaseIfNecessary(databasePath);
551550
if (createDatabaseStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
552551
return createDatabaseStatus;
@@ -584,10 +583,18 @@ private TSStatus loadSchemaSnapShot(
584583
return PipeReceiverStatusHandler.getPriorStatus(results);
585584
}
586585

587-
static boolean shouldLoadSchemaSnapshotDatabase(
588-
final String pathPattern, final String databaseName) {
589-
return PipePattern.parsePatternFromString(pathPattern, IoTDBPipePattern::new)
590-
.mayOverlapWithDb(databaseName);
586+
static boolean shouldLoadTreeSchemaSnapshotDatabase(
587+
final String pathPattern,
588+
final boolean isTreeModelDataAllowedToBeCaptured,
589+
final String databaseName) {
590+
return isTreeModelDataAllowedToBeCaptured
591+
&& shouldLoadTreeSchemaSnapshotDatabase(
592+
PipePattern.parsePatternFromString(pathPattern, IoTDBPipePattern::new), databaseName);
593+
}
594+
595+
private static boolean shouldLoadTreeSchemaSnapshotDatabase(
596+
final PipePattern pipePattern, final String databaseName) {
597+
return pipePattern.mayOverlapWithDb(databaseName);
591598
}
592599

593600
private TSStatus createSchemaSnapshotDatabaseIfNecessary(final PartialPath databasePath) {

iotdb-core/datanode/src/test/java/org/apache/iotdb/db/pipe/receiver/protocol/thrift/IoTDBDataNodeReceiverTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,15 @@ public void testRepeatedStatementExceptionLogIsReduced() throws Exception {
111111
}
112112

113113
@Test
114-
public void testSchemaSnapshotDatabaseIsFilteredByPattern() {
114+
public void testTreeSchemaSnapshotDatabaseIsFilteredByPattern() {
115115
Assert.assertTrue(
116-
IoTDBDataNodeReceiver.shouldLoadSchemaSnapshotDatabase("root.ln.**", "root.ln"));
117-
Assert.assertTrue(IoTDBDataNodeReceiver.shouldLoadSchemaSnapshotDatabase("root.**", "root.db"));
116+
IoTDBDataNodeReceiver.shouldLoadTreeSchemaSnapshotDatabase("root.ln.**", true, "root.ln"));
117+
Assert.assertTrue(
118+
IoTDBDataNodeReceiver.shouldLoadTreeSchemaSnapshotDatabase("root.**", true, "root.db"));
119+
Assert.assertFalse(
120+
IoTDBDataNodeReceiver.shouldLoadTreeSchemaSnapshotDatabase("root.ln.**", true, "root.db"));
118121
Assert.assertFalse(
119-
IoTDBDataNodeReceiver.shouldLoadSchemaSnapshotDatabase("root.ln.**", "root.db"));
122+
IoTDBDataNodeReceiver.shouldLoadTreeSchemaSnapshotDatabase("root.ln.**", false, "root.ln"));
120123
}
121124

122125
@Test

0 commit comments

Comments
 (0)