keith-turner commented on code in PR #4996:
URL: https://github.com/apache/accumulo/pull/4996#discussion_r1806986063
##########
server/manager/src/main/java/org/apache/accumulo/manager/upgrade/Upgrader11to12.java:
##########
@@ -117,6 +121,20 @@ public void upgradeZookeeper(@NonNull ServerContext
context) {
zrw.overwritePersistentData(rootBase, rtm.toJson().getBytes(UTF_8),
stat.getVersion());
log.info("Root metadata in ZooKeeper after upgrade: {}", rtm.toJson());
}
+
+ String zPath = Constants.ZROOT + "/" + context.getInstanceID() +
Constants.ZNAMESPACES;
+ ZooReaderWriter zoo = context.getZooReaderWriter();
+ Map<String,String> namespaceMap = new HashMap<>();
+ List<String> namespaceIdList = zoo.getChildren(zPath);
+ for (String namespaceId : namespaceIdList) {
+ @SuppressWarnings("deprecation")
+ String namespaceNamePath = zPath + "/" + namespaceId +
Constants.ZNAMESPACE_NAME;
+ namespaceMap.put(namespaceId, new
String(zoo.getData(namespaceNamePath), UTF_8));
+ zoo.delete(namespaceNamePath);
Review Comment:
Upgrade operations should be idempotent, this does not seems like it is
since it deletes stuff from zookeeper before adding. If the process died after
this loop before adding the new data then when this code runs again it would
not find anything in zookeeper. Probably need to move the deletes after the
add.
For testing purposes may be able to use [strict
mock](https://stackoverflow.com/a/3740547) to ensure the zookeeper methods are
called in a certain order.
--
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]