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

Feature: Saga provide a switch to skip branch report on branch success, in order to optimize performance. #2151

Merged
merged 4 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Skip branch report on branch commit success. #2150
  • Loading branch information
long187 committed Jan 7, 2020
commit e8bd719fe99f7295d83ebbecc7a0fd4cad8aacc6
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class DbStateMachineConfig extends DefaultStateMachineConfig implements D
private String dbType;
private int transOperationTimeout = DEFAULT_TRANS_OPER_TIMEOUT;
private SagaTransactionalTemplate sagaTransactionalTemplate;
private boolean skipBranchReportOnSuccess;
Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/seata/seata/blob/a1a51e0c3d374ed0f9604012e9aac1f9822a7495/script/client/spring/application.yml#L9 There is a similar function switch in AT mode. If this configuration can be combined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


public static String getDbTypeFromDataSource(DataSource dataSource) throws SQLException {
Connection con = null;
Expand Down Expand Up @@ -165,4 +166,12 @@ public int getTransOperationTimeout() {
public void setTransOperationTimeout(int transOperationTimeout) {
this.transOperationTimeout = transOperationTimeout;
}

public boolean isSkipBranchReportOnSuccess() {
return skipBranchReportOnSuccess;
}

public void setSkipBranchReportOnSuccess(boolean skipBranchReportOnSuccess) {
this.skipBranchReportOnSuccess = skipBranchReportOnSuccess;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import io.seata.core.exception.TransactionException;
import io.seata.core.model.BranchStatus;
import io.seata.core.model.GlobalStatus;
import io.seata.saga.engine.StateMachineConfig;
import io.seata.saga.engine.config.DbStateMachineConfig;
import io.seata.saga.engine.exception.EngineExecutionException;
import io.seata.saga.engine.sequence.SeqGenerator;
import io.seata.saga.engine.serializer.Serializer;
Expand Down Expand Up @@ -404,7 +406,13 @@ public void recordStateFinished(StateInstance stateInstance, ProcessContext cont
executeUpdate(stateLogStoreSqls.getRecordStateFinishedSql(dbType), STATE_INSTANCE_TO_STATEMENT_FOR_UPDATE,
stateInstance);

branchReport(stateInstance, context);
StateMachineConfig stateMachineConfig = (StateMachineConfig) context.getVariable(
DomainConstants.VAR_NAME_STATEMACHINE_CONFIG);
if (!(stateMachineConfig instanceof DbStateMachineConfig
&& ((DbStateMachineConfig)stateMachineConfig).isSkipBranchReportOnSuccess()
&& ExecutionStatus.SU.equals(stateInstance.getStatus()))) {
branchReport(stateInstance, context);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<property name="threadPoolExecutor" ref="threadExecutor"></property>
<property name="applicationId" value="test_saga"></property>
<property name="txServiceGroup" value="my_test_tx_group"></property>
<property name="skipBranchReportOnSuccess" value="true"></property>
</bean>
<bean id="threadExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean">
Expand Down