Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Commit e931b6d

Browse files
gaoran10eolivelli
andauthored
[fix][transaction] Handle errors while writing transaction logs and markers (#1962)
### Modifications Handle correctly NOT_LEADER_OR_FOLLOWER while writing TX markers. Handle BROKER_NOT_AVAILABLE in TransactionMarkerRequestCompletionHandler. Co-authored-by: Enrico Olivelli <[email protected]>
1 parent 1dda879 commit e931b6d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionMarkerRequestCompletionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ private AbortSendingRetryPartitions hasAbortSendOrRetryPartitions(
165165
case UNKNOWN_TOPIC_OR_PARTITION:
166166
// this error was introduced in newer kafka client version,
167167
// recover this condition after bump the kafka client version
168-
//case NOT_LEADER_OR_FOLLOWER:
169168
case NOT_ENOUGH_REPLICAS:
170169
case NOT_ENOUGH_REPLICAS_AFTER_APPEND:
171170
case REQUEST_TIMED_OUT:
@@ -178,6 +177,7 @@ private AbortSendingRetryPartitions hasAbortSendOrRetryPartitions(
178177
abortSendingAndRetryPartitions.retryPartitions.add(topicPartition);
179178
break;
180179
case LEADER_NOT_AVAILABLE:
180+
case BROKER_NOT_AVAILABLE:
181181
case NOT_LEADER_OR_FOLLOWER:
182182
log.info("Sending {}'s transaction marker for partition {} has failed with error {}, "
183183
+ "retrying with current coordinator epoch {} and invalidating cache",

kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/coordinator/transaction/TransactionStateManager.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,13 @@ private Errors statusCheck(String transactionalId,
406406
// note that for timed out request we return NOT_AVAILABLE error code to let client retry
407407
return Errors.COORDINATOR_NOT_AVAILABLE;
408408
case KAFKA_STORAGE_ERROR:
409-
// case Errors.NOT_LEADER_OR_FOLLOWER:
409+
case NOT_LEADER_OR_FOLLOWER:
410410
return Errors.NOT_COORDINATOR;
411411
case MESSAGE_TOO_LARGE:
412412
case RECORD_LIST_TOO_LARGE:
413413
default:
414+
log.error("Unhandled error code {} for transactionalId {}, return UNKNOWN_SERVER_ERROR",
415+
status.error, transactionalId);
414416
return Errors.UNKNOWN_SERVER_ERROR;
415417
}
416418
}
@@ -464,7 +466,8 @@ transactionalId, coordinatorEpoch, newMetadata, partitionFor(transactionalId),
464466
metadata.completeTransitionTo(newMetadata);
465467
return errors;
466468
} catch (IllegalStateException ex) {
467-
log.error("Failed to complete transition.", ex);
469+
log.error("Failed to complete transition for {}. Return UNKNOWN_SERVER_ERROR",
470+
transactionalId, ex);
468471
return Errors.UNKNOWN_SERVER_ERROR;
469472
}
470473
}

0 commit comments

Comments
 (0)