Code review comment: What would you like to know or talk about today?

Code under review:
public void processAlterTable(AlterTableStmt stmt) throws UserException {
        TableName dbTableName = stmt.getTbl();
        String dbName = dbTableName.getDb();
        String tableName = dbTableName.getTbl();
        Database db = GlobalStateMgr.getCurrentState().getDb(dbName);
        if (db == null) {
            ErrorReport.reportDdlException(ErrorCode.ERR_BAD_DB_ERROR, dbName);
        }
        Table table = db.getTable(tableName);
        if (table == null) {
            ErrorReport.reportDdlException(ErrorCode.ERR_BAD_TABLE_ERROR, tableName);
        }
        OlapTable olapTable = (OlapTable) table;

        
        boolean needProcessOutsideDatabaseLock = false;
        boolean isSynchronous = true;

        if (!(table.isOlapOrCloudNativeTable() || table.isMaterializedView())) {
            throw new DdlException("Do not support alter non-native table/materialized-view[" + tableName + "]");
        }

        List<AlterClause> alterClauses = stmt.getAlterClauseList();
        Locker locker = new Locker();
        locker.lockTablesWithIntensiveDbLock(db, Lists.newArrayList(table.getId()), LockType.WRITE);
        try {
            if (olapTable.getState() != OlapTableState.NORMAL) {
                throw InvalidOlapTableStateException.of(olapTable.getState(), olapTable.getName());
            }
            if (stmt.hasSchemaChangeOp()) {
                
                schemaChangeHandler.process(stmt.getAlterClauseList(), db, olapTable);
                isSynchronous = false;
            } else if (stmt.contains(AlterOpType.MODIFY_TABLE_PROPERTY_SYNC) &&
                    olapTable.isCloudNativeTable()) {
                schemaChangeHandler.processLakeTableAlterMeta(alterClauses, db, olapTable);
                isSynchronous = false;
            } else if (stmt.hasRollupOp()) {
                materializedViewHandler.process(alterClauses, db, olapTable);
                isSynchronous = false;
            } else if (stmt.contains(AlterOpType.RENAME)) {
                processRename(db, olapTable, alterClauses);
            } else if (stmt.contains(AlterOpType.ALTER_COMMENT)) {
                processAlterComment(db, olapTable, alterClauses);
            } else if (stmt.contains(AlterOpType.MODIFY_TABLE_PROPERTY_SYNC)) {
                needProcessOutsideDatabaseLock = true;
            } else if (stmt.contains(AlterOpType.COMPACT)) {
                needProcessOutsideDatabaseLock = true;
            } else {
                throw new DdlException("Invalid alter operations: " + stmt.getAlterClauseList());
            }
        } finally {
            locker.unLockTablesWithIntensiveDbLock(db, Lists.newArrayList(table.getId()), LockType.WRITE);
        }

        
        if (needProcessOutsideDatabaseLock) {
            Preconditions.checkState(alterClauses.size() == 1);
            AlterClause alterClause = alterClauses.get(0);
            if (alterClause instanceof ModifyTablePropertiesClause) {
                Map<String, String> properties = alterClause.getProperties();
                Preconditions.checkState(properties.containsKey(PropertyAnalyzer.PROPERTIES_INMEMORY) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_PERSISTENT_INDEX) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_REPLICATED_STORAGE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BUCKET_SIZE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_WRITE_QUORUM) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_ENABLE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_TTL) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_MAX_SIZE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_FOREIGN_KEY_CONSTRAINT) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_UNIQUE_CONSTRAINT) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_PRIMARY_INDEX_CACHE_EXPIRE_SEC));

                olapTable = (OlapTable) db.getTable(tableName);
                if (properties.containsKey(PropertyAnalyzer.PROPERTIES_INMEMORY)) {
                    schemaChangeHandler.updateTableMeta(db, tableName,
                            properties, TTabletMetaType.INMEMORY);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_PERSISTENT_INDEX)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.ENABLE_PERSISTENT_INDEX);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_WRITE_QUORUM)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.WRITE_QUORUM);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_REPLICATED_STORAGE)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.REPLICATED_STORAGE);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_BUCKET_SIZE)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.BUCKET_SIZE);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_PRIMARY_INDEX_CACHE_EXPIRE_SEC)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.PRIMARY_INDEX_CACHE_EXPIRE_SEC);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_ENABLE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_TTL) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_MAX_SIZE)) {
                    boolean isSuccess = schemaChangeHandler.updateBinlogConfigMeta(db, olapTable.getId(),
                            properties, TTabletMetaType.BINLOG_CONFIG);
                    if (!isSuccess) {
                        throw new DdlException("modify binlog config of FEMeta failed or table has been droped");
                    }
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_FOREIGN_KEY_CONSTRAINT)
                        || properties.containsKey(PropertyAnalyzer.PROPERTIES_UNIQUE_CONSTRAINT)) {
                    schemaChangeHandler.updateTableConstraint(db, olapTable.getName(), properties);
                } else {
                    throw new DdlException("Invalid alter operation: " + alterClause.getOpType());
                }
            }
        }

        if (isSynchronous) {
            olapTable.lastSchemaUpdateTime.set(System.nanoTime());
        }
    }

Line commented on: if (isSynchronous) {

Revised code:
public void processAlterTable(AlterTableStmt stmt) throws UserException {
        TableName dbTableName = stmt.getTbl();
        String dbName = dbTableName.getDb();
        String tableName = dbTableName.getTbl();
        Database db = GlobalStateMgr.getCurrentState().getDb(dbName);
        if (db == null) {
            ErrorReport.reportDdlException(ErrorCode.ERR_BAD_DB_ERROR, dbName);
        }
        Table table = db.getTable(tableName);
        if (table == null) {
            ErrorReport.reportDdlException(ErrorCode.ERR_BAD_TABLE_ERROR, tableName);
        }


        
        boolean needProcessOutsideDatabaseLock = false;
        boolean isSynchronous = true;

        if (!(table.isOlapOrCloudNativeTable() || table.isMaterializedView())) {
            throw new DdlException("Do not support alter non-native table/materialized-view[" + tableName + "]");
        }
        OlapTable olapTable = (OlapTable) table;

        List<AlterClause> alterClauses = stmt.getAlterClauseList();
        Locker locker = new Locker();
        locker.lockTablesWithIntensiveDbLock(db, Lists.newArrayList(table.getId()), LockType.WRITE);
        try {
            if (olapTable.getState() != OlapTableState.NORMAL) {
                throw InvalidOlapTableStateException.of(olapTable.getState(), olapTable.getName());
            }
            if (stmt.hasSchemaChangeOp()) {
                
                schemaChangeHandler.process(stmt.getAlterClauseList(), db, olapTable);
                isSynchronous = false;
            } else if (stmt.contains(AlterOpType.MODIFY_TABLE_PROPERTY_SYNC) &&
                    olapTable.isCloudNativeTable()) {
                schemaChangeHandler.processLakeTableAlterMeta(alterClauses, db, olapTable);
                isSynchronous = false;
            } else if (stmt.hasRollupOp()) {
                materializedViewHandler.process(alterClauses, db, olapTable);
                isSynchronous = false;
            } else if (stmt.contains(AlterOpType.RENAME)) {
                processRename(db, olapTable, alterClauses);
            } else if (stmt.contains(AlterOpType.ALTER_COMMENT)) {
                processAlterComment(db, olapTable, alterClauses);
            } else if (stmt.contains(AlterOpType.MODIFY_TABLE_PROPERTY_SYNC)) {
                needProcessOutsideDatabaseLock = true;
            } else if (stmt.contains(AlterOpType.COMPACT)) {
                needProcessOutsideDatabaseLock = true;
            } else {
                throw new DdlException("Invalid alter operations: " + stmt.getAlterClauseList());
            }
        } finally {
            locker.unLockTablesWithIntensiveDbLock(db, Lists.newArrayList(table.getId()), LockType.WRITE);
        }

        
        if (needProcessOutsideDatabaseLock) {
            Preconditions.checkState(alterClauses.size() == 1);
            AlterClause alterClause = alterClauses.get(0);
            if (alterClause instanceof ModifyTablePropertiesClause) {
                Map<String, String> properties = alterClause.getProperties();
                Preconditions.checkState(properties.containsKey(PropertyAnalyzer.PROPERTIES_INMEMORY) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_PERSISTENT_INDEX) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_REPLICATED_STORAGE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BUCKET_SIZE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_WRITE_QUORUM) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_ENABLE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_TTL) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_MAX_SIZE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_FOREIGN_KEY_CONSTRAINT) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_UNIQUE_CONSTRAINT) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_PRIMARY_INDEX_CACHE_EXPIRE_SEC));

                olapTable = (OlapTable) db.getTable(tableName);
                if (properties.containsKey(PropertyAnalyzer.PROPERTIES_INMEMORY)) {
                    schemaChangeHandler.updateTableMeta(db, tableName,
                            properties, TTabletMetaType.INMEMORY);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_ENABLE_PERSISTENT_INDEX)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.ENABLE_PERSISTENT_INDEX);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_WRITE_QUORUM)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.WRITE_QUORUM);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_REPLICATED_STORAGE)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.REPLICATED_STORAGE);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_BUCKET_SIZE)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.BUCKET_SIZE);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_PRIMARY_INDEX_CACHE_EXPIRE_SEC)) {
                    schemaChangeHandler.updateTableMeta(db, tableName, properties,
                            TTabletMetaType.PRIMARY_INDEX_CACHE_EXPIRE_SEC);
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_ENABLE) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_TTL) ||
                        properties.containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_MAX_SIZE)) {
                    boolean isSuccess = schemaChangeHandler.updateBinlogConfigMeta(db, olapTable.getId(),
                            properties, TTabletMetaType.BINLOG_CONFIG);
                    if (!isSuccess) {
                        throw new DdlException("modify binlog config of FEMeta failed or table has been droped");
                    }
                } else if (properties.containsKey(PropertyAnalyzer.PROPERTIES_FOREIGN_KEY_CONSTRAINT)
                        || properties.containsKey(PropertyAnalyzer.PROPERTIES_UNIQUE_CONSTRAINT)) {
                    schemaChangeHandler.updateTableConstraint(db, olapTable.getName(), properties);
                } else {
                    throw new DdlException("Invalid alter operation: " + alterClause.getOpType());
                }
            }
        }

        if (isSynchronous) {
            olapTable.lastSchemaUpdateTime.set(System.nanoTime());
        }
    }