{"record":{"id":"5ddcd7cee1287432","repo":"apache/shardingsphere","slug":"0","errorCode":"0","errorMessage":"Can not alter storage units '%s'.","messagePattern":"Can not alter storage units '(.+?)'\\.","errorType":"exception","errorClass":"StorageUnitsOperateException","httpStatus":null,"severity":"error","filePath":"infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/AlterStorageUnitExecutor.java","lineNumber":69,"sourceCode":"/**\n * Alter storage unit executor.\n */\n@Setter\npublic final class AlterStorageUnitExecutor implements DistSQLUpdateExecutor<AlterStorageUnitStatement>, DistSQLExecutorDatabaseAware {\n    \n    private final DistSQLDataSourcePoolPropertiesValidator validateHandler = new DistSQLDataSourcePoolPropertiesValidator();\n    \n    private ShardingSphereDatabase database;\n    \n    @Override\n    public void executeUpdate(final AlterStorageUnitStatement sqlStatement, final ContextManager contextManager) {\n        checkBefore(sqlStatement);\n        Map<String, DataSourcePoolProperties> propsMap = DataSourceSegmentsConverter.convert(database.getProtocolType(), sqlStatement.getStorageUnits());\n        validateHandler.validate(propsMap, getExpectedPrivileges(sqlStatement));\n        try {\n            contextManager.getPersistServiceFacade().getModeFacade().getMetaDataManagerService().alterStorageUnits(database, propsMap);\n        } catch (final ShardingSphereExternalException ex) {\n            throw new StorageUnitsOperateException(\"alter\", propsMap.keySet(), ex);\n        }\n    }\n    \n    private void checkBefore(final AlterStorageUnitStatement sqlStatement) {\n        Collection<String> toBeAlteredStorageUnitNames = sqlStatement.getStorageUnits().stream().map(DataSourceSegment::getName).collect(Collectors.toList());\n        checkDuplicatedStorageUnitNames(toBeAlteredStorageUnitNames);\n        checkStorageUnitNameExisted(toBeAlteredStorageUnitNames);\n        checkDatabase(sqlStatement);\n    }\n    \n    private void checkDuplicatedStorageUnitNames(final Collection<String> storageUnitNames) {\n        Collection<String> duplicatedStorageUnitNames = storageUnitNames.stream().filter(each -> storageUnitNames.stream().filter(each::equals).count() > 1L).collect(Collectors.toList());\n        ShardingSpherePreconditions.checkMustEmpty(duplicatedStorageUnitNames, () -> new DuplicateStorageUnitException(database.getName(), duplicatedStorageUnitNames));\n    }\n    \n    private void checkStorageUnitNameExisted(final Collection<String> storageUnitNames) {\n        Collection<String> notExistedStorageUnitNames = storageUnitNames.stream().filter(each -> !database.getResourceMetaData().getStorageUnits().containsKey(each)).collect(Collectors.toList());\n        ShardingSpherePreconditions.checkMustEmpty(notExistedStorageUnitNames, () -> new MissingRequiredStorageUnitsException(database.getName(), notExistedStorageUnitNames));","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/infra/distsql-handler/src/main/java/org/apache/shardingsphere/distsql/handler/executor/rdl/resource/AlterStorageUnitExecutor.java#L51-L87","documentation":"Error \"Can not alter storage units '%s'.\" thrown in apache/shardingsphere.","triggerScenarios":"ALTER STORAGE UNIT fails because the named storage units do not exist or their new configuration is invalid.","commonSituations":"Misspelled storage unit name or invalid JDBC properties supplied in a DistSQL ALTER STORAGE UNIT statement.","solutions":["Ensure the storage units exist before altering them (SHOW STORAGE UNITS).","Correct the storage unit names in the ALTER STORAGE UNIT statement.","Verify the new data source properties are valid so the alter can succeed."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}