KAFKA-6559: Iterate record sets before calling Log.append
If a Produce request contains multiple record sets for a single topic-partition, it is better to iterate these before calling Log.append. This is because append will process all the sets together, and therefore will need to reassign offsets even if the offsets for an individual record set are properly formed. By iterating the record sets before calling append, each set can be considered on its own and potentially be appended without reassigning offsets.
3 tests added to cover this:
- Append a single MemoryRecords that contains multiple batches
- Append a single MemoryRecords that contains no batches
- Append a single MemoryRecords that has an empty batch in the middle of valid batches
Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
Produce requests with multiple batches are currently rejected by the broker. See ProduceRequest.validateRecords. This behavior was intentionally introduced in KIP-98 so that partial writes to a partition are no longer possible. This makes produce errors unambiguous which is important for the idempotent producer.
This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please leave a comment asking for a review. If the PR has merge conflicts, update it with the latest from the base branch.
If you are having difficulty finding a reviewer, please reach out on the [mailing list](https://kafka.apache.org/contact).
If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed.
This PR has been closed since it has not had any activity in 120 days. If you feel like this was a mistake, or you would like to continue working on it, please feel free to re-open the PR and ask for a review.