transactions: support topic deletions with active transactions
Cover letter
Builds on top of transaction expiration loop that periodically expires expired tx_ids. Now that expiration also attempts to expire transactions with deleted partitions. For timely expiry we rely on deletion notifications from topics table that tickles the expiration loop.
Particularly sticky case here is when the transaction is in preparing mode and the
the partition disappears. In such cases, we attempt to commit first and if that fails,
abort with a reduced partition list (without the deleted partitions) and if that succeeds,
expire the transaction right away.
Primary focus of the patch is to unblock consumers on partitions within the same txn scope but are not deleted (they may belong to a different topic). Also, relying on the topic_table/metadata_cache may result in cause some sticky races in create-delete-create situations, especially after a node bootstraps and the replay of the controller log is in progress. Such actions typically unsupported and may result in weird outcomes (Kafka has the same behavior per docs).
Fixes core-internal#28
Backport Required
- [x] not a bug fix
- [x] issue does not exist in previous branches
- [ ] papercut/not impactful enough to backport
- [ ] v22.2.x
- [ ] v22.1.x
- [ ] v21.11.x
UX changes
Consumers have a better experience when deleting topics with active transactions without stuck consumers.