Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pulsar Transaction]Transaction client transaction state check #9776

Conversation

congbobo184
Copy link
Contributor

@congbobo184 congbobo184 commented Mar 2, 2021

Motivation

Now pulsar client don't check the transaction state, so when it committed or aborted, it also can produce or ack message. It should be prevented.

implement

Add the State :

    public enum State {
        OPEN,
        COMMITTING,
        ABORTING,
        COMMITTED,
        ABORTED,
        ERROR
    }

when open we can do transaction operation, it is close we can't do transaction operation.

Verifying this change

Add the tests for it

Does this pull request potentially affect one of the following parts:
If yes was chosen, please highlight the changes

Dependencies (does it add or upgrade a dependency): (no)
The public API: (no)
The schema: (no)
The default values of configurations: (no)
The wire protocol: (yes)
The rest endpoints: (no)
The admin cli options: (no)
Anything that affects deployment: (no)

@congbobo184 congbobo184 changed the title Congbobo184 transaction client transaction state check [Pulsar Transaction]transaction client transaction state check Mar 2, 2021
@congbobo184 congbobo184 changed the title [Pulsar Transaction]transaction client transaction state check [Pulsar Transaction]Transaction client transaction state check Mar 2, 2021
Comment on lines 67 to 68
OPEN,
CLOSE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not keep the state consistent with the transaction state? Open/Committing/Aborting/Committed/Aborted ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some situation we can't get the real state fro this transaction, example: the transaction timeout, it will be aborted but client commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the state should be committing -> closed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit or abort finish, the state will become closed. we don't need to change the state to committing or aborting, it seem not useful. When we need committing or aborting sate we can add.

@congbobo184
Copy link
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@congbobo184
Copy link
Contributor Author

/pulsarbot run-failure-checks

}
tcClient.abortAsync(new TxnID(txnIdMostBits, txnIdLeastBits)).whenComplete((vx, ex) -> {
return checkIfOpen().thenCompose(value -> {
CompletableFuture<Void> abortFuture = new CompletableFuture<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to aborting first?

.withTransactionTimeout(1, TimeUnit.SECONDS)
.build().get();

Thread.sleep(2000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid use sleep.

Comment on lines 213 to 214
return FutureUtil.failedFuture(new InvalidTxnStatusException("[" + txnIdMostBits + ":"
+ txnIdLeastBits + "] Transaction in " + state.name() + " state!"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print the expected transaction state and the current transaction state?

@codelipenghui
Copy link
Contributor

@gaoran10 Please help review this PR

@congbobo184
Copy link
Contributor Author

/pulsarbot run-failure-checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants