chia7712 commented on code in PR #21577:
URL: https://github.com/apache/kafka/pull/21577#discussion_r2877077548
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/TransactionIndex.java:
##########
@@ -240,17 +240,18 @@ public boolean hasNext() {
@Override
public AbortedTxnWithPosition next() {
try {
- ByteBuffer buffer = allocate.get();
+ buffer.clear();
Utils.readFully(channel, buffer, position.value);
buffer.flip();
- AbortedTxn abortedTxn = new AbortedTxn(buffer);
- if (abortedTxn.version() > AbortedTxn.CURRENT_VERSION)
- throw new KafkaException("Unexpected aborted
transaction version " + abortedTxn.version()
+ short version = buffer.getShort();
+ if (version > AbortedTxn.HIGHEST_SUPPORTED_VERSION)
Review Comment:
Should we check `LOWEST_SUPPORTED_VERSION` as well?
##########
storage/src/main/java/org/apache/kafka/storage/internals/log/TransactionIndex.java:
##########
@@ -216,22 +219,19 @@ private FileChannel channelOrNull() {
}
private Iterable<AbortedTxnWithPosition> iterable() {
- return iterable(() -> ByteBuffer.allocate(AbortedTxn.TOTAL_SIZE));
- }
-
- private Iterable<AbortedTxnWithPosition> iterable(Supplier<ByteBuffer>
allocate) {
FileChannel channel = channelOrNull();
if (channel == null)
return List.of();
+ ByteBuffer buffer = ByteBuffer.allocate(ABORTED_TXN_RECORD_SIZE);
Review Comment:
What happens if we add new filed in the future
--
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]