Skip to content

Commit

Permalink
feature:save context into fence log
Browse files Browse the repository at this point in the history
  • Loading branch information
pengten committed May 25, 2023
1 parent 0d05499 commit 9cc7d4e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
10 changes: 10 additions & 0 deletions common/src/main/java/io/seata/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,14 @@ public interface Constants {
* where is the tcc actionContext stored
*/
String TCC_ACTION_CONTEXT_REPORT_TYPE = "actionContextReportType";

/**
* The constant TCC_PREPARE_STATUS
*/
String TCC_PREPARE_STATUS = "tccPrepareStatus";

/**
* Tcc prepare error
*/
String TCC_PREPARE_STATUS_ERROR = "error";
}
4 changes: 2 additions & 2 deletions integration/grpc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.11.0:exe:${os.detected.classifier}</protocArtifact>
<protocArtifact>com.google.protobuf:protoc:3.11.0:exe:linux-aarch_64</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.27.1:exe:${os.detected.classifier}</pluginArtifact>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.27.1:exe:linux-aarch_64</pluginArtifact>
</configuration>
<executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion serializer/seata-serializer-protobuf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<configuration>
<protoSourceRoot>${project.basedir}/src/main/resources/protobuf/io/seata/protocol/transcation/</protoSourceRoot>
<protocArtifact>
com.google.protobuf:protoc:3.11.0:exe:${os.detected.classifier}
com.google.protobuf:protoc:3.11.0:exe:linux-aarch_64
</protocArtifact>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import io.seata.integration.tx.api.fence.store.CommonFenceStore;
import io.seata.integration.tx.api.fence.store.db.CommonFenceStoreDataBaseDAO;
import io.seata.integration.tx.api.remoting.TwoPhaseResult;
import io.seata.rm.tcc.api.BusinessActionContextUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.DataSourceUtils;
Expand Down Expand Up @@ -136,9 +137,11 @@ public Object prepareFence(String xid, Long branchId, String actionName, Callbac
addToLogCleanQueue(xid, branchId);
}
status.setRollbackOnly();
BusinessActionContextUtil.addContext(Constants.TCC_PREPARE_STATUS, Constants.TCC_PREPARE_STATUS_ERROR);
throw new SkipCallbackWrapperException(e);
} catch (Throwable t) {
status.setRollbackOnly();
BusinessActionContextUtil.addContext(Constants.TCC_PREPARE_STATUS, Constants.TCC_PREPARE_STATUS_ERROR);
throw new SkipCallbackWrapperException(t);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public BusinessActionContext search(BusinessActionContext context) {

@Override
public boolean isSupport(BusinessActionContext context) {
return Boolean.TRUE.equals(context.getActionContext(Constants.USE_COMMON_FENCE));
return Boolean.TRUE.equals(context.getActionContext(Constants.USE_COMMON_FENCE))
&& !Constants.TCC_PREPARE_STATUS_ERROR.equals(context.getActionContext(Constants.TCC_PREPARE_STATUS));
}

public static DataSource getDataSource() {
Expand Down

0 comments on commit 9cc7d4e

Please sign in to comment.