kafka/clients
Ritika Reddy c7e4ff01cd
CI / build (push) Waiting to run Details
KAFKA-19272: Add initPid Response handling when keepPrepared is set to true (KIP-939) (#20039)
When initPid(keepPrepared = true) is called after a client crashes,
several situations should be considered.

When there's an ongoing transaction, we can transition it to the newly
added PREPARED_TRANSACTION state. However, what if there's no ongoing
transaction?

Another scenario could be:

- Issued a commit, to commit prepared
- The commit succeeded on the TC, but the client crashed
- Client restarted with keepPreparedTxn=true (because it doesn't know if
the commit succeeded or not and needs to keep retrying the commit until
it's successful)
- Issued a commit, but the transaction is not ongoing, because it's
committed

**Solution:**
This is a perfectly valid scenario as the external transaction
coordinator for the 2PC transaction will keep committing participants,
and the participants need to eventually return success (that's a
guarantee for a prepared transaction).
_Rejected Alt 1_ -> Return an InvalidTxnStateException : Returning an
error would break the above scenario.
_Rejected Alt 2_ -> Then the next thought is that we should somehow
validate if the state is expected, but we don't have data to validate
the result against.

**Final Solution:**  Just returning the success and transitioning to
READY is the proper handling of this condition.

Reviewers: Justine Olshan <jolshan@confluent.io>, Artem Livshits
 <alivshits@confluent.io>
2025-07-22 15:03:49 -07:00
..
clients-integration-tests/src/test MINOR: Rename waitForTopic to waitTopicCreation (#20216) 2025-07-22 21:02:57 +08:00
src KAFKA-19272: Add initPid Response handling when keepPrepared is set to true (KIP-939) (#20039) 2025-07-22 15:03:49 -07:00
.gitignore KAFKA-4848: Fix retryWithBackoff deadlock issue 2017-03-20 21:56:15 -07:00