shardingsphere icon indicating copy to clipboard operation
shardingsphere copied to clipboard

can't use HintManager.getInstance().setMasterRouteOnly()

Open maxiaoxian opened this issue 7 years ago • 5 comments

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details. If no response more than 7 days and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

    4.0.0-RC2

Which project did you use? Sharding-JDBC or Sharding-Proxy?

    Sharding-JDBC

Expected behavior

   route to master

Actual behavior

  throw a exception : HintManagerHolder has previous value, please clear first. 

Reason analyze (If you can)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

// 读写分离配置 MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration("ds", "fcWriteDataSource", Arrays.asList("fcRead1DataSource", "fcRead2DataSource"));

    Set<MasterSlaveRuleConfiguration> masterSlaveRuleConfigurationSet = new HashSet<>();
    masterSlaveRuleConfigurationSet.add(masterSlaveRuleConfig);

    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
    shardingRuleConfig.setMasterSlaveRuleConfigs(masterSlaveRuleConfigurationSet);
    ...

Example codes for reproduce this issue (such as a github link).

maxiaoxian avatar Sep 26 '19 08:09 maxiaoxian

Perhaps you forget to close previous HintManager

terrymanu avatar Sep 26 '19 09:09 terrymanu

for example: HintManager.getInstance().setMasterRouteOnly(); final List list = list(wrapper); ...

then : thow Exception

but : before upgrade , it can route to master

Last version: 3.1.0

maxiaoxian avatar Sep 26 '19 09:09 maxiaoxian

for HintManager.getInstance() , in 4.0.0-RC2 version . add Preconditions.checkState for check . so,it need manual close or use try...catch... ?

maxiaoxian avatar Sep 26 '19 11:09 maxiaoxian

so,it need manual close or use try...catch... ?

Yes, you need manual close or use try with resource

terrymanu avatar Sep 26 '19 15:09 terrymanu

3q

maxiaoxian avatar Sep 27 '19 00:09 maxiaoxian