Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

3.2 Extracting TransactionSession from TransactionManager

ComponentResponsibility
TransactionSession (New)Identity (ID/Epoch), Lifecycle State Machine, Coordinator RPCs, and Heartbeat thread.
TransactionManager (Slimmed)Sequence numbers, in-flight partition management, and Sender thread interaction.

State mapping:

Current TransactionManager.StateNew TransactionSession.State
UNINITIALIZED / INITIALIZINGUNINITIALIZED / INITIALIZING
READY / IN_TRANSACTIONREADY / IN_TRANSACTION
PREPARED_TRANSACTIONPREPARED
COMMITTING_TRANSACTIONCOMMITTING
ABORTING_TRANSACTIONABORTING
ABORTABLE_ERROR / FATAL_ERRORABORTABLE_ERROR / FATAL_ERROR

3.3 No Wire Protocol Changes

This KIP reuses existing RPCs and schemas. TransactionSession becomes the new sender for all transaction-related requests:


RPCCurrent SenderNew Sender
FindCoordinator / InitProducerIdTransactionManagerTransactionSession
AddPartitionsToTxn / EndTxnTransactionManagerTransactionSession
AddOffsetsToTxn / TxnOffsetCommitTransactionManagerTransactionSession
TxnHeartbeat (KIP-1309)N/ATransactionSession
AddShareAcksToTxn (KIP-1289)N/ATransactionSession


3.4 Internal Network Client


TransactionSession uses a lightweight NetworkClient for coordinator communication, similar to the consumer's HeartbeatThread.


Dedicated Connection - Maintains its own connection to the coordinator broker.


4. Use Cases

4.1 Apache Flink: Lightweight Transaction Completion

...

KafkaProducer constructed with transactional.id in the config continues to work exactly as today.

Internally, it creates a TransactionSession and delegates to it, but the public API (initTransactions(), beginTransaction(), commitTransaction(), abortTransaction(), sendOffsetsToTransaction()) is unchanged.

...

No deprecations. The KafkaProducer convenience methods remain the recommended API for simple produce-and-commit patterns. TransactionSession is for advanced use cases: 2PC, cross-entity transactions, external coordinators.

...

6.

...

Security

6.1 Authorization

TransactionSession requires the same ACLs as the current producer transaction API:

RPC

Phase 1: Introduce TransactionSession class. Internal refactoring of TransactionManager. All existing code continues to work.

Phase 2: Add KafkaProducer(configs, TransactionSession) constructor. Enables external session management. Flink, Connect, Streams can optionally adopt.

Phase 3: Add KafkaShareConsumer.acknowledgeTransactionally(session, acks). Enables KIP-1289 transactional ack implementation.

Each phase is independently deployable. Phase 1 is a pure refactoring with no public API changes.

5.4 Wire Protocol Compatibility

No wire protocol changes. No new RPCs. No new request/response versions. TransactionSession uses the same RPCs at the same versions as the current TransactionManager. A cluster running any version of Kafka that supports transactions (0.11+) can be used with TransactionSession.

6. Security

6.1 Authorization

TransactionSession requires the same ACLs as the current producer transaction API:

RPC

Resource Type

Operation

InitProducerId

TRANSACTIONAL_ID

WRITE

AddPartitionsToTxn

TRANSACTIONAL_ID

WRITE; TOPIC

EndTxn

TRANSACTIONAL_ID

WRITE

TxnHeartbeat (KIP 1309)

TRANSACTIONAL_ID

WRITE

AddShareAcksToTxn (KIP-1289)

TRANSACTIONAL_ID

WRITE; GROUP

...

When a TransactionSession is shared between a producer and a share consumer (Use Case 4.2), both entities operate under the same transactionalId and require the same ACLs.

The session identity is not multiplied -- there is one session, one one producerId, one epoch, regardless of how many clients use it.

...