Skip to content

Commit

Permalink
[improve][meta] Log a warning when ZK batch fails with connectionloss (
Browse files Browse the repository at this point in the history
  • Loading branch information
lhotari authored Apr 26, 2024
1 parent d19860c commit 69839c7
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,20 @@ protected void batchOperation(List<MetadataOp> ops) {
Code code = Code.get(rc);
if (code == Code.CONNECTIONLOSS) {
// There is the chance that we caused a connection reset by sending or requesting a batch
// that passed the max ZK limit. Retry with the individual operations
// that passed the max ZK limit.

// Build the log warning message
// summarize the operations by type
String countsByType = ops.stream().collect(
Collectors.groupingBy(MetadataOp::getType, Collectors.summingInt(op -> 1)))
.entrySet().stream().map(e -> e.getValue() + " " + e.getKey().name() + " entries")
.collect(Collectors.joining(", "));
Long totalSize = ops.stream().collect(Collectors.summingLong(MetadataOp::size));
log.warn("Connection loss while executing batch operation of {} "
+ "of total data size of {}. "
+ "Retrying individual operations one-by-one.", countsByType, totalSize);

// Retry with the individual operations
executor.schedule(() -> {
ops.forEach(o -> batchOperation(Collections.singletonList(o)));
}, 100, TimeUnit.MILLISECONDS);
Expand Down

0 comments on commit 69839c7

Please sign in to comment.