ddanielr commented on code in PR #5383:
URL: https://github.com/apache/accumulo/pull/5383#discussion_r1989715036
##########
server/base/src/main/java/org/apache/accumulo/server/util/ZooZap.java:
##########
@@ -115,13 +123,77 @@ public void zap(SiteConfiguration siteConf, String...
args) {
SecurityUtil.serverLogin(siteConf);
}
- String volDir =
VolumeConfiguration.getVolumeUris(siteConf).iterator().next();
- Path instanceDir = new Path(volDir, "instance_id");
- InstanceId iid = VolumeManager.getInstanceIDFromHdfs(instanceDir, new
Configuration());
- var zrw = zk.asReaderWriter();
+ 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 var zrw = zk.asReaderWriter();
+ final String upgradePath = zkRoot + Constants.ZPREPARE_FOR_UPGRADE;
+
+ if (opts.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");
+ AdminUtil<Admin> admin = new AdminUtil<>(false);
+ if (!admin.checkGlobalLock(zk, ServiceLock.path(zkRoot +
Constants.ZMANAGER_LOCK))) {
+ throw new IllegalStateException(
+ "Manager is running, shut it down and retry this operation");
+ }
+
+ log.info("Checking for existing fate transactions");
+ try {
+ final String fatePath = zkRoot + Constants.ZFATE;
+ // Adapted from UpgradeCoordinator.abortIfFateTransactions
+ final ReadOnlyTStore<ZooZap> fate = new ZooStore<>(fatePath, zk);
+ if (!fate.list().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);
+ }
+
+ log.info("Creating {} node in zookeeper, servers will be prevented
from"
+ + " starting while this node exists", upgradePath);
+ try {
+ zrw.putPersistentData(upgradePath, new byte[0],
NodeExistsPolicy.SKIP);
+ } catch (KeeperException | InterruptedException e) {
+ throw new IllegalStateException("Error creating " + upgradePath
+ + " node in zookeeper. Check for any issues and retry.", e);
+ }
+ log.info("Instance {} prepared for upgrade. Server processes will not
start while"
+ + " in this state. To undo this state and abort upgrade
preparations delete"
+ + " the zookeeper node: {}", iid.canonical(), upgradePath);
+
+ log.info("Forcing removal of all server locks");
+ // modify the options to remove all locks
+ opts.zapCompactors = true;
+ opts.zapCoordinators = true;
+ opts.zapManager = true;
+ opts.zapScanServers = true;
+ opts.zapTservers = true;
Review Comment:
Yeah I agree that zooZap hasn't done it before. Handling that in a different
PR is fine.
--
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]