This is an automated email from the ASF dual-hosted git repository.
dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 1f15679530 Reverted 5641,5645. Fix root cause of upgrade error (#5654)
1f15679530 is described below
commit 1f1567953067779cd3157d9786865f779eaf5823
Author: Dave Marion <[email protected]>
AuthorDate: Tue Jun 17 16:23:53 2025 -0400
Reverted 5641,5645. Fix root cause of upgrade error (#5654)
This change reverts commits 242438ae64376e67bb9f38d1b6a90e232dd6cc62 from
#5641
and 963150dcfda7cd678b9fde9514d0a498d692fd9f from #5645 and fixes the root
cause of the issues, which was that the scanref and fate tables were not
being created during the upgrade.
---
.../accumulo/core/util/tables/TableMapping.java | 8 ++--
.../java/org/apache/accumulo/manager/Manager.java | 15 -------
.../accumulo/manager/upgrade/Upgrader11to12.java | 50 +++++++++++++++++++---
.../accumulo/manager/upgrade/Upgrader12to13.java | 29 +++++++------
.../manager/upgrade/Upgrader11to12Test.java | 17 +++++++-
5 files changed, 77 insertions(+), 42 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/util/tables/TableMapping.java
b/core/src/main/java/org/apache/accumulo/core/util/tables/TableMapping.java
index c38a269bf7..4d8d6a22e8 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/tables/TableMapping.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/tables/TableMapping.java
@@ -144,11 +144,9 @@ public class TableMapping {
}
Map<String,String> idToName = deserializeMap(data);
if (namespaceId.equals(Namespace.ACCUMULO.id())) {
- if (!(idToName.containsKey(SystemTables.ROOT.tableId().canonical())
- &&
idToName.containsKey(SystemTables.METADATA.tableId().canonical()))) {
- throw new IllegalStateException("Accumulo namespace expected to at
least contain tables "
- + SystemTables.ROOT.tableId().canonical() + " and "
- + SystemTables.METADATA.tableId().canonical() + ", but saw " +
idToName);
+ if (!idToName.equals(SystemTables.tableIdToSimpleNameMap())) {
+ throw new IllegalStateException("Accumulo namespace expected to
contain tables "
+ + SystemTables.tableIdToSimpleNameMap() + ", but saw " +
idToName);
}
}
var converted = ImmutableSortedMap.<TableId,String>naturalOrder();
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
index f16d83e0a9..bdf6507ed0 100644
--- a/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
+++ b/server/manager/src/main/java/org/apache/accumulo/manager/Manager.java
@@ -60,7 +60,6 @@ import java.util.stream.Collectors;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.ConfigOpts;
-import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.admin.CompactionConfig;
import org.apache.accumulo.core.client.admin.servers.ServerId;
import org.apache.accumulo.core.client.admin.servers.ServerId.Type;
@@ -1334,20 +1333,6 @@ public class Manager extends AbstractServer implements
LiveTServerSet.Listener {
lock -> ServiceLock.isLockHeld(context.getZooCache(), lock);
var metaInstance = initializeFateInstance(context,
new MetaFateStore<>(context.getZooSession(),
managerLock.getLockID(), isLockHeld));
-
- // If an upgrade occurred, then it's possible that the client may not yet
- // be aware of the table. Wait for the table to be known to prevent an
- // error when creating the UserFateStore.
- while (true) {
- try {
- context.getTableId(SystemTables.FATE.tableName());
- break;
- } catch (TableNotFoundException e) {
- log.trace("Waiting for client to become aware of user fate table");
- Thread.sleep(100);
- }
- }
-
var userInstance = initializeFateInstance(context, new
UserFateStore<>(context,
SystemTables.FATE.tableName(), managerLock.getLockID(), isLockHeld));
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java
b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java
index 26c1bd9c45..557759f534 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java
@@ -44,13 +44,18 @@ import org.apache.accumulo.core.client.IsolatedScanner;
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.clientImpl.Namespace;
import org.apache.accumulo.core.clientImpl.NamespaceMapping;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
+import org.apache.accumulo.core.data.NamespaceId;
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.fate.zookeeper.ZooUtil.NodeExistsPolicy;
+import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.core.metadata.StoredTabletFile;
import org.apache.accumulo.core.metadata.SystemTables;
import org.apache.accumulo.core.metadata.schema.Ample;
@@ -63,11 +68,13 @@ import
org.apache.accumulo.core.metadata.schema.TabletMergeabilityMetadata;
import org.apache.accumulo.core.schema.Section;
import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.core.util.Encoding;
+import org.apache.accumulo.core.util.Pair;
import org.apache.accumulo.core.util.TextUtil;
+import org.apache.accumulo.core.util.tables.TableNameUtil;
import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.conf.store.TablePropKey;
import org.apache.accumulo.server.init.FileSystemInitializer;
import org.apache.accumulo.server.init.InitialConfiguration;
-import org.apache.accumulo.server.init.ZooKeeperInitializer;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.zookeeper.KeeperException;
@@ -153,6 +160,10 @@ public class Upgrader11to12 implements Upgrader {
log.info("Removing problems reports from zookeeper");
removeZKProblemReports(context);
+ log.info("Creating ZooKeeper entries for ScanServerRefTable");
+ preparePre4_0NewTableState(context, SystemTables.SCAN_REF.tableId(),
Namespace.ACCUMULO.id(),
+ SystemTables.SCAN_REF.tableName(), TableState.ONLINE,
ZooUtil.NodeExistsPolicy.FAIL);
+
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new IllegalStateException(
@@ -163,6 +174,36 @@ public class Upgrader11to12 implements Upgrader {
}
}
+ private static final String ZTABLE_NAME = "/name";
+ private static final String ZTABLE_COMPACT_ID = "/compact-id";
+ private static final String ZTABLE_COMPACT_CANCEL_ID = "/compact-cancel-id";
+ private static final String ZTABLE_STATE = "/state";
+ private static final byte[] ZERO_BYTE = {'0'};
+
+ public static void preparePre4_0NewTableState(ServerContext context, TableId
tableId,
+ NamespaceId namespaceId, String tableName, TableState state,
NodeExistsPolicy existsPolicy)
+ throws KeeperException, InterruptedException {
+ // state gets created last
+ log.debug("Creating ZooKeeper entries for new table {} (ID: {}) in
namespace (ID: {})",
+ tableName, tableId, namespaceId);
+ Pair<String,String> qualifiedTableName = TableNameUtil.qualify(tableName);
+ tableName = qualifiedTableName.getSecond();
+ String zTablePath = Constants.ZTABLES + "/" + tableId;
+ final ZooReaderWriter zoo = context.getZooSession().asReaderWriter();
+ zoo.putPersistentData(zTablePath, new byte[0], existsPolicy);
+ zoo.putPersistentData(zTablePath + Constants.ZTABLE_NAMESPACE,
+ namespaceId.canonical().getBytes(UTF_8), existsPolicy);
+ zoo.putPersistentData(zTablePath + ZTABLE_NAME, tableName.getBytes(UTF_8),
existsPolicy);
+ zoo.putPersistentData(zTablePath + Constants.ZTABLE_FLUSH_ID, ZERO_BYTE,
existsPolicy);
+ zoo.putPersistentData(zTablePath + ZTABLE_COMPACT_ID, ZERO_BYTE,
existsPolicy);
+ zoo.putPersistentData(zTablePath + ZTABLE_COMPACT_CANCEL_ID, ZERO_BYTE,
existsPolicy);
+ zoo.putPersistentData(zTablePath + ZTABLE_STATE,
state.name().getBytes(UTF_8), existsPolicy);
+ var propKey = TablePropKey.of(tableId);
+ if (!context.getPropStore().exists(propKey)) {
+ context.getPropStore().create(propKey, Map.of());
+ }
+ }
+
interface MutationWriter {
void addMutation(Mutation m) throws MutationsRejectedException;
}
@@ -180,7 +221,7 @@ public class Upgrader11to12 implements Upgrader {
var metaName = Ample.DataLevel.USER.metaTable();
upgradeTabletsMetadata(context, metaName);
removeScanServerRange(context, metaName);
- createScanServerRefTable(context);
+ createScanServerRefTableMetadataEntries(context);
log.info("Removing problems reports from metadata table");
removeMetadataProblemReports(context);
}
@@ -280,10 +321,7 @@ public class Upgrader11to12 implements Upgrader {
log.info("Scan Server Ranges {} removed from table {}",
OLD_SCAN_SERVERS_RANGES, tableName);
}
- public void createScanServerRefTable(ServerContext context) {
- ZooKeeperInitializer zkInit = new ZooKeeperInitializer();
- zkInit.initScanRefTableState(context);
-
+ public void createScanServerRefTableMetadataEntries(ServerContext context) {
try {
FileSystemInitializer initializer = new FileSystemInitializer(
new InitialConfiguration(context.getHadoopConf(),
context.getSiteConfiguration()));
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader12to13.java
b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader12to13.java
index c07253ee30..0d6b42ad90 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader12to13.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader12to13.java
@@ -34,6 +34,7 @@ import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.admin.TabletAvailability;
+import org.apache.accumulo.core.clientImpl.Namespace;
import org.apache.accumulo.core.clientImpl.NamespaceMapping;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
@@ -43,6 +44,7 @@ import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.fate.zookeeper.ZooReader;
import org.apache.accumulo.core.fate.zookeeper.ZooUtil;
import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.core.manager.state.tables.TableState;
import org.apache.accumulo.core.metadata.SystemTables;
import org.apache.accumulo.core.metadata.schema.Ample.DataLevel;
import org.apache.accumulo.core.metadata.schema.Ample.TabletsMutator;
@@ -59,7 +61,6 @@ import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.conf.store.TablePropKey;
import org.apache.accumulo.server.init.FileSystemInitializer;
import org.apache.accumulo.server.init.InitialConfiguration;
-import org.apache.accumulo.server.init.ZooKeeperInitializer;
import org.apache.accumulo.server.util.PropUtil;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.data.Stat;
@@ -89,6 +90,8 @@ public class Upgrader12to13 implements Upgrader {
removeCompactColumnsFromRootTabletMetadata(context);
LOG.info("Adding compactions node to zookeeper");
addCompactionsNode(context);
+ LOG.info("Creating ZooKeeper entries for accumulo.fate table");
+ initializeFateTable(context);
LOG.info("Adding table mappings to zookeeper");
addTableMappingsToZooKeeper(context);
}
@@ -141,19 +144,6 @@ public class Upgrader12to13 implements Upgrader {
return;
}
- try {
- ZooKeeperInitializer zkInit = new ZooKeeperInitializer();
- zkInit.initFateTableState(context);
- } catch (RuntimeException e) {
- // initFateTableState wraps KeeperException and InterruptedException
- // with a RuntimeException
- if (e.getCause() instanceof KeeperException.NodeExistsException) {
- LOG.debug("Fate table node already exists in ZooKeeper");
- } else {
- throw e;
- }
- }
-
try {
FileSystemInitializer initializer = new FileSystemInitializer(
new InitialConfiguration(context.getHadoopConf(),
context.getSiteConfiguration()));
@@ -406,6 +396,17 @@ public class Upgrader12to13 implements Upgrader {
}
}
+ private void initializeFateTable(ServerContext context) {
+ try {
+ Upgrader11to12.preparePre4_0NewTableState(context,
SystemTables.FATE.tableId(),
+ Namespace.ACCUMULO.id(), SystemTables.FATE.tableName(),
TableState.ONLINE,
+ ZooUtil.NodeExistsPolicy.FAIL);
+ } catch (InterruptedException | KeeperException ex) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException("Error creating fate table", ex);
+ }
+ }
+
void addTableMappingsToZooKeeper(ServerContext context) {
var zrw = context.getZooSession().asReaderWriter();
try {
diff --git
a/server/manager/src/test/java/org/apache/accumulo/manager/upgrade/Upgrader11to12Test.java
b/server/manager/src/test/java/org/apache/accumulo/manager/upgrade/Upgrader11to12Test.java
index 8a3e4505cf..6a4be51fe3 100644
---
a/server/manager/src/test/java/org/apache/accumulo/manager/upgrade/Upgrader11to12Test.java
+++
b/server/manager/src/test/java/org/apache/accumulo/manager/upgrade/Upgrader11to12Test.java
@@ -28,6 +28,7 @@ import static org.easymock.EasyMock.createStrictMock;
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.mock;
import static org.easymock.EasyMock.newCapture;
import static org.easymock.EasyMock.replay;
@@ -56,6 +57,7 @@ import org.apache.accumulo.core.data.Mutation;
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.fate.zookeeper.ZooUtil.NodeExistsPolicy;
import org.apache.accumulo.core.metadata.StoredTabletFile;
import
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.ChoppedColumnFamily;
import
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
@@ -64,6 +66,8 @@ import
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.La
import org.apache.accumulo.core.metadata.schema.RootTabletMetadata;
import org.apache.accumulo.core.zookeeper.ZooSession;
import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.conf.store.TablePropKey;
+import org.apache.accumulo.server.conf.store.impl.ZooPropStore;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.zookeeper.data.Stat;
@@ -338,6 +342,7 @@ public class Upgrader11to12Test {
assertEquals(1,
u1.getUpdates().stream().filter(ColumnUpdate::isDeleted).count());
}
+ @SuppressWarnings("unchecked")
@Test
public void upgradeZooKeeperTest() throws Exception {
@@ -354,6 +359,7 @@ public class Upgrader11to12Test {
ServerContext context = createMock(ServerContext.class);
ZooSession zk = createStrictMock(ZooSession.class);
ZooReaderWriter zrw = createStrictMock(ZooReaderWriter.class);
+ ZooPropStore store = createMock(ZooPropStore.class);
expect(context.getInstanceID()).andReturn(iid).anyTimes();
expect(context.getZooSession()).andReturn(zk).anyTimes();
@@ -395,13 +401,20 @@ public class Upgrader11to12Test {
expect(zrw.exists("/problems")).andReturn(false).once();
- replay(context, zk, zrw);
+ expect(zrw.putPersistentData(isA(String.class), isA(byte[].class),
isA(NodeExistsPolicy.class)))
+ .andReturn(true).times(7);
+ expect(context.getPropStore()).andReturn(store).atLeastOnce();
+
expect(store.exists(isA(TablePropKey.class))).andReturn(false).atLeastOnce();
+ store.create(isA(TablePropKey.class), isA(Map.class));
+ expectLastCall().once();
+
+ replay(context, zk, zrw, store);
upgrader.upgradeZookeeper(context);
assertEquals(zKRootV2, new String(byteCapture.getValue(), UTF_8));
- verify(context, zk, zrw);
+ verify(context, zk, zrw, store);
}
@Test