when max.connections.size.per.query is greater than 1, uncommitted records may not been visiable when we execute query SQL in current transaction.
Sharding-Proxy Version: dev configuration: config-sharding.yaml
schemaName: sharding_db
dataSources:
ds_0:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_0?serverTimezone=UTC&useSSL=false
username: root
password:
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
ds_1:
url: jdbc:mysql://127.0.0.1:3306/demo_ds_1?serverTimezone=UTC&useSSL=false
username: root
password:
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
shardingRule:
tables:
t_order:
actualDataNodes: ds_${0..1}.t_order_${0..1}
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_${order_id % 2}
keyGenerator:
type: SNOWFLAKE
column: order_id
t_order_item:
actualDataNodes: ds_${0..1}.t_order_item_${0..1}
tableStrategy:
inline:
shardingColumn: order_id
algorithmExpression: t_order_item_${order_id % 2}
keyGenerator:
type: SNOWFLAKE
column: order_item_id
bindingTables:
- t_order,t_order_item
broadcastTables:
- t_address
defaultDatabaseStrategy:
inline:
shardingColumn: user_id
algorithmExpression: ds_${user_id % 2}
defaultTableStrategy:
none:
server.yaml when max.connections.size.per.query=1
authentication:
users:
root:
password:
sharding:
password: sharding
authorizedSchemas: sharding_db
props:
max.connections.size.per.query: 1
acceptor.size: 16 # The default value is available processors count * 2.
executor.size: 16 # Infinite by default.
proxy.frontend.flush.threshold: 128 # The default value is 128.
# LOCAL: Proxy will run with LOCAL transaction.
# XA: Proxy will run with XA transaction.
# BASE: Proxy will run with B.A.S.E transaction.
proxy.transaction.type: LOCAL
proxy.opentracing.enabled: false
query.with.cipher.column: true
sql.show: false
print result:
---------------------------- Print Order Data -----------------------
order_id: 412075829204353025, user_id: 2, address_id: 2, status: INSERT_TEST
order_id: 412075829279850497, user_id: 4, address_id: 4, status: INSERT_TEST
order_id: 412075829330182145, user_id: 6, address_id: 6, status: INSERT_TEST
order_id: 412075829384708097, user_id: 8, address_id: 8, status: INSERT_TEST
order_id: 412075829439234049, user_id: 10, address_id: 10, status: INSERT_TEST
order_id: 412075829162409984, user_id: 1, address_id: 1, status: INSERT_TEST
order_id: 412075829246296064, user_id: 3, address_id: 3, status: INSERT_TEST
order_id: 412075829300822016, user_id: 5, address_id: 5, status: INSERT_TEST
order_id: 412075829359542272, user_id: 7, address_id: 7, status: INSERT_TEST
order_id: 412075829414068224, user_id: 9, address_id: 9, status: INSERT_TEST
when max.connections.size.per.query>1,such as: max.connections.size.per.query:2 (The others configuration are the same)
print result:
---------------------------- Print Order Data -----------------------
order_id: 412072322820734976, user_id: 1, address_id: 1, status: INSERT_TEST
order_id: 412072323223388160, user_id: 3, address_id: 3, status: INSERT_TEST
order_id: 412072323273719808, user_id: 5, address_id: 5, status: INSERT_TEST
order_id: 412072323319857152, user_id: 7, address_id: 7, status: INSERT_TEST
order_id: 412072323365994496, user_id: 9, address_id: 9, status: INSERT_TEST
Run Example: You can click to view example
@geomonlin max.connections.size.per.query decides synchronized execute unit groups. What's your major question?
@geomonlin
max.connections.size.per.querydecides synchronized execute unit groups. What's your major question? differentmax.connections.size.per.querysize ,the number of rows printed is same but number of rows printed is different.
@SteNicholas I think @geomonlin means he got two different results by using two different configurations. Results are expected same no matter how configuration changed. This is a LOCAL Transaction scenario, maybe @cherrylzhao could help.
I have reproduce this problem in my local machine. when max.connections.size.per.query is greater than 1, uncommitted records may not been visiable when we execute query SQL in current transaction. the reason is that insert SQL will only cached one uncommitted connection in cache, but query SQL will get other connections which would not seen the transaction context. so we should add constraint in getting connection logic, when we start a transaction we should only get cached connections max.connections.size.per.query should be ignored here. also see #3015
Since this issue has been inactive for more than 1 year, we will close it. If you still have related questions, please submit a new issue, thank you.