apache / apache/incubator-seata

Session State Management with StateMachine

Open
#796 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
26k
Forks
8.8k
Avg merge
1d 8h
Merged PRs (30d)
4

Description

## Why you need it?

Now, I can see that there was no state control of Global session. for this test case (if I have)

```
@Test
public void test(){
GlobalSession globalSession = new GlobalSession("demo-app", "my_test_tx_group", "test", 6000);
try {
globalSession.changeStatus(GlobalStatus.CommitFailed);
} catch (TransactionException e) {
e.printStackTrace();
}
try {
globalSession.changeStatus(GlobalStatus.Committed);
} catch (TransactionException e) {
e.printStackTrace();
}
}
```

this case will not throw any exp, but we all know, failed can not transfer to commited( or other state), so what the status will need some logic code to keep right, but I think there is some state transform we need to obey.

## How it could be?

maybe we need to keep a state transform graph in GlobalSession, which define the possible transforms between states.

maybe like this

```
@Override
public void changeStatus(GlobalStatus status) throws TransactionException {

if (state.transfer(status)){
this.status=status
}else{
throw exp;
}
}
```

so everyone can understand what is the corrent state transform.

## Other related information
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Research direction

Start at GlobalSession.changeStatus and trace how GlobalStatus values are currently applied. Use the test case in the issue to verify that an invalid transition such as CommitFailed to Committed raises TransactionException, then define and test the permitted state transitions before considering the work done.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.