This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new d1df0b88789 [fix](mtmv)Solving the problem of calling each other in
toString() loops (#34277) (#34317)
d1df0b88789 is described below
commit d1df0b887897c369da5678989c3015f4f5695b36
Author: zhangdong <[email protected]>
AuthorDate: Mon Apr 29 21:46:29 2024 +0800
[fix](mtmv)Solving the problem of calling each other in toString() loops
(#34277) (#34317)
bp #34277
---
.../main/java/org/apache/doris/catalog/MTMV.java | 87 +++++++++++++++++-----
.../apache/doris/job/extensions/mtmv/MTMVTask.java | 3 -
.../java/org/apache/doris/mtmv/MTMVJobInfo.java | 4 +-
.../doris/mtmv/MTMVMaxTimestampSnapshot.java | 8 ++
.../org/apache/doris/mtmv/MTMVPartitionInfo.java | 4 +-
.../doris/mtmv/MTMVRefreshPartitionSnapshot.java | 8 ++
.../org/apache/doris/mtmv/MTMVRefreshSnapshot.java | 7 ++
.../java/org/apache/doris/mtmv/MTMVRelation.java | 4 +-
.../apache/doris/mtmv/MTMVTimestampSnapshot.java | 7 ++
.../org/apache/doris/mtmv/MTMVVersionSnapshot.java | 7 ++
.../doris/tablefunction/MetadataGenerator.java | 2 +-
.../test/java/org/apache/doris/mtmv/MTMVTest.java | 86 +++++++++++++++++++++
12 files changed, 199 insertions(+), 28 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
index a751cd4beec..c76f1a253f2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
@@ -364,6 +364,51 @@ public class MTMV extends OlapTable {
return res;
}
+ // for test
+ public void setRefreshInfo(MTMVRefreshInfo refreshInfo) {
+ this.refreshInfo = refreshInfo;
+ }
+
+ // for test
+ public void setQuerySql(String querySql) {
+ this.querySql = querySql;
+ }
+
+ // for test
+ public void setStatus(MTMVStatus status) {
+ this.status = status;
+ }
+
+ // for test
+ public void setEnvInfo(EnvInfo envInfo) {
+ this.envInfo = envInfo;
+ }
+
+ // for test
+ public void setJobInfo(MTMVJobInfo jobInfo) {
+ this.jobInfo = jobInfo;
+ }
+
+ // for test
+ public void setMvProperties(Map<String, String> mvProperties) {
+ this.mvProperties = mvProperties;
+ }
+
+ // for test
+ public void setRelation(MTMVRelation relation) {
+ this.relation = relation;
+ }
+
+ // for test
+ public void setMvPartitionInfo(MTMVPartitionInfo mvPartitionInfo) {
+ this.mvPartitionInfo = mvPartitionInfo;
+ }
+
+ // for test
+ public void setRefreshSnapshot(MTMVRefreshSnapshot refreshSnapshot) {
+ this.refreshSnapshot = refreshSnapshot;
+ }
+
public void readMvLock() {
this.mvRwLock.readLock().lock();
}
@@ -405,23 +450,29 @@ public class MTMV extends OlapTable {
}
}
- @Override
- public String toString() {
- return "MTMV{"
- + ", refreshInfo=" + refreshInfo
- + ", querySql='" + querySql + '\''
- + ", status=" + status
- + ", envInfo=" + envInfo
- + ", jobInfo=" + jobInfo
- + ", mvProperties=" + mvProperties
- + ", relation=" + relation
- + ", mvPartitionInfo=" + mvPartitionInfo
- + ", refreshSnapshot=" + refreshSnapshot
- + ", cache=" + cache
- + ", id=" + id
- + ", name='" + name + '\''
- + ", qualifiedDbName='" + qualifiedDbName + '\''
- + ", comment='" + comment + '\''
- + '}';
+ // toString() is not easy to find where to call the method
+ public String toInfoString() {
+ final StringBuilder sb = new StringBuilder("MTMV{");
+ sb.append("refreshInfo=").append(refreshInfo);
+ sb.append(", querySql='").append(querySql).append('\'');
+ sb.append(", status=").append(status);
+ sb.append(", envInfo=").append(envInfo);
+ if (jobInfo != null) {
+ sb.append(", jobInfo=").append(jobInfo.toInfoString());
+ }
+ sb.append(", mvProperties=").append(mvProperties);
+ if (relation != null) {
+ sb.append(", relation=").append(relation.toInfoString());
+ }
+ if (mvPartitionInfo != null) {
+ sb.append(",
mvPartitionInfo=").append(mvPartitionInfo.toInfoString());
+ }
+ sb.append(", refreshSnapshot=").append(refreshSnapshot);
+ sb.append(", id=").append(id);
+ sb.append(", name='").append(name).append('\'');
+ sb.append(", qualifiedDbName='").append(qualifiedDbName).append('\'');
+ sb.append(", comment='").append(comment).append('\'');
+ sb.append('}');
+ return sb.toString();
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
index 42560575b14..f67144cd0d3 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
@@ -441,9 +441,6 @@ public class MTMVTask extends AbstractTask {
+ ", needRefreshPartitions=" + needRefreshPartitions
+ ", completedPartitions=" + completedPartitions
+ ", refreshMode=" + refreshMode
- + ", mtmv=" + mtmv
- + ", relation=" + relation
- + ", executor=" + executor
+ "} " + super.toString();
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
index b9a65e4d543..eb79c30adf5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
@@ -56,8 +56,8 @@ public class MTMVJobInfo {
return historyTasks;
}
- @Override
- public String toString() {
+ // toString() is not easy to find where to call the method
+ public String toInfoString() {
return "MTMVJobInfo{"
+ "jobName='" + jobName + '\''
+ ", historyTasks=" + historyTasks
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVMaxTimestampSnapshot.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVMaxTimestampSnapshot.java
index 5b551cebef6..53f9df542cf 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVMaxTimestampSnapshot.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVMaxTimestampSnapshot.java
@@ -56,4 +56,12 @@ public class MTMVMaxTimestampSnapshot implements
MTMVSnapshotIf {
public int hashCode() {
return Objects.hashCode(partitionId, timestamp);
}
+
+ @Override
+ public String toString() {
+ return "MTMVMaxTimestampSnapshot{"
+ + "partitionId=" + partitionId
+ + ", timestamp=" + timestamp
+ + '}';
+ }
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionInfo.java
index 3a364e0749d..348f6e4de99 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPartitionInfo.java
@@ -102,8 +102,8 @@ public class MTMVPartitionInfo {
return MTMVPartitionUtil.getPos(getRelatedTable(), relatedCol);
}
- @Override
- public String toString() {
+ // toString() is not easy to find where to call the method
+ public String toInfoString() {
return "MTMVPartitionInfo{"
+ "partitionType=" + partitionType
+ ", relatedTable=" + relatedTable
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshPartitionSnapshot.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshPartitionSnapshot.java
index 8de2b4cdfed..2336c3922ea 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshPartitionSnapshot.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshPartitionSnapshot.java
@@ -40,4 +40,12 @@ public class MTMVRefreshPartitionSnapshot {
public Map<Long, MTMVSnapshotIf> getTables() {
return tables;
}
+
+ @Override
+ public String toString() {
+ return "MTMVRefreshPartitionSnapshot{"
+ + "partitions=" + partitions
+ + ", tables=" + tables
+ + '}';
+ }
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshSnapshot.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshSnapshot.java
index 5132f06a12e..c1d07b27049 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshSnapshot.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshSnapshot.java
@@ -72,4 +72,11 @@ public class MTMVRefreshSnapshot {
}
}
}
+
+ @Override
+ public String toString() {
+ return "MTMVRefreshSnapshot{"
+ + "partitionSnapshots=" + partitionSnapshots
+ + '}';
+ }
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java
index d8f4d5be627..b9f5350086a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java
@@ -44,8 +44,8 @@ public class MTMVRelation {
return baseViews;
}
- @Override
- public String toString() {
+ // toString() is not easy to find where to call the method
+ public String toInfoString() {
return "MTMVRelation{"
+ "baseTables=" + baseTables
+ ", baseViews=" + baseViews
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVTimestampSnapshot.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVTimestampSnapshot.java
index b3fd88a94de..359f83abf89 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVTimestampSnapshot.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVTimestampSnapshot.java
@@ -48,4 +48,11 @@ public class MTMVTimestampSnapshot implements MTMVSnapshotIf
{
public int hashCode() {
return Objects.hashCode(timestamp);
}
+
+ @Override
+ public String toString() {
+ return "MTMVTimestampSnapshot{"
+ + "timestamp=" + timestamp
+ + '}';
+ }
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVVersionSnapshot.java
b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVVersionSnapshot.java
index 14304e60183..0eb7860bc54 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVVersionSnapshot.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVVersionSnapshot.java
@@ -44,4 +44,11 @@ public class MTMVVersionSnapshot implements MTMVSnapshotIf {
public int hashCode() {
return Objects.hashCode(version);
}
+
+ @Override
+ public String toString() {
+ return "MTMVVersionSnapshot{"
+ + "version=" + version
+ + '}';
+ }
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
index 85d9ce94cdd..50d97e69705 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
@@ -727,7 +727,7 @@ public class MetadataGenerator {
}
MTMV mv = (MTMV) table;
if (LOG.isDebugEnabled()) {
- LOG.debug("mv: " + mv);
+ LOG.debug("mv: " + mv.toInfoString());
}
TRow trow = new TRow();
trow.addToColumnValue(new TCell().setLongVal(mv.getId()));
diff --git a/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVTest.java
b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVTest.java
new file mode 100644
index 00000000000..695203b9cec
--- /dev/null
+++ b/fe/fe-core/src/test/java/org/apache/doris/mtmv/MTMVTest.java
@@ -0,0 +1,86 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.catalog.MTMV;
+import org.apache.doris.job.common.IntervalUnit;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+import org.apache.doris.mtmv.MTMVRefreshEnum.BuildMode;
+import org.apache.doris.mtmv.MTMVRefreshEnum.RefreshMethod;
+import org.apache.doris.mtmv.MTMVRefreshEnum.RefreshTrigger;
+
+import com.google.common.collect.Sets;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashMap;
+
+public class MTMVTest {
+ @Test
+ public void testToInfoString() {
+ String expect
+ = "MTMV{refreshInfo=BUILD IMMEDIATE REFRESH COMPLETE ON
SCHEDULE EVERY 2 SECOND STARTS ss, "
+ + "querySql='select * from xxx;', "
+ + "status=MTMVStatus{state=INIT, schemaChangeDetail='null',
refreshState=INIT}, "
+ + "envInfo=EnvInfo{ctlId='1', dbId='2'}, "
+ + "jobInfo=MTMVJobInfo{jobName='job1', "
+ + "historyTasks=[MTMVTask{dbId=0, mtmvId=0, taskContext=null, "
+ + "needRefreshPartitions=null, completedPartitions=null,
refreshMode=null} "
+ + "AbstractTask(jobId=null, taskId=1, status=null,
createTimeMs=null, startTimeMs=null, "
+ + "finishTimeMs=null, taskType=null, errMsg=null)]},
mvProperties={}, "
+ + "relation=MTMVRelation{baseTables=[], baseViews=[]}, "
+ + "mvPartitionInfo=MTMVPartitionInfo{partitionType=null,
relatedTable=null, "
+ + "relatedCol='null', partitionCol='null'}, "
+ + "refreshSnapshot=MTMVRefreshSnapshot{partitionSnapshots={}},
id=1, name='null', "
+ + "qualifiedDbName='db1', comment='comment1'}";
+ MTMV mtmv = new MTMV();
+ mtmv.setId(1L);
+ mtmv.setComment("comment1");
+ mtmv.setQualifiedDbName("db1");
+ mtmv.setRefreshInfo(buildMTMVRefreshInfo(mtmv));
+ mtmv.setQuerySql("select * from xxx;");
+ mtmv.setStatus(new MTMVStatus());
+ mtmv.setEnvInfo(new EnvInfo(1L, 2L));
+ mtmv.setJobInfo(buildMTMVJobInfo(mtmv));
+ mtmv.setMvProperties(new HashMap<>());
+ mtmv.setRelation(new MTMVRelation(Sets.newHashSet(),
Sets.newHashSet()));
+ mtmv.setMvPartitionInfo(new MTMVPartitionInfo());
+ mtmv.setRefreshSnapshot(new MTMVRefreshSnapshot());
+ Assert.assertEquals(expect, mtmv.toInfoString());
+ }
+
+ private MTMVRefreshInfo buildMTMVRefreshInfo(MTMV mtmv) {
+ MTMVRefreshTriggerInfo info = new
MTMVRefreshTriggerInfo(RefreshTrigger.SCHEDULE,
+ new MTMVRefreshSchedule("ss", 2,
+ IntervalUnit.SECOND));
+ MTMVRefreshInfo mtmvRefreshInfo = new
MTMVRefreshInfo(BuildMode.IMMEDIATE, RefreshMethod.COMPLETE, info);
+ return mtmvRefreshInfo;
+ }
+
+ private MTMVJobInfo buildMTMVJobInfo(MTMV mtmv) {
+ MTMVJobInfo mtmvJobInfo = new MTMVJobInfo("job1");
+ mtmvJobInfo.addHistoryTask(buildMTMVTask(mtmv));
+ return mtmvJobInfo;
+ }
+
+ private MTMVTask buildMTMVTask(MTMV mtmv) {
+ MTMVTask task = new MTMVTask(mtmv, null, null);
+ task.setTaskId(1L);
+ return task;
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]