<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 <strong>more than 7 days</strong> 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">4.0.0</p>
<h3 dir="auto">Which project did you use? Sharding-JDBC or Sharding-Proxy?</h3>
<p dir="auto">Sharding-JDBC</p>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">primary key produced by key generator<br>
Logic SQL:<br>
insert into test_complex 	(<code class="notranslate">name</code>,age,create_time,modified_time,user_id,phone,address)<br>
values(?,?,?,?,?,	?,?) , (?,?,?,?,?,?,?)<br>
route result of sharding key(id)<br>
logicName=sharding_db, value=461910991453999105, hash=1101970151 , mod=1<br>
logicName=sharding_db, mod=1 ,route =sharding_db_1<br>
logicName=test_complex, value=461910991453999105, hash=1101970151 , mod=7<br>
logicName=test_complex, mod=7 ,route =test_complex_7</p>
<p dir="auto">logicName=sharding_db, value=461910991453999108, hash=1101970154 , mod=0<br>
logicName=sharding_db, mod=0 ,route =sharding_db_0<br>
logicName=test_complex, value=461910991453999108, hash=1101970154 , mod=2<br>
logicName=test_complex, mod=2 ,route =test_complex_2</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">Actual SQL: sharding_db_1 ::: insert into test_complex_3	(<code class="notranslate">name</code>,age,create_time,modified_time,user_id,phone,address,id) values<br>
(?, ?, ?, ?, ?, ?, ?, ?),(?, ?, ?, ?, ?, ?, ?, ?)<br>
::: [null, 1, 2020-04-28 15:09:21.415, 2020-04-28 15:09:21.415, 09c53d8e85934bbf8aeeec3d4711c0c95, 09c53d8e85934bbf8aeeec3d4711c0c95, 时代峰峻克鲁赛德, 461910991453999108, null, 1, 2020-04-28 15:09:21.415, 2020-04-28 15:09:21.415, 09c53d8e85934bbf8aeeec3d4711c0c98, 09c53d8e85934bbf8aeeec3d4711c0c98, 时代峰峻克鲁赛德, 461910991453999105]</p>
<h3 dir="auto">Reason analyze (If you can)</h3>
<p dir="auto">ShardingGeneratedKeyInsertValueParameterRewriter rewrite generateKey values had a descendingIterator<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/31645800/80464764-d9192b00-896c-11ea-8ee9-39ff979e871f.png"><img src="https://user-images.githubusercontent.com/31645800/80464764-d9192b00-896c-11ea-8ee9-39ff979e871f.png" alt="image" style="max-width: 100%;"></a><br>
the params had a descending order of route result, cause th actual sql is wrong<br>
why use descendingIterator here ?  if use common iterator would cause some problems?</p>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>
<h2 dir="auto">Bug Report</h2>
<h3 dir="auto">Which version of ShardingSphere did you use?</h3>
<p dir="auto">5.1.1</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">i hava three databases of mysql，one for write，tow for read，i use ShardingSphere-Proxy and config readwrite-splitting, when a select not in transaction, i think it will route to read database .</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">begin, all my examples run good util a request with <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/transactional/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/transactional">@transactional</a> ，after this request，all select sql route to write database  even in other request</p>
<h3 dir="auto">Reason analyze (If you can)</h3>
<p dir="auto">i debug the ShardingSphere-Proxy，find the TransactionHolder.isTransaction=true，but i can't understand why a request with transaction can affect other request</p>
<h3 dir="auto">Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.</h3>
<hr>
<p dir="auto">config-readwrite-splitting.yaml</p>
<p dir="auto">schemaName: x1db_shardingsphere</p>
<p dir="auto">dataSources:<br>
write_ds_141:<br>
url: jdbc:mysql://10.110.34.141:3306/x1db?serverTimezone=UTC&amp;useSSL=false&amp;characterEncoding=utf8<br>
username: root<br>
password:<br>
connectionTimeoutMilliseconds: 30000<br>
idleTimeoutMilliseconds: 60000<br>
maxLifetimeMilliseconds: 1800000<br>
maxPoolSize: 50<br>
minPoolSize: 1<br>
read_ds_151:<br>
url: jdbc:mysql://10.110.34.151:3306/x1db?serverTimezone=UTC&amp;useSSL=false&amp;characterEncoding=utf8<br>
username: root<br>
password:<br>
connectionTimeoutMilliseconds: 30000<br>
idleTimeoutMilliseconds: 60000<br>
maxLifetimeMilliseconds: 1800000<br>
maxPoolSize: 50<br>
minPoolSize: 1<br>
read_ds_152:<br>
url: jdbc:mysql://10.110.34.152:3306/x1db?serverTimezone=UTC&amp;useSSL=false&amp;characterEncoding=utf8<br>
username: root<br>
password:<br>
connectionTimeoutMilliseconds: 30000<br>
idleTimeoutMilliseconds: 60000<br>
maxLifetimeMilliseconds: 1800000<br>
maxPoolSize: 50<br>
minPoolSize: 1</p>
<p dir="auto">rules:</p>
<ul dir="auto">
<li>!READWRITE_SPLITTING<br>
dataSources:<br>
readwrite_ds:<br>
type: Static<br>
props:<br>
write-data-source-name: write_ds_141<br>
read-data-source-names: read_ds_151, read_ds_152</li>
</ul>
<hr>
<p dir="auto">server.yaml</p>
<p dir="auto">rules:</p>
<ul dir="auto">
<li>!AUTHORITY<br>
users:
<ul dir="auto">
<li>root@%:shardingsphere@141<br>
provider:<br>
type: ALL_PRIVILEGES_PERMITTED</li>
</ul>
</li>
<li>!SQL_PARSER<br>
sqlCommentParseEnabled: true<br>
sqlStatementCache:<br>
initialCapacity: 2000<br>
maximumSize: 65535<br>
concurrencyLevel: 4<br>
parseTreeCache:<br>
initialCapacity: 128<br>
maximumSize: 1024<br>
concurrencyLevel: 4<br>
props:<br>
max-connections-size-per-query: 1<br>
kernel-executor-size: 16<br>
proxy-frontend-flush-threshold: 128<br>
proxy-opentracing-enabled: false<br>
proxy-hint-enabled: false<br>
sql-show: true<br>
check-table-metadata-enabled: false<br>
show-process-list-enabled: false<br>
proxy-backend-query-fetch-size: -1<br>
check-duplicate-table-enabled: false<br>
proxy-frontend-executor-size: 0<br>
proxy-backend-executor-suitable: OLAP<br>
proxy-frontend-max-connections: 0 # Less than or equal to 0 means no limitation.<br>
sql-federation-enabled: false<br>
proxy-backend-driver-type: JDBC</li>
</ul>
<hr>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/16077783/163531912-e37b0634-45e4-4d26-beb6-9943953d97b1.png"><img src="https://user-images.githubusercontent.com/16077783/163531912-e37b0634-45e4-4d26-beb6-9943953d97b1.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Example codes for reproduce this issue (such as a github link).</h3>