yiguolei commented on code in PR #23616:
URL: https://github.com/apache/doris/pull/23616#discussion_r1312433170


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnIdFlushDaemon.java:
##########
@@ -0,0 +1,134 @@
+// 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.catalog;
+
+import org.apache.doris.alter.AlterLightSchChangeHelper;
+import org.apache.doris.common.util.MasterDaemon;
+
+import com.google.common.collect.Maps;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * note(tsy): this class is temporary, make table before 1.2 to enable light 
schema change
+ */
+public class ColumnIdFlushDaemon extends MasterDaemon {
+
+    /**
+     * db name -> (tbl name -> status)
+     */
+    private final Map<String, Map<String, FlushStatus>> resultCollector;
+
+    private final ReadWriteLock rwLock;
+
+    public ColumnIdFlushDaemon() {
+        super("colum-id-flusher", TimeUnit.HOURS.toMillis(1));
+        resultCollector = Maps.newHashMap();
+        rwLock = new ReentrantReadWriteLock();
+    }
+
+    @Override
+    protected void runAfterCatalogReady() {
+        flush();
+    }
+
+    private void flush() {
+        List<Database> dbs = Env.getCurrentEnv().getInternalCatalog().getDbs();
+        rwLock.writeLock().lock();
+        try {
+            for (Database db : dbs) {
+                db.getTables()
+                        .stream()
+                        .filter(table -> table instanceof OlapTable)
+                        .map(table -> (OlapTable) table)
+                        .filter(olapTable -> 
!olapTable.getTableProperty().getUseSchemaLightChange())
+                        .forEach(table -> {
+                            try {
+                                table.writeLock();
+                                if 
(table.getTableProperty().getUseSchemaLightChange()) {
+                                    table.writeUnlock();
+                                    return;
+                                }
+                                new AlterLightSchChangeHelper(db, 
table).enableLightSchemaChange();
+                                table.writeUnlock();
+                                recordResult(db.getFullName(), 
table.getName(), FlushStatus.ok());
+                            } catch (IllegalStateException e) {
+                                recordResult(db.getFullName(), 
table.getName(), FlushStatus.failed(e.getMessage()));
+                            }
+                        });
+            }
+        } finally {
+            rwLock.writeLock().unlock();
+        }
+    }
+
+    private void recordResult(String dbName, String tableName, FlushStatus 
status) {
+        resultCollector.putIfAbsent(dbName, Maps.newHashMap());
+        Map<String, FlushStatus> tableToStatus = resultCollector.get(dbName);
+        tableToStatus.put(tableName, status);
+    }
+
+    public Map<String, Map<String, FlushStatus>> getResultCollector() {
+        return resultCollector;

Review Comment:
   If use does not set enable_convert_light_weight_schema_change to true, the 
the result collector is empty. User will not know if the flush process is 
stopped or it is not begin.
   
   I think the show xxx comand should return the tables that not convert to 
light weigth schema change, it has no relation with the config 
"enable_convert_light_weight_schema_change":
   1. if all tables are converted, then the command return empty.
   2. it should return (1) the tables that are not converted  (2) the tables 
that have been converted but meet errors and the error message.



-- 
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

Reply via email to