dlmarion commented on code in PR #3137:
URL: https://github.com/apache/accumulo/pull/3137#discussion_r1062426873
##########
server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java:
##########
@@ -179,15 +187,21 @@ public synchronized Future<Void>
upgradeMetadata(ServerContext context,
.submit(() -> {
try {
for (int v = currentVersion; v < AccumuloDataVersion.get(); v++)
{
- log.info("Upgrading Root from data version {}", v);
- upgraders.get(v).upgradeRoot(context);
+ log.info("Upgrading Root from data version {} target version
{}", v,
+ AccumuloDataVersion.get());
+ if (upgraders.get(v) != null) {
+ upgraders.get(v).upgradeRoot(context);
+ }
}
setStatus(UpgradeStatus.UPGRADED_ROOT, eventCoordinator);
for (int v = currentVersion; v < AccumuloDataVersion.get(); v++)
{
- log.info("Upgrading Metadata from data version {}", v);
- upgraders.get(v).upgradeMetadata(context);
+ log.info("Upgrading Metadata from data version {} target
version {}", v,
+ AccumuloDataVersion.get());
+ if (upgraders.get(v) != null) {
+ upgraders.get(v).upgradeMetadata(context);
+ }
Review Comment:
I think you should replace lines 202 - 204 with
`upgraders.get(v).upgradeMetadata(context);`. You added the `requireNonNull`
check in the commit you mentioned, so it shouldn't be null. If it null here,
then this code will hide it and move on.
##########
server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java:
##########
@@ -105,8 +106,11 @@ public boolean isParentLevelUpgraded(KeyExtent extent) {
private static Logger log =
LoggerFactory.getLogger(UpgradeCoordinator.class);
private int currentVersion;
- private Map<Integer,Upgrader> upgraders =
Map.of(AccumuloDataVersion.SHORTEN_RFILE_KEYS,
- new Upgrader8to9(), AccumuloDataVersion.CRYPTO_CHANGES, new
Upgrader9to10());
+ // map of "current version" -> upgrader to next version.
+ private Map<Integer,
Review Comment:
`Map.of` returns an unmodifiable map. If you use `final` here, then the
`upgraders` variable can't be reassigned. This should give you confidence in
the map contents in the code below.
##########
server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader10to11.java:
##########
@@ -0,0 +1,264 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.manager.upgrade;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.accumulo.core.Constants.ZTABLES;
+import static org.apache.accumulo.core.Constants.ZTABLE_STATE;
+import static
org.apache.accumulo.core.metadata.schema.MetadataSchema.RESERVED_PREFIX;
+import static org.apache.accumulo.server.util.MetadataTableUtil.EMPTY_TEXT;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+import org.apache.accumulo.core.client.BatchDeleter;
+import org.apache.accumulo.core.client.BatchWriter;
+import org.apache.accumulo.core.client.MutationsRejectedException;
+import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.accumulo.core.data.InstanceId;
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.Range;
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter;
+import org.apache.accumulo.core.fate.zookeeper.ZooUtil;
+import org.apache.accumulo.core.manager.state.tables.TableState;
+import org.apache.accumulo.core.metadata.MetadataTable;
+import org.apache.accumulo.core.metadata.schema.MetadataSchema;
+import org.apache.accumulo.core.security.Authorizations;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.conf.store.PropStore;
+import org.apache.accumulo.server.conf.store.PropStoreKey;
+import org.apache.accumulo.server.conf.store.TablePropKey;
+import org.apache.hadoop.io.Text;
+import org.apache.zookeeper.KeeperException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Upgrader10to11 implements Upgrader {
+
+ private static final Logger log =
LoggerFactory.getLogger(Upgrader10to11.class);
+
+ // Included for upgrade code usage any other usage post 3.0 should not be
used.
+ private static final TableId REPLICATION_ID = TableId.of("+rep");
+
+ private static final Range REP_TABLE_RANGE =
+ new Range(REPLICATION_ID.canonical() + ";", true,
REPLICATION_ID.canonical() + "<", true);
+
+ // copied from MetadataSchema 2.1 (removed in 3.0)
+ private static final Range REP_WAL_RANGE =
+ new Range(RESERVED_PREFIX + "repl", true, RESERVED_PREFIX + "repm",
false);
+
+ public Upgrader10to11() {
+ super();
+ }
+
+ @Override
+ public void upgradeZookeeper(final ServerContext context) {
+ log.info("upgrade of ZooKeeper entries");
+
+ var zrw = context.getZooReaderWriter();
+ var iid = context.getInstanceID();
+
+ // if the replication base path (../tables/+rep) assume removed or never
existed.
+ if (!checkReplicationTableInZk(iid, zrw)) {
+ log.debug("replication table root node does not exist in ZooKeeper -
nothing to do");
+ return;
+ }
+
+ // if the replication table is online - stop. There could be data in
transit.
+ if (!checkReplicationOffline(iid, zrw)) {
+ throw new IllegalStateException(
+ "Replication table is not offline. Cannot continue with upgrade that
will remove replication with replication active");
+ }
+
+ cleanMetaConfig(iid, context.getPropStore());
+
+ deleteReplicationTableZkEntries(zrw, iid);
+
+ }
+
+ @Override
+ public void upgradeRoot(final ServerContext context) {
+ log.info("upgrade root - skipping, nothing to do");
+ }
+
+ @Override
+ public void upgradeMetadata(final ServerContext context) {
+ log.info("upgrade metadata entries");
+ List<String> replTableFiles = readReplFilesFromMetadata(context);
+ deleteReplMetadataEntries(context);
+ deleteReplTableFiles(context, replTableFiles);
+ }
+
+ List<String> readReplFilesFromMetadata(final ServerContext context) {
+ List<String> results = new ArrayList<>();
+ try (Scanner scanner = context.createScanner(MetadataTable.NAME,
Authorizations.EMPTY)) {
+
scanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
+ scanner.setRange(REP_TABLE_RANGE);
+ for (Map.Entry<Key,Value> entry : scanner) {
+ String f = entry.getKey()
+
.getColumnQualifier(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME).toString();
+ results.add(f);
+ }
+ } catch (TableNotFoundException ex) {
+ throw new IllegalStateException("failed to read replication files from
metadata", ex);
+ }
+ return results;
+ }
+
+ void deleteReplTableFiles(final ServerContext context, final List<String>
replTableFiles) {
+ // write delete mutations
Review Comment:
you could short-circuit here if `replTableFiles` is empty
##########
server/manager/src/main/java/org/apache/accumulo/manager/upgrade/UpgradeCoordinator.java:
##########
@@ -179,15 +186,22 @@ public synchronized Future<Void>
upgradeMetadata(ServerContext context,
.submit(() -> {
try {
for (int v = currentVersion; v < AccumuloDataVersion.get(); v++)
{
- log.info("Upgrading Root from data version {}", v);
- upgraders.get(v).upgradeRoot(context);
+ log.info("Upgrading Root - current version {} as step towards
target version {}", v,
+ AccumuloDataVersion.get());
+ if (upgraders.get(v) != null) {
+ upgraders.get(v).upgradeRoot(context);
+ }
Review Comment:
I think you should replace lines 191-1932 with
`upgraders.get(v).upgradeRoot(context);`. You added the `requireNonNull` check
in the commit you mentioned below, so it shouldn't be null. If it null here,
then this code will hide it and move on.
--
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]