shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

When sharding proxy and SQL hint are used for database splitting, does the read-write separation configuration not take effect?

Open ykjxx opened this issue 3 years ago • 3 comments

problem:When sharding proxy and SQL hint are used for database splitting, does the read-write separation configuration not take effect? environment:shardingproxy-5.1.2,mysql5.7 What should I do if I want to use hint and read / write split config at the same time?

ykjxx avatar Aug 09 '22 08:08 ykjxx

Hi @ykjxx Please describe your configuration and operation, what is the expectation and what is the actual performance? So that someone can help you analyze the cause of the problem.

It is best to use the issue template to ask questions.

RaigorJiang avatar Aug 09 '22 13:08 RaigorJiang

Hi @RaigorJiang my config: image

[db1, replica1] and [DB2, replica2] are two groups of master-slave Databases. I hope to route these two groups of Databases through Hin SQL and realize read-write separation excute-sql: /* ShardingSphere hint: dataSourceName=db_2 */ select * from sm_project_img; expect: It is expected that the above SQL execute on the slave dabatase(replica_2)

actual: this sql execute on the master database(db_2)

In this case,If I use distsql to set hint value, the READWRITE_SPLITTING-strategy can take effect; for example:Execute first ”set sharding hint database_value=db_2", then execute "select * from XX",The query statement is executed from the slave database(replica_2), However, this distsql cannot guarantee thread safety in the multithreading environment of the same application,Is there a two pronged approach?

ykjxx avatar Aug 10 '22 02:08 ykjxx

Two risks:

  1. Your readwrite-splitting group names and the original resource names are duplicated, which may lead to deviation
  2. The way of SQL HINT to dataSourceName has been removed from the master, so it is best not to use it, otherwise the subsequent upgrade will not be possible.

RaigorJiang avatar Aug 10 '22 12:08 RaigorJiang

Hello , this issue has not received a reply for several days. This issue is supposed to be closed.

github-actions[bot] avatar Oct 08 '22 16:10 github-actions[bot]

Closed due to no reply for a long time.

RaigorJiang avatar Oct 14 '22 05:10 RaigorJiang