dlmarion commented on code in PR #5383:
URL: https://github.com/apache/accumulo/pull/5383#discussion_r2014753512
##########
server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java:
##########
@@ -115,6 +128,71 @@ public void zap(SiteConfiguration siteConf, String...
args) {
try (var context = new ServerContext(siteConf)) {
final ZooReaderWriter zrw = context.getZooSession().asReaderWriter();
+
+ if (opts.upgrade) {
+ final String volDir =
VolumeConfiguration.getVolumeUris(siteConf).iterator().next();
+ final Path instanceDir = new Path(volDir, "instance_id");
+ final InstanceId iid =
+ VolumeManager.getInstanceIDFromHdfs(instanceDir, new
Configuration());
+ final String zkRoot = ZooUtil.getRoot(iid);
+ final String upgradePath = zkRoot + Constants.ZPREPARE_FOR_UPGRADE;
+
+ try {
+ if (zrw.exists(upgradePath)) {
+ if (!opts.forceUpgradePrep) {
+ throw new IllegalStateException(
+ "'ZooZap -prepare-for-upgrade' must have already been run."
+ + " To run again use the 'ZooZap -prepare-for-upgrade
-force'");
+ } else {
+ zrw.delete(upgradePath);
+ }
+ }
+ } catch (KeeperException | InterruptedException e) {
+ throw new IllegalStateException("Error creating or checking for "
+ upgradePath
+ + " node in zookeeper: " + e.getMessage(), e);
+ }
+
+ log.info("Upgrade specified, validating that Manager is stopped");
+ if (context.getServerPaths().getManager(true) != null) {
+ throw new IllegalStateException(
+ "Manager is running, shut it down and retry this operation");
+ }
+
+ log.info("Checking for existing fate transactions");
+ try {
+ // Adapted from UpgradeCoordinator.abortIfFateTransactions
+ if (!zrw.getChildren(context.getZooKeeperRoot() +
Constants.ZFATE).isEmpty()) {
+ throw new IllegalStateException("Cannot complete upgrade
preparation"
+ + " because FATE transactions exist. You can start a
tserver, but"
+ + " not the Manager, then use the shell to delete completed"
+ + " transactions and fail pending or in-progress
transactions."
+ + " Once all of the FATE transactions have been removed you
can"
+ + " retry this operation.");
+ }
+ } catch (KeeperException | InterruptedException e) {
+ throw new IllegalStateException("Error checking for existing FATE
transactions", e);
+ }
Review Comment:
I can make a ticket to modify this check in a post-4.0 release.
--
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]