morrySnow commented on code in PR #34548: URL: https://github.com/apache/doris/pull/34548#discussion_r1600917966
########## fe/fe-core/src/main/java/org/apache/doris/event/TableEvent.java: ########## @@ -0,0 +1,52 @@ +// 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.event; + +public class TableEvent extends Event { Review Comment: abstract? ########## fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVJob.java: ########## @@ -140,27 +140,37 @@ public List<MTMVTask> createTasks(TaskType taskType, MTMVTaskContext taskContext /** * if user trigger, return true - * if system trigger, Check if there are any system triggered tasks, and if so, return false + * else, only can have 2 task. because every task can refresh all data. * * @param taskContext * @return */ @Override public boolean isReadyForScheduling(MTMVTaskContext taskContext) { - if (taskContext != null) { + if (isManual(taskContext)) { return true; } List<MTMVTask> runningTasks = getRunningTasks(); + int runningNum = 0; for (MTMVTask task : runningTasks) { - if (task.getTaskContext() == null || task.getTaskContext().getTriggerMode() == MTMVTaskTriggerMode.SYSTEM) { - LOG.warn("isReadyForScheduling return false, because current taskContext is null, exist task: {}", - task); - return false; + if (!isManual(task.getTaskContext())) { + runningNum++; + // TODO: 2024/5/9 When the scheduling framework supports running only one task simultaneously, + // change to 2 to prevent message loss Review Comment: cannot understand this TODO. could u explain it clearly? why change to 2 could prevent message loss ########## fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java: ########## @@ -1863,7 +1864,9 @@ public void dropPartition(Database db, OlapTable olapTable, DropPartitionClause DropPartitionInfo info = new DropPartitionInfo(db.getId(), olapTable.getId(), partitionName, isTempPartition, clause.isForceDrop(), recycleTime, version, versionTime); Env.getCurrentEnv().getEditLog().logDropPartition(info); - + Env.getCurrentEnv().getEventProcessor().processEvent( + new DropPartitionEvent(db.getCatalog().getId(), db.getId(), + olapTable.getId())); Review Comment: if we do not persist these events, what will happen if fe stop after logDropPartition and before processEvent? ########## fe/fe-core/src/main/java/org/apache/doris/mtmv/BaseTableInfo.java: ########## @@ -44,6 +44,12 @@ public BaseTableInfo(Long tableId, Long dbId) { this.ctlId = InternalCatalog.INTERNAL_CATALOG_ID; } + public BaseTableInfo(Long tableId, Long dbId, Long ctlId) { Review Comment: why not just unboxing type **long** in parameter list ########## fe/fe-core/src/main/java/org/apache/doris/event/DropPartitionEvent.java: ########## @@ -0,0 +1,29 @@ +// 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.event; + +public class DropPartitionEvent extends TableEvent { + public DropPartitionEvent(long ctlId, long dbId, long tableId) { + super(EventType.DROP_PARTITION, ctlId, dbId, tableId); + } + + @Override + public String toString() { + return super.toString(); + } Review Comment: nit: remove this ########## fe/fe-core/src/main/java/org/apache/doris/event/EventProcessor.java: ########## @@ -0,0 +1,57 @@ +// 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.event; + +import com.google.common.collect.Sets; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Objects; +import java.util.Set; + +public class EventProcessor { + + private static final Logger LOG = LogManager.getLogger(EventProcessor.class); + + private Set<EventListener> listeners = Sets.newHashSet(); + + public EventProcessor(EventListener... args) { + for (EventListener listener : args) { + this.listeners.add(listener); + } + } + + public boolean processEvent(Event event) { + Objects.requireNonNull(event); + if (LOG.isDebugEnabled()) { + LOG.debug("processEvent: {}", event); + } + boolean result = true; + for (EventListener listener : listeners) { + try { + listener.processEvent(event); Review Comment: If `processEvent` is a heavy operation, it will block the thread. So, should a separate thread pool be used to execute `processEvent` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org