You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/02/24 08:59:41 UTC
[GitHub] [incubator-shardingsphere] nevereverever opened a new issue #4443:
ShardingProxy Read / write separation cannot supporte transaction?
nevereverever opened a new issue #4443: ShardingProxy Read / write separation cannot supporte transaction?
URL: https://github.com/apache/incubator-shardingsphere/issues/4443
In ShardingSphere Introduce,"If there is write operation in the same thread and database connection, all the following read operations are from the master database to ensure data consistency.
".
But I verified Read/write separation,I can't read my data after ddl in common transaction.I tried command line and using program with Spring @Transactional. Sharding Proxy version is 4.0.0
1.This is my configuration:
```yaml
schemaName: sharding_db
dataSources:
ds_0:
url: jdbc:mysql://192.168.133.15:3306/demo_1?serverTimezone=UTC&useSSL=false
username: pcloud
password: pcloud
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
ds_0_slave:
url: jdbc:mysql://192.168.133.15:3306/demo_1_slave?serverTimezone=UTC&useSSL=false
username: pcloud
password: pcloud
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
ds_1:
url: jdbc:mysql://192.168.133.15:3306/demo_2?serverTimezone=UTC&useSSL=false
username: pcloud
password: pcloud
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
ds_1_slave:
url: jdbc:mysql://192.168.133.15:3306/demo_2_slave?serverTimezone=UTC&useSSL=false
username: pcloud
password: pcloud
connectionTimeoutMilliseconds: 30000
idleTimeoutMilliseconds: 60000
maxLifetimeMilliseconds: 1800000
maxPoolSize: 50
shardingRule:
tables:
tbperson:
actualDataNodes: ms_ds${0..1}.tbperson
databaseStrategy:
standard:
shardingColumn: person_id
preciseAlgorithmClassName: org.apache.shardingsphere.api.sharding.impl.HashShardingAlgorithm
defaultDatabaseStrategy:
none:
defaultTableStrategy:
none:
masterSlaveRules:
ms_ds0:
masterDataSourceName: ds_0
slaveDataSourceNames:
- ds_0_slave
loadBalanceAlgorithmType: ROUND_ROBIN
ms_ds1:
masterDataSourceName: ds_1
slaveDataSourceNames:
- ds_1_slave
loadBalanceAlgorithmType: ROUND_ROBIN
```
2.table data
database name: demo_1
----------------
person_id |name| last_update_time |account
---|---|----|---
2|wanger|2020-02-24|1000
database name: demo_1_slave
----------------
person_id |name| last_update_time |account
---|---|----|---
4|lisi|2020-02-24|1000
database name: demo_2
----------------
person_id |name| last_update_time |account
---|---|----|---
1|hello|2020-02-24|1000
database name: demo_2_slave
----------------
person_id |name| last_update_time |account
---|---|----|---
3|zhangsan|2020-02-24|1000
3.In common transaction,I select all data from tbperson:
----------------
person_id |name| last_update_time |account
---|---|----|---
4|lisi|2020-02-24|1000
3|zhangsan|2020-02-24|1000
that's right.
then, insert to this table:
```sql
insert into tbperson(person_id,name,last_update_time,account) values ('14','luyang',now(),10000)
> Affected rows: 1
> 时间: 0.347s
```
finally,select all data from tbperson:
----------------
person_id |name| last_update_time |account
---|---|----|---
4|lisi|2020-02-24|1000
3|zhangsan|2020-02-24|1000
not this data:
----------------
person_id |name| last_update_time |account
---|---|----|---
14|luyang|2020-02-24|10000
My question is why I can't get the right data?
I looked up some issue,some one said that this only can be use in sharding-jdbc?The others said we must use hint?I wonder if that's true.
If it is not support now,will it be supported in future versions?
Thank you.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] terrymanu closed issue #4443:
ShardingProxy Read / write separation cannot support transaction?
Posted by GitBox <gi...@apache.org>.
terrymanu closed issue #4443: ShardingProxy Read / write separation cannot support transaction?
URL: https://github.com/apache/incubator-shardingsphere/issues/4443
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] terrymanu commented on issue #4443:
ShardingProxy Read / write separation cannot support transaction?
Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #4443: ShardingProxy Read / write separation cannot support transaction?
URL: https://github.com/apache/incubator-shardingsphere/issues/4443#issuecomment-590632706
The proposal of read-write split is using data consistence to exchange performance improvement. Using transaction in write is OK, but use transaction with read and write is not good practice.
We need to add description to doc, do you interest in this issue?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] terrymanu commented on issue #4443:
ShardingProxy Read / write separation cannot support transaction?
Posted by GitBox <gi...@apache.org>.
terrymanu commented on issue #4443: ShardingProxy Read / write separation cannot support transaction?
URL: https://github.com/apache/incubator-shardingsphere/issues/4443#issuecomment-590633528
FIY #4455
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
[GitHub] [incubator-shardingsphere] terrymanu edited a comment on issue
#4443: ShardingProxy Read / write separation cannot support transaction?
Posted by GitBox <gi...@apache.org>.
terrymanu edited a comment on issue #4443: ShardingProxy Read / write separation cannot support transaction?
URL: https://github.com/apache/incubator-shardingsphere/issues/4443#issuecomment-590632706
The proposal of read-write split is using data consistence to exchange performance improvement. Using transaction in write node only is OK, but using transaction with read and write together is not good practice.
We need to add description to doc, do you interest in this issue?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services