diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/ClusterMetaDataManagerPersistService.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/ClusterMetaDataManagerPersistService.java index c2da0ec039206..38d026812dceb 100644 --- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/ClusterMetaDataManagerPersistService.java +++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/persist/ClusterMetaDataManagerPersistService.java @@ -125,7 +125,7 @@ public void registerStorageUnits(final String databaseName, final Map getToBeDroppedResourceNames(final String databaseName return toBeDroppedResourceNames.stream().filter(propsMap::containsKey).collect(Collectors.toList()); } - private void afterStorageUnitsAltered(final String databaseName, final MetaDataContexts originalMetaDataContexts, final MetaDataContexts reloadMetaDataContexts) { - reloadMetaDataContexts.getMetaData().getDatabase(databaseName).getAllSchemas().forEach(each -> metaDataPersistService.getDatabaseMetaDataFacade() - .getSchema().alterByRuleAltered(reloadMetaDataContexts.getMetaData().getDatabase(databaseName).getName(), each)); + private void afterStorageUnitsRegistered(final String databaseName, final MetaDataContexts originalMetaDataContexts, final MetaDataContexts reloadMetaDataContexts) { Optional.ofNullable(reloadMetaDataContexts.getStatistics().getDatabaseData().get(databaseName)) .ifPresent(optional -> optional.getSchemaData().forEach((schemaName, schemaData) -> metaDataPersistService.getShardingSphereDataPersistService() .persist(originalMetaDataContexts.getMetaData().getDatabase(databaseName), schemaName, schemaData))); @@ -189,6 +187,12 @@ private void afterStorageUnitsAltered(final String databaseName, final MetaDataC originalMetaDataContexts.getMetaData().getDatabase(databaseName)); } + private void afterStorageUnitsAltered(final String databaseName, final MetaDataContexts originalMetaDataContexts, final MetaDataContexts reloadMetaDataContexts) { + reloadMetaDataContexts.getMetaData().getDatabase(databaseName).getAllSchemas().forEach(each -> metaDataPersistService.getDatabaseMetaDataFacade() + .getSchema().alterByRuleAltered(reloadMetaDataContexts.getMetaData().getDatabase(databaseName).getName(), each)); + afterStorageUnitsRegistered(databaseName, originalMetaDataContexts, reloadMetaDataContexts); + } + private void afterStorageUnitsDropped(final String databaseName, final MetaDataContexts originalMetaDataContexts, final MetaDataContexts reloadMetaDataContexts) { reloadMetaDataContexts.getMetaData().getDatabase(databaseName).getAllSchemas().forEach(each -> metaDataPersistService.getDatabaseMetaDataFacade() .getSchema().alterByRuleDropped(reloadMetaDataContexts.getMetaData().getDatabase(databaseName).getName(), each));