Skip to content

Commit 1f23bb1

Browse files
MINOR: Include exception objects when logging group coordinator errors (#20806)
...so that we capture stack traces for these errors. Reviewers: Chia-Ping Tsai <[email protected]>
1 parent bd8ea36 commit 1f23bb1

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorExecutorImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public <R> boolean schedule(
107107
"the coordinator is not active.", key, exception.getMessage());
108108
} else {
109109
log.error("The write event for the task {} failed due to {}. Ignoring it. ",
110-
key, exception.getMessage());
110+
key, exception.getMessage(), exception);
111111
}
112112

113113
return null;

coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ public void run() {
399399
schedule(key, retryBackoff, TimeUnit.MILLISECONDS, true, retryBackoff, operation);
400400
} else {
401401
log.error("The write event {} for the timer {} failed due to {}. Ignoring it. ",
402-
event.name, key, ex.getMessage());
402+
event.name, key, ex.getMessage(), ex);
403403
}
404404

405405
return null;
@@ -717,7 +717,7 @@ private void load() {
717717
}
718718
} catch (Throwable ex) {
719719
log.error("Failed to load metadata from {} with epoch {} due to {}.",
720-
tp, epoch, ex.toString());
720+
tp, epoch, ex.getMessage(), ex);
721721
context.transitionTo(CoordinatorState.FAILED);
722722
}
723723
} else {
@@ -820,7 +820,7 @@ private void flushCurrentBatch() {
820820
// Free up the current batch.
821821
freeCurrentBatch();
822822
} catch (Throwable t) {
823-
log.error("Writing records to {} failed due to: {}.", tp, t.getMessage());
823+
log.error("Writing records to {} failed due to: {}.", tp, t.getMessage(), t);
824824
failCurrentBatch(t);
825825
// We rethrow the exception for the caller to handle it too.
826826
throw t;
@@ -1057,7 +1057,7 @@ private void append(
10571057
currentBatch.builder.append(recordToAppend);
10581058
currentBatch.nextOffset++;
10591059
} catch (Throwable t) {
1060-
log.error("Replaying record {} to {} failed due to: {}.", recordToReplay, tp, t.getMessage());
1060+
log.error("Replaying record {} to {} failed due to: {}.", recordToReplay, tp, t.getMessage(), t);
10611061

10621062
// Add the event to the list of pending events associated with the last
10631063
// batch in order to fail it too.
@@ -2446,7 +2446,7 @@ public void scheduleUnloadOperation(
24462446
// It's very unlikely that we will ever see an exception here, since we
24472447
// already make an effort to catch exceptions in the unload method.
24482448
log.error("Failed to unload metadata for {} with epoch {} due to {}.",
2449-
tp, partitionEpoch, ex.toString());
2449+
tp, partitionEpoch, ex.getMessage(), ex);
24502450
} finally {
24512451
// Always remove the coordinator context, otherwise the coordinator
24522452
// shard could be permanently stuck.

group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,7 @@ private CompletableFuture<DescribeShareGroupOffsetsResponseData.DescribeShareGro
18251825
persister.readSummary(ReadShareGroupStateSummaryParameters.from(readSummaryRequestData))
18261826
.whenComplete((result, error) -> {
18271827
if (error != null) {
1828-
log.error("Failed to read summary of the share partition");
1828+
log.error("Failed to read summary of the share partition", error);
18291829
future.completeExceptionally(error);
18301830
return;
18311831
}

group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,7 +3457,7 @@ private CoordinatorResult<Void, CoordinatorRecord> handleRegularExpressionsResul
34573457
) {
34583458
if (exception != null) {
34593459
log.error("[GroupId {}] Couldn't update regular expression due to: {}",
3460-
groupId, exception.getMessage());
3460+
groupId, exception.getMessage(), exception);
34613461
return new CoordinatorResult<>(List.of());
34623462
}
34633463

@@ -3933,7 +3933,7 @@ private Assignment updateTargetAssignment(
39333933
} catch (PartitionAssignorException ex) {
39343934
String msg = String.format("Failed to compute a new target assignment for epoch %d: %s",
39353935
groupEpoch, ex.getMessage());
3936-
log.error("[GroupId {}] {}.", group.groupId(), msg);
3936+
log.error("[GroupId {}] {}.", group.groupId(), msg, ex);
39373937
throw new UnknownServerException(msg, ex);
39383938
}
39393939
}
@@ -3994,7 +3994,7 @@ private Assignment updateTargetAssignment(
39943994
} catch (PartitionAssignorException ex) {
39953995
String msg = String.format("Failed to compute a new target assignment for epoch %d: %s",
39963996
groupEpoch, ex.getMessage());
3997-
log.error("[GroupId {}] {}.", group.groupId(), msg);
3997+
log.error("[GroupId {}] {}.", group.groupId(), msg, ex);
39983998
throw new UnknownServerException(msg, ex);
39993999
}
40004000
}
@@ -4053,7 +4053,7 @@ private TasksTuple updateStreamsTargetAssignment(
40534053
} catch (TaskAssignorException ex) {
40544054
String msg = String.format("Failed to compute a new target assignment for epoch %d: %s",
40554055
groupEpoch, ex.getMessage());
4056-
log.error("[GroupId {}] {}.", group.groupId(), msg);
4056+
log.error("[GroupId {}] {}.", group.groupId(), msg, ex);
40574057
throw new UnknownServerException(msg, ex);
40584058
}
40594059
}

0 commit comments

Comments
 (0)