You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Guozhang Wang (Jira)" <ji...@apache.org> on 2020/04/05 22:32:00 UTC

[jira] [Updated] (KAFKA-9811) TransactionMetadata state and pendingState are non-volatile and read outside the metadata lock

     [ https://issues.apache.org/jira/browse/KAFKA-9811?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guozhang Wang updated KAFKA-9811:
---------------------------------
    Component/s: core

> TransactionMetadata state and pendingState are non-volatile and read outside the metadata lock
> ----------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-9811
>                 URL: https://issues.apache.org/jira/browse/KAFKA-9811
>             Project: Kafka
>          Issue Type: Bug
>          Components: core
>            Reporter: Bob Barrett
>            Priority: Major
>
> As an example, in TransactionStateManager.timedOutTransactions(), we read the state and pendingState without acquiring the lock for each metadata object:
> {code:java}
> inReadLock(stateLock) {
>   transactionMetadataCache.flatMap { case (_, entry) =>
>     entry.metadataPerTransactionalId.filter { case (_, txnMetadata) =>
>       if (txnMetadata.pendingTransitionInProgress) {
>         false
>       } else {
>         txnMetadata.state match {
>           case Ongoing =>
>             txnMetadata.txnStartTimestamp + txnMetadata.txnTimeoutMs < now
>           case _ => false
>         }
>       }
>     }.map { case (txnId, txnMetadata) =>
>       TransactionalIdAndProducerIdEpoch(txnId, txnMetadata.producerId, txnMetadata.producerEpoch)
>     }
>   }
> }{code}
> The start timestamp is volatile, so it can be safely read, but we also read the pendingState and state, which are not.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)