apache / apache/pulsar

[Bug] [txn] callback of commit/abort is not accurate in transaction

Open
#19,747 3 comments 0 reactions 1 assignee Claimed by @TakaHiR07 View on GitHub
Stale type/bug
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 14h
Merged PRs (30d)
160

Description

### Search before asking

- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.

### Version

master branch

### Minimal reproduce step

When I reading the transaction code and pip-31,I found the implementation of CommandEndTxn is not as pip-31 described. Now the txn client execute commit() or abort() would wait the reponse from server until txn status become committed or aborted.

![企业微信截图_47c1b690-de98-4380-a676-804d5b3c28d6](https://user-images.githubusercontent.com/13505225/223641043-df77b242-683b-40b3-bbad-a16a36f0dd85.png)

![企业微信截图_7990a84a-28a4-4f95-af32-96813d9dbf1a](https://user-images.githubusercontent.com/13505225/223634180-3f985abe-1358-4b3d-b674-051e54e22f15.png)

And now the callback of commit() can not reflect the actual status of txn. For example, 2 case may occur
1. broker may be unavailable before server update txnstatus to committing
2. broker may be unavailable between committing and committed

For case 2, may throw CoordinatorNotFound exception to client, then client would retry txn.commit(). But when broker recover, coordinator would firstly recover the previous transactions. Then broker process the retry-commit, may return InvalidTxnStatus or transactionNotFound to client, Which client would regard txn commit error, but actually it is success.

Why we don't respond success to client when server update txn-status to committing ? @congbobo184 @liangyepianzhou

### What did you expect to see?

throw exception in commit.callback, but txn is success

### What did you see instead?

commit.callback can reflect the accurate status

### Anything else?

_No response_

### Are you willing to submit a PR?

- [X] I'm willing to submit a PR!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.