This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new c23f8e1f9d3 Add filter DatabaseRule in alterRuleConfiguration method
to avoid clear datasources in TransactionRule (#29958)
c23f8e1f9d3 is described below
commit c23f8e1f9d33dae89b2cb074c1f1df375256674a
Author: Zhengqiang Duan <[email protected]>
AuthorDate: Fri Feb 2 11:53:15 2024 +0800
Add filter DatabaseRule in alterRuleConfiguration method to avoid clear
datasources in TransactionRule (#29958)
---
.../mode/manager/context/ConfigurationContextManager.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
index 84e98252063..dd124c44a4d 100644
---
a/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
+++
b/mode/core/src/main/java/org/apache/shardingsphere/mode/manager/context/ConfigurationContextManager.java
@@ -37,6 +37,7 @@ import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSp
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import
org.apache.shardingsphere.infra.rule.builder.database.DatabaseRulesBuilder;
import org.apache.shardingsphere.infra.rule.builder.global.GlobalRulesBuilder;
+import org.apache.shardingsphere.infra.rule.identifier.scope.DatabaseRule;
import org.apache.shardingsphere.infra.rule.identifier.type.ResourceHeldRule;
import org.apache.shardingsphere.metadata.factory.ExternalMetaDataFactory;
import org.apache.shardingsphere.metadata.factory.InternalMetaDataFactory;
@@ -151,7 +152,8 @@ public final class ConfigurationContextManager {
public synchronized void alterRuleConfiguration(final String databaseName,
final Collection<RuleConfiguration> ruleConfigs) {
try {
Collection<ResourceHeldRule> staleResourceHeldRules =
getStaleResourceHeldRules(databaseName);
-
staleResourceHeldRules.forEach(ResourceHeldRule::closeStaleResource);
+ // TODO consider rename this method to
alterDatabaseRuleConfiguration
+ staleResourceHeldRules.stream().filter(each -> each instanceof
DatabaseRule).forEach(ResourceHeldRule::closeStaleResource);
MetaDataContexts reloadMetaDataContexts =
createMetaDataContextsWhenRuleChanged(databaseName, false, null, ruleConfigs);
alterSchemaMetaData(databaseName,
reloadMetaDataContexts.getMetaData().getDatabase(databaseName),
metaDataContexts.get().getMetaData().getDatabase(databaseName));
metaDataContexts.set(reloadMetaDataContexts);