Current state: "Under Discussion"
Discussion thread: here
JIRA: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Currently, the ProducerPerformance tool supports transactional producers but cannot randomly abort transactions during testing. This prevents developers from evaluating how transactional producers behave under failure scenarios.
This proposal targets four critical areas:
A single new command-line option is introduced: --transaction-abort-ratio
Property | Description |
|---|---|
Type | |
Range | 0.0 to 1.0 |
Default | 0.0 (no transactions aborted) |
Dependency | Only valid when transactions are enabled |
Add the --transaction-abort-ratio argument after the existing --transaction-duration-ms argument:
parser.addArgument("--transaction-abort-ratio")
.action(store())
.required(false)
.type(Double.class)
.metavar("TRANSACTION-ABORT-RATIO")
.dest("transactionAbortRatio")
.setDefault(0.0)
.help("The ratio of transactions to abort during the test. "
+ "The value should be between 0.0 and 1.0. "
+ "This option is only valid when transactions are enabled.");
|
Add a new field double transactionAbortRatio with the following validations:
ArgumentParserException if the value is outside the [0.0, 1.0] range;ArgumentParserException if transactionAbortRatio is greater than 0.0 but transactions are not enabled, since aborting without transactions is meaningless.There are currently two places where commitTransaction() is called:
transactionDurationMsAt both commit points, use the existing SplittableRandom instance to randomly decide whether to commit or abort based on the ratio:
if (random.nextDouble() < config.transactionAbortRatio) {
producer.abortTransaction();
} else {
producer.commitTransaction();
}
|
Note: The current code uses a fixed seed (new SplittableRandom(0)). The abort decision reuses the same instance, so for a given ratio and record count, results are deterministic and reproducible.
Transactions during the warmup phase are also subject to the --transaction-abort-ratio. The warmup phase (introduced in KAFKA-17645) is designed to bring the system into a steady state before collecting performance statistics. If the abort ratio were only applied during the steady-state phase, the system would transition from an all-commit warmup to a mixed commit/abort steady state, introducing an additional settling period that undermines the purpose of warmup. Applying the same abort ratio during warmup ensures the system has already stabilized under the target conditions when steady-state measurement begins.
This feature is fully backward compatible:
Unit tests will cover the following scenarios:
--transaction-abort-ratio 0.5 is parsed correctlycommitTransaction() is called)abortTransaction() is called)None