jsancio commented on a change in pull request #11116:
URL: https://github.com/apache/kafka/pull/11116#discussion_r680252689
##########
File path: metadata/src/test/java/org/apache/kafka/metalog/LocalLogManager.java
##########
@@ -631,7 +658,34 @@ public void
unregister(RaftClient.Listener<ApiMessageAndVersion> listener) {
@Override
public Long scheduleAppend(int epoch, List<ApiMessageAndVersion> batch) {
- return scheduleAtomicAppend(epoch, batch);
+ if (batch.isEmpty()) {
+ throw new IllegalArgumentException("Batch cannot be empty");
+ }
+
+ List<ApiMessageAndVersion> first = batch.subList(0, batch.size() / 2);
+ List<ApiMessageAndVersion> second = batch.subList(batch.size() / 2,
batch.size());
+
+ assertEquals(batch.size(), first.size() + second.size());
+ assertFalse(second.isEmpty());
+
+ OptionalLong firstOffset = first
+ .stream()
+ .mapToLong(record -> scheduleAtomicAppend(epoch,
Collections.singletonList(record)))
+ .max();
+
+ if (firstOffset.isPresent() &&
resignAfterNonAtomicCommit.getAndSet(false)) {
+ // Emulate losing leadering in them middle of a non-atomic append
by not writing
Review comment:
Fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]