Skip to content

Commit

Permalink
check opResults returned for multi call for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantPSpencer committed Jan 21, 2025
1 parent d700f77 commit 98926d0
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1842,16 +1842,30 @@ public void deleteRecursivelyAtomic(String path) {
*/
public void deleteRecursivelyAtomic(List<String> paths) {
List<Op> ops = new ArrayList<>();
List<OpResult> opResults;
for (String path : paths) {
ops.addAll(getOpsForRecursiveDelete(path));
}
try {
multi(ops);
}
catch (Exception e) {
opResults = multi(ops);
} catch (Exception e) {
LOG.error("zkclient {}, Failed to delete paths {}, exception {}", _uid, paths, e);
throw new ZkClientException("Failed to delete paths " + paths, e);
}

List<KeeperException.Code> opResultErrorCodes = new ArrayList<>();
for (OpResult result : opResults) {
if (result instanceof OpResult.ErrorResult) {
opResultErrorCodes.add(KeeperException.Code.get(((OpResult.ErrorResult) result).getErr()));
}
}

if (!opResultErrorCodes.isEmpty()) {
LOG.error("zkclient {}, Failed to delete paths {}, multi returned with error codes {}",
_uid, paths, opResultErrorCodes);
throw new ZkClientException("Failed to delete paths " + paths + " with ZK KeeperException error codes: "
+ opResultErrorCodes);
}
}

/**
Expand Down

0 comments on commit 98926d0

Please sign in to comment.