This is an automated email from the ASF dual-hosted git repository.
KKcorps pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 6bff2295ebc Add logs to ZK multi write failures (#18581)
6bff2295ebc is described below
commit 6bff2295ebcb3530ea54fcf56e828e5bcdc5bf7e
Author: Krishan Goyal <[email protected]>
AuthorDate: Thu May 28 17:40:04 2026 +0530
Add logs to ZK multi write failures (#18581)
---
.../common/utils/helix/ZkMultiWriteBuilder.java | 47 +++++++++++++++++++++-
.../utils/helix/ZkMultiWriteBuilderTest.java | 3 +-
2 files changed, 48 insertions(+), 2 deletions(-)
diff --git
a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/ZkMultiWriteBuilder.java
b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/ZkMultiWriteBuilder.java
index 1053ed41484..6ba682284c7 100644
---
a/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/ZkMultiWriteBuilder.java
+++
b/pinot-common/src/main/java/org/apache/pinot/common/utils/helix/ZkMultiWriteBuilder.java
@@ -27,7 +27,10 @@ import
org.apache.helix.zookeeper.zkclient.exception.ZkException;
import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.Op;
+import org.apache.zookeeper.OpResult;
import org.apache.zookeeper.ZooDefs;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -57,6 +60,8 @@ import org.apache.zookeeper.ZooDefs;
*/
public final class ZkMultiWriteBuilder {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ZkMultiWriteBuilder.class);
+
/** Pass as {@code expectedVersion} to skip the version check on a {@link
#set}/{@link #delete}. */
public static final int ANY_VERSION = -1;
@@ -152,12 +157,52 @@ public final class ZkMultiWriteBuilder {
} catch (ZkException ze) {
Throwable cause = ze.getCause();
if (cause instanceof KeeperException) {
- throw (KeeperException) cause;
+ KeeperException ke = (KeeperException) cause;
+ logFailedOps(ke);
+ throw ke;
}
throw ze;
}
}
+ private void logFailedOps(KeeperException e) {
+ List<OpResult> results = e.getResults();
+ if (results == null) {
+ LOGGER.warn("ZK multi-op error has no per-op results attached: {}",
e.toString());
+ return;
+ }
+ int common = Math.min(results.size(), _ops.size());
+ for (int i = 0; i < common; i++) {
+ Op op = _ops.get(i);
+ OpResult r = results.get(i);
+ String label = opTypeLabel(op.getType()) + " " + op.getPath();
+ if (r instanceof OpResult.ErrorResult) {
+ int err = ((OpResult.ErrorResult) r).getErr();
+ LOGGER.warn("multi-op[{}] FAILED code={} ({}) — {}", i, err,
KeeperException.Code.get(err), label);
+ } else {
+ LOGGER.info("multi-op[{}] {} — {}", i, r.getClass().getSimpleName(),
label);
+ }
+ }
+ if (results.size() != _ops.size()) {
+ LOGGER.warn("multi-op result count {} != submitted ops {}",
results.size(), _ops.size());
+ }
+ }
+
+ private static String opTypeLabel(int type) {
+ switch (type) {
+ case ZooDefs.OpCode.create:
+ return "create";
+ case ZooDefs.OpCode.setData:
+ return "set";
+ case ZooDefs.OpCode.delete:
+ return "delete";
+ case ZooDefs.OpCode.check:
+ return "check";
+ default:
+ return "op(" + type + ")";
+ }
+ }
+
private void checkNotExecuted() {
Preconditions.checkState(!_executed, "ZkMultiWriteBuilder already
executed");
}
diff --git
a/pinot-common/src/test/java/org/apache/pinot/common/utils/helix/ZkMultiWriteBuilderTest.java
b/pinot-common/src/test/java/org/apache/pinot/common/utils/helix/ZkMultiWriteBuilderTest.java
index b09e316a44e..0b5fb799f02 100644
---
a/pinot-common/src/test/java/org/apache/pinot/common/utils/helix/ZkMultiWriteBuilderTest.java
+++
b/pinot-common/src/test/java/org/apache/pinot/common/utils/helix/ZkMultiWriteBuilderTest.java
@@ -150,7 +150,7 @@ public class ZkMultiWriteBuilderTest {
_client.writeData(pB, record("b", "v", "bumped"));
Assert.assertEquals(version(pB), 1);
- Assert.expectThrows(KeeperException.BadVersionException.class, () ->
+ KeeperException.BadVersionException ex =
Assert.expectThrows(KeeperException.BadVersionException.class, () ->
builder()
.set(pA, record("a", "v", "2"), 0)
.set(pB, record("b", "v", "2"), 0) // stale version -> BADVERSION
@@ -160,6 +160,7 @@ public class ZkMultiWriteBuilderTest {
Assert.assertEquals(read(pA).getSimpleField("v"), "1");
Assert.assertEquals(version(pA), 0);
Assert.assertEquals(read(pB).getSimpleField("v"), "bumped");
+ Assert.assertTrue(ex.getResults() != null && !ex.getResults().isEmpty());
}
@Test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]