You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "zihenzzz (via GitHub)" <gi...@apache.org> on 2026/04/20 13:08:25 UTC

[PR] Feature/benchmark tcc real mode [incubator-seata]

zihenzzz opened a new pull request, #8062:
URL: https://github.com/apache/incubator-seata/pull/8062

   <!--
       Licensed to the Apache Software Foundation (ASF) under one or more
       contributor license agreements.  See the NOTICE file distributed with
       this work for additional information regarding copyright ownership.
       The ASF licenses this file to You under the Apache License, Version 2.0
       (the "License"); you may not use this file except in compliance with
       the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
       
       Unless required by applicable law or agreed to in writing, software
       distributed under the License is distributed on an "AS IS" BASIS,
       WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       See the License for the specific language governing permissions and
       limitations under the License.
   -->
   <!-- Please make sure you have read and understood the contributing guidelines -->
   
   - [ ] I have read the [CONTRIBUTING.md](https://github.com/apache/incubator-seata/blob/2.x/CONTRIBUTING.md) guidelines.
   - [ ] I have registered the PR [changes](https://github.com/apache/incubator-seata/tree/2.x/changes).
   
   ### Ⅰ. Describe what this PR did
   
   
   ### Ⅱ. Does this pull request fix one issue?
   <!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->
   fix:https://github.com/apache/incubator-seata/issues/8009
   
   ### Ⅲ. Why don't you add test cases (unit test/integration test)? 
   
   
   ### Ⅳ. Describe how to verify it
   
   
   ### Ⅴ. Special notes for reviews
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] feature: benchmark tcc real mode [incubator-seata]

Posted by "WangzJi (via GitHub)" <gi...@apache.org>.
WangzJi merged PR #8062:
URL: https://github.com/apache/incubator-seata/pull/8062


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] Feature/benchmark tcc real mode [incubator-seata]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #8062:
URL: https://github.com/apache/incubator-seata/pull/8062#issuecomment-4281158101

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/8062?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 72.11%. Comparing base ([`630f502`](https://app.codecov.io/gh/apache/incubator-seata/commit/630f502c8b254c15eb175cf3995d47128d6bd554?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`2900ccc`](https://app.codecov.io/gh/apache/incubator-seata/commit/2900ccc6c7d2aa750f84842da284189aefc9d14d?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##                2.x    #8062      +/-   ##
   ============================================
   + Coverage     72.08%   72.11%   +0.02%     
     Complexity      872      872              
   ============================================
     Files          1320     1320              
     Lines         50545    50545              
     Branches       6026     6026              
   ============================================
   + Hits          36435    36450      +15     
   + Misses        11114    11102      -12     
   + Partials       2996     2993       -3     
   ```
   [see 3 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/8062/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/incubator-seata/pull/8062/graphs/tree.svg?width=650&height=150&src=pr&token=tbmHt2ZfxO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/incubator-seata/pull/8062?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] Feature/benchmark tcc real mode [incubator-seata]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #8062:
URL: https://github.com/apache/incubator-seata/pull/8062#discussion_r3114815707


##########
test-suite/seata-benchmark-cli/README.md:
##########
@@ -100,6 +100,14 @@ java -jar seata-benchmark-cli.jar \
   --duration 60 \
   --branches 3
 
+# TCC mode with real try/confirm/cancel
+java -jar seata-benchmark-cli.jar \
+  --server 127.0.0.1:8091 \
+  --mode TCC \
+  --tps 100 \
+  --duration 60 \
+  --branches 3

Review Comment:
   This runnable example omits `--threads 1`. With the current config validation (`BenchmarkConfig.validateTpsAndThreads`), `--tps 100` cannot be combined with the default `--threads 10`, so this command will fail unless `--threads 1` is specified (or `--tps` is raised to the unlimited threshold).



##########
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/tcc/BenchmarkTccAction.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.benchmark.tcc;
+
+import org.apache.seata.rm.tcc.api.BusinessActionContext;
+import org.apache.seata.rm.tcc.api.LocalTCC;
+import org.apache.seata.rm.tcc.api.TwoPhaseBusinessAction;
+
+/**
+ * Benchmark TCC action interface.
+ *
+ * <p>Used by {@link org.apache.seata.benchmark.executor.TCCModeExecutor} in real mode
+ * ({@code branches > 0}) to drive the TCC protocol path through the Seata interceptor.
+ * Each call to {@link #prepare} registers one TCC branch with the TC. On global commit
+ * the TC invokes {@link #commit}; on global rollback it invokes {@link #rollback}.
+ *
+ * <p>All three methods are intentionally no-ops so the benchmark measures only Seata
+ * protocol overhead, not business logic.
+ */
+@LocalTCC
+public interface BenchmarkTccAction {
+
+    @TwoPhaseBusinessAction(name = "benchmarkTccAction", commitMethod = "commit", rollbackMethod = "rollback")

Review Comment:
   `@TwoPhaseBusinessAction(name = "benchmarkTccAction", ...)` uses a very generic, constant action name. Since TCC resource IDs must be unique within a JVM (see `TCCResourceManager.registerResource` throwing `RepeatRegistrationException` on duplicates), this can collide if the benchmark CLI is embedded/run alongside other TCC participants or multiple benchmark runs in the same JVM. Consider namespacing the action name (e.g., prefix with `seata-benchmark-cli-` or similar) to reduce collision risk.
   ```suggestion
       String ACTION_NAME = "seata-benchmark-cli-benchmarkTccAction";
   
       @TwoPhaseBusinessAction(name = ACTION_NAME, commitMethod = "commit", rollbackMethod = "rollback")
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [PR] Feature/benchmark tcc real mode [incubator-seata]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #8062:
URL: https://github.com/apache/incubator-seata/pull/8062#discussion_r3114545314


##########
changes/en-us/2.x.md:
##########
@@ -19,6 +19,7 @@ Add changes here for all PR submitted to the 2.x branch.
 <!-- Please add the `changes` to the following location(feature/bugfix/optimize/test) based on the type of PR -->
 
 ### feature:
+- [[#8062](https://github.com/apache/incubator-seata/pull/???)] implement real TCC mode in benchmark CLI

Review Comment:
   The changelog entry still contains a placeholder PR link (`pull/???`) and an inconsistent reference (`#8062`). Please replace with the actual PR number/link for this change before merging.
   ```suggestion
   
   ```



##########
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/executor/TCCModeExecutor.java:
##########
@@ -17,41 +17,128 @@
 package org.apache.seata.benchmark.executor;
 
 import org.apache.seata.benchmark.config.BenchmarkConfig;
+import org.apache.seata.benchmark.tcc.BenchmarkTccAction;
+import org.apache.seata.benchmark.tcc.BenchmarkTccActionImpl;
+import org.apache.seata.integration.tx.api.interceptor.InvocationWrapper;
+import org.apache.seata.integration.tx.api.interceptor.handler.ProxyInvocationHandler;
+import org.apache.seata.rm.tcc.interceptor.parser.TccActionInterceptorParser;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
 /**
- * TCC mode transaction executor (simplified mock implementation)
- * Note: For Phase 1 (MVP), TCC mode executes empty transactions similar to AT mode.
- * Full TCC implementation with try/confirm/cancel will be added in future versions.
+ * TCC mode transaction executor.
+ *
+ * <p>Supports two sub-modes controlled by {@code --branches}:
+ * <ul>
+ *   <li><b>Empty mode</b> ({@code branches == 0}): starts and commits an empty global
+ *       transaction. Measures pure Seata protocol overhead with no branch registration.</li>
+ *   <li><b>Real mode</b> ({@code branches > 0}): registers {@code branches} TCC branches
+ *       per transaction via the {@link BenchmarkTccAction} proxy. On commit the TC invokes
+ *       {@link BenchmarkTccAction#commit} for every registered branch; on rollback it invokes
+ *       {@link BenchmarkTccAction#rollback}.</li>
+ * </ul>
+ *
+ * <p>No Spring container is required. A JDK dynamic proxy wraps
+ * {@link org.apache.seata.rm.tcc.interceptor.TccActionInterceptorHandler},
+ * which is equivalent to what Spring AOP would produce at runtime.
  */
 public class TCCModeExecutor extends AbstractTransactionExecutor {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(TCCModeExecutor.class);
 
+    private BenchmarkTccAction actionProxy;
+    private BenchmarkTccActionImpl actionImpl;
+
     public TCCModeExecutor(BenchmarkConfig config) {
         super(config);
     }
 
+    private boolean isRealMode() {
+        return config.getBranches() > 0;
+    }
+
     @Override
     public void init() {
-        LOGGER.info("TCC mode executor initialized (simplified mock mode)");
+        if (isRealMode()) {
+            initRealMode();
+        } else {
+            LOGGER.info("TCC mode executor initialized (empty transaction mode)");
+        }
+    }
+
+    private void initRealMode() {
+        LOGGER.info("Initializing TCC mode executor (try/confirm/cancel)");
+
+        actionImpl = new BenchmarkTccActionImpl();
+
+        // TccActionInterceptorParser does two things:
+        // 1. Registers TCCResource with DefaultResourceManager (enables TC callbacks)
+        // 2. Returns a TccActionInterceptorHandler for proxy dispatch
+        TccActionInterceptorParser parser = new TccActionInterceptorParser();
+        ProxyInvocationHandler handler;
+        try {
+            handler = parser.parserInterfaceToProxy(actionImpl, "benchmarkTccService");
+        } catch (Exception e) {
+            throw new RuntimeException("Failed to initialize TCC proxy", e);
+        }

Review Comment:
   `TccActionInterceptorParser#parserInterfaceToProxy(...)` can return `null` when no `@TwoPhaseBusinessAction` methods are found. If that happens, `handler.invoke(...)` below will throw a NPE with a confusing stack trace. Add an explicit null check after parsing and throw a clear exception (or log and fall back to empty mode).
   ```suggestion
           }
           if (handler == null) {
               throw new IllegalStateException("Failed to initialize TCC proxy: no @TwoPhaseBusinessAction method was found for "
                       + BenchmarkTccAction.class.getName());
           }
   ```



##########
changes/zh-cn/2.x.md:
##########
@@ -20,6 +20,7 @@
 
 ### feature:
 
+- [[#8062](https://github.com/apache/incubator-seata/pull/???)] 为benchmark CLI实现真实TCC模式(try/confirm/cancel)

Review Comment:
   The changelog entry still contains a placeholder PR link (`pull/???`) and an inconsistent reference (`#8062`). Please replace with the actual PR number/link for this change before merging.
   ```suggestion
   - [[#8062](https://github.com/apache/incubator-seata/pull/8062)] 为benchmark CLI实现真实TCC模式(try/confirm/cancel)
   ```



##########
test-suite/seata-benchmark-cli/src/main/java/org/apache/seata/benchmark/tcc/BenchmarkTccAction.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.benchmark.tcc;
+
+import org.apache.seata.rm.tcc.api.BusinessActionContext;
+import org.apache.seata.rm.tcc.api.LocalTCC;
+import org.apache.seata.rm.tcc.api.TwoPhaseBusinessAction;
+
+/**
+ * Benchmark TCC action interface.
+ *
+ * <p>Used by {@link TCCModeExecutor} in real mode ({@code branches > 0}) to drive the TCC
+ * protocol path through the Seata interceptor. Each call to {@link #prepare} registers one
+ * TCC branch with the TC. On global commit the TC invokes {@link #commit}; on global rollback
+ * it invokes {@link #rollback}.

Review Comment:
   The Javadoc references `{@link TCCModeExecutor}`, but that class is in a different package (`org.apache.seata.benchmark.executor`) and isn’t imported/fully-qualified here. This link won’t resolve during Javadoc generation (and can fail builds if doclint is strict). Use a fully-qualified link (or remove/replace the link).
   ```suggestion
    * <p>Used by {@link org.apache.seata.benchmark.executor.TCCModeExecutor} in real mode
    * ({@code branches > 0}) to drive the TCC protocol path through the Seata interceptor.
    * Each call to {@link #prepare} registers one TCC branch with the TC. On global commit
    * the TC invokes {@link #commit}; on global rollback it invokes {@link #rollback}.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org