chia7712 commented on code in PR #20456:
URL: https://github.com/apache/kafka/pull/20456#discussion_r2649653963


##########
core/src/main/scala/kafka/coordinator/transaction/TransactionStateManager.scala:
##########
@@ -495,19 +495,21 @@ class TransactionStateManager(brokerId: Int,
             memRecords.batches.forEach { batch =>
               for (record <- batch.asScala) {
                 require(record.hasKey, "Transaction state log's key should not 
be null")
-                try {
-                  val transactionalId = 
TransactionLog.readTxnRecordKey(record.key).asInstanceOf[String]
+                val transactionalId = try 
Some(TransactionLog.readTxnRecordKey(record.key))
+                catch {
+                  case e: IllegalStateException =>
+                    warn(s"Unknown message key version while loading 
transaction state from $topicPartition. " +
+                      s"Ignoring it. It could be a left over from an aborted 
upgrade. Error: ${e.getMessage}")

Review Comment:
   ```scala
                       warn(s"Unknown message key version while loading 
transaction state from $topicPartition. " +
                         s"Ignoring it. It could be a left over from an aborted 
upgrade", e)
   ```



-- 
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]

Reply via email to