redpanda
redpanda copied to clipboard
transactions: Support transaction coordinator leadership transfer
Cover letter
The patch supports graceful leadership transfer scenario for transaction coordinator (tm_stm). High level approach is as follows.
- Adds a
transferringflag totm_transactionstate. Defaults to false but is true for transfer-in-progress txns. - Upon receiving a leadership transfer request, flip this flag and flush ongoing txns to log
- New leader applies them in-memory and lazily resets the flag upon access but before updating their state.
- If the flag is set and the term does not match, new leader expires them so that we don't read any dirty uncommitted txns.
A side effect of this refactoring is that the transactions can now appear in log/mem state, so the patch refactors to lookup in both places wherever needed.
Fixes #6214
Backport Required
- [x] not a bug fix
- [ ] issue does not exist in previous branches
- [ ] papercut/not impactful enough to backport
- [x] v22.2.x
- [ ] v22.1.x
- [ ] v21.11.x
UX changes
- none
Release notes
- none
Improvements
- Transactions can now span leadership changes of transaction coordinator.
Put * none for UX changes and Release notes
Do we need to add some chaos test for it?
/ci-repeat 5
Test failure #6601