dlmarion commented on code in PR #5749:
URL: https://github.com/apache/accumulo/pull/5749#discussion_r2236194561


##########
server/base/src/main/java/org/apache/accumulo/server/init/ZooKeeperInitializer.java:
##########
@@ -76,16 +77,33 @@ void initializeConfig(final InstanceId instanceId, final 
ZooReaderWriter zoo) {
       String zkInstanceRoot = ZooUtil.getRoot(instanceId);
       zoo.putPersistentData(zkInstanceRoot, EMPTY_BYTE_ARRAY, 
ZooUtil.NodeExistsPolicy.SKIP);
       var sysPropPath = SystemPropKey.of().getPath();
-      VersionedProperties vProps = new VersionedProperties();
       // skip if the encoded props node exists
-      if (zoo.exists(sysPropPath)) {
+      boolean alreadyExists = zoo.exists(zkInstanceRoot + sysPropPath);
+      var created = zoo.putPrivatePersistentData(zkInstanceRoot + sysPropPath,
+          VersionedPropCodec.getDefault().toBytes(new VersionedProperties()),
+          ZooUtil.NodeExistsPolicy.FAIL);
+      if (!alreadyExists && !created) {
+        throw new IllegalStateException(
+            "Failed to create default system props during initialization at: " 
+ sysPropPath);
+      }
+

Review Comment:
   I tried that, but it didn't work because at this location the nodes are 
being created before the chroot'd connection. I tried moving the default 
resource group creation to `ZooKeeperInitializer.initialize()` so that the 
method could be re-used with the chroot'd connection. However, that fails 
because `Initialize.doInit` creates a ServerContext object before calling 
`ZooKeeperInitializer.initialize()` and that fails because the Default resource 
group node is not created yet (chicken/egg situation). The only other thing I 
can think to do to reuse ResourceGroupPropKey here is to pass in the path root 
as a method argument. In all cases but initialization it would be just 
Constants.ZRESOURCEGROUPS. In the initialization code it would be the full path.



-- 
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: notifications-unsubscr...@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to