<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>For English only</strong>, other languages will not accept.</p>
<p dir="auto">Before report a bug, make sure you have:</p>
<ul dir="auto">
<li>Searched open and closed <a href="https://github.com/apache/shardingsphere/issues">GitHub issues</a>.</li>
<li>Read documentation: <a href="https://shardingsphere.apache.org/document/current/en/overview" rel="nofollow">ShardingSphere Doc</a>.</li>
</ul>
<p dir="auto">Please pay attention on issues you submitted, because we maybe need more details.<br>
If no response anymore and we cannot reproduce it on current information, we will <strong>close it</strong>.</p>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto">5.0.1-SNAPSHOT</p>
<h3 dir="auto">Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?</h3>
<p dir="auto">ShardingSphere-Proxy</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">execute XA transaction</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">when test by sysbech read_write for proxy-myqsl XA mode, got following errrors:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Initializing worker threads...

Threads started!

FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
(last message repeated 1 times)
FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
(last message repeated 1 times)
FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
(last message repeated 1 times)
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
(last message repeated 1 times)
FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
"><pre class="notranslate"><code class="notranslate">Initializing worker threads...

Threads started!

FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
(last message repeated 1 times)
FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
(last message repeated 1 times)
FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
(last message repeated 1 times)
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state
(last message repeated 1 times)
FATAL: mysql_stmt_execute() returned error 1399 (XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state) for query 'COMMIT'
FATAL: `thread_run' function failed: /usr/share/sysbench/oltp_common.lua:409: SQL error, errno = 1399, state = 'XAE07': XAER_RMFAIL: The command cannot be executed when global transaction is in the  ACTIVE state

</code></pre></div>
<h3 dir="auto">Reason analyze (If you can)</h3>
<p dir="auto">maybe same as <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="824546125" data-permission-text="Title is private" data-url="https://github.com/apache/shardingsphere/issues/9611" data-hovercard-type="issue" data-hovercard-url="/apache/shardingsphere/issues/9611/hovercard" href="https://github.com/apache/shardingsphere/issues/9611">#9611</a></p>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<ol dir="auto">
<li>start a proxy with sharding mode and XA mode for mysql</li>
<li>execute following sysbench script:</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="sysbench oltp_read_write --mysql-host=10.16.9.234 --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=1 --table-size=1 --report-interval=5 --time=180 --threads=100 --max-requests=0 --percentile=99  --range_selects=off --rand-type=uniform --auto_inc=off run | tee transanction.XA.tx"><pre class="notranslate"><code class="notranslate">sysbench oltp_read_write --mysql-host=10.16.9.234 --mysql-port=3307 --mysql-user=root --mysql-password='root' --mysql-db=sbtest --tables=1 --table-size=1 --report-interval=5 --time=180 --threads=100 --max-requests=0 --percentile=99  --range_selects=off --rand-type=uniform --auto_inc=off run | tee transanction.XA.tx
</code></pre></div>
<p dir="auto">Hello, The shardingsphere version I am using is 5.0.0，the following is my code and result data, please look at the reason：<br>
<strong>Test code:</strong><br>
object SnowFlakeUtils {<br>
fun  getId(workerId: String): Long {<br>
val keyGenerator = SnowflakeKeyGenerateAlgorithm()<br>
val properties = Properties()<br>
properties.setProperty("worker-id", workerId)<br>
keyGenerator.props = properties<br>
keyGenerator.init()<br>
return keyGenerator.generateKey().toString().toLong()<br>
}<br>
}<br>
for (i in 1..100) {<br>
println(SnowFlakeUtils.getId("1"))<br>
}</p>
<p dir="auto"><strong>The resulting data is:</strong><br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630224842752<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630229037056<br>
725026630233231360</p>