-
Notifications
You must be signed in to change notification settings - Fork 15.4k
KAFKA-16192: Introduce transaction.version and usage of flexible records to coordinators #16183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
98c8d15
6b3ace4
1550222
541b49e
249917d
c12ca5f
32b1bbd
d2ae555
7b3fc9c
bde2d4e
fada954
dc34d93
432fe47
87ca44d
0598cb8
22af8c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ import java.nio.ByteBuffer | |
| import java.util.Properties | ||
| import java.util.concurrent.atomic.AtomicBoolean | ||
| import java.util.concurrent.locks.ReentrantReadWriteLock | ||
| import kafka.server.{ReplicaManager, RequestLocal} | ||
| import kafka.server.{MetadataCache, ReplicaManager, RequestLocal} | ||
| import kafka.utils.CoreUtils.{inReadLock, inWriteLock} | ||
| import kafka.utils.{Logging, Pool} | ||
| import kafka.utils.Implicits._ | ||
|
|
@@ -36,6 +36,7 @@ import org.apache.kafka.common.requests.TransactionResult | |
| import org.apache.kafka.common.utils.{Time, Utils} | ||
| import org.apache.kafka.common.{KafkaException, TopicPartition} | ||
| import org.apache.kafka.coordinator.transaction.{TransactionLogConfigs, TransactionStateManagerConfigs} | ||
| import org.apache.kafka.server.common.TransactionVersion | ||
| import org.apache.kafka.server.config.ServerConfigs | ||
| import org.apache.kafka.server.record.BrokerCompressionType | ||
| import org.apache.kafka.server.util.Scheduler | ||
|
|
@@ -65,6 +66,7 @@ import scala.collection.mutable | |
| class TransactionStateManager(brokerId: Int, | ||
| scheduler: Scheduler, | ||
| replicaManager: ReplicaManager, | ||
| metadataCache: MetadataCache, | ||
| config: TransactionConfig, | ||
| time: Time, | ||
| metrics: Metrics) extends Logging { | ||
|
|
@@ -99,6 +101,10 @@ class TransactionStateManager(brokerId: Int, | |
| TransactionStateManagerConfigs.METRICS_GROUP, | ||
| "The avg time it took to load the partitions in the last 30sec"), new Avg()) | ||
|
|
||
| private[transaction] def usesFlexibleRecords(): Boolean = { | ||
| metadataCache.features().finalizedFeatures().getOrDefault(TransactionVersion.FEATURE_NAME, 0.toShort) > 0 | ||
| } | ||
|
|
||
| // visible for testing only | ||
| private[transaction] def addLoadingPartition(partitionId: Int, coordinatorEpoch: Int): Unit = { | ||
| val partitionAndLeaderEpoch = TransactionPartitionAndLeaderEpoch(partitionId, coordinatorEpoch) | ||
|
|
@@ -618,7 +624,7 @@ class TransactionStateManager(brokerId: Int, | |
|
|
||
| // generate the message for this transaction metadata | ||
| val keyBytes = TransactionLog.keyToBytes(transactionalId) | ||
| val valueBytes = TransactionLog.valueToBytes(newMetadata) | ||
| val valueBytes = TransactionLog.valueToBytes(newMetadata, usesFlexibleRecords()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a test to ensure that this new logic works as expected?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Functionally there is no difference now, so a test didn't come to my mind easily. I guess the best thing is to just look at the version of the record generated. I can add that. |
||
| val timestamp = time.milliseconds() | ||
|
|
||
| val records = MemoryRecords.withRecords(TransactionLog.EnforcedCompression, new SimpleRecord(timestamp, keyBytes, valueBytes)) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.