flyrain commented on code in PR #3385: URL: https://github.com/apache/polaris/pull/3385#discussion_r2842897864
########## runtime/admin/src/main/java/org/apache/polaris/admintool/BootstrapMetricsCommand.java: ########## @@ -0,0 +1,120 @@ +/* + * 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.polaris.admintool; + +import io.smallrye.common.annotation.Identifier; +import jakarta.inject.Inject; +import java.util.List; +import org.apache.polaris.core.persistence.metrics.MetricsSchemaBootstrap; +import picocli.CommandLine; + +/** + * CLI command to bootstrap the metrics schema independently from the entity schema. + * + * <p>This command allows operators to add metrics persistence support to an existing Polaris + * deployment without re-bootstrapping the entity schema. It supports both fresh installation and + * upgrading from an older schema version to a newer one. + * + * <p>Example usage: + * + * <pre>{@code + * polaris-admin bootstrap-metrics -r my-realm + * polaris-admin bootstrap-metrics -r realm1 -r realm2 + * polaris-admin bootstrap-metrics -r my-realm --version 2 Review Comment: Is the `--include-metrics` option still needed given that this PR introduces `polaris-admin bootstrap-metrics -r my-realm`? Currently, `--include-metrics` enables `bootstrap` to create the metrics tables, but the schema version for metrics is hard coded to `1` in `JdbcMetaStoreManagerFactory`, here https://github.com/apache/polaris/blob/090887b42ae3a48ace84772524edffb4765dce95/persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcMetaStoreManagerFactory.java#L180. This means it ignores the version passed from the command line, for example `bootstrap -v 3`. If we introduce a new schema version for metrics, this could break existing users. Correct me if I am wrong. I believe this PR is to replace `--include-metrics` with `polaris-admin bootstrap-metrics`. However, I believe it would be better to keep the metrics table schema version aligned with other tables. We already follow this approach for policy, event, and idempotency key tables, and maintaining consistency here would reduce surprises and future migration issues. cc @singhpk234 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
