RaigorJiang commented on code in PR #19037:
URL: https://github.com/apache/shardingsphere/pull/19037#discussion_r918566284
##########
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/distsql/ral/common/updatable/ImportDatabaseConfigurationHandler.java:
##########
@@ -94,73 +93,84 @@ protected void update(final ContextManager contextManager)
throws DistSQLExcepti
String databaseName = yamlConfig.getDatabaseName();
checkDatabaseName(databaseName, file);
checkDataSource(yamlConfig.getDataSources(), file);
- updateResources(databaseName, yamlConfig.getDataSources());
- updateRules(databaseName, yamlConfig.getRules());
+ addDatabase(databaseName);
+ addResources(databaseName, yamlConfig.getDataSources());
+ try {
+ addRules(databaseName, yamlConfig.getRules());
+ } catch (DistSQLException ex) {
+ dropDatabase(databaseName);
+ throw ex;
+ }
}
private void checkDatabaseName(final String databaseName, final File file)
{
Preconditions.checkNotNull(databaseName, String.format("Property
`databaseName` in file `%s` is required.", file.getName()));
- if
(!ProxyContext.getInstance().getAllDatabaseNames().contains(databaseName)) {
- throw new DatabaseNotExistedException(databaseName);
+ if
(ProxyContext.getInstance().getAllDatabaseNames().contains(databaseName)) {
+
Preconditions.checkState(ProxyContext.getInstance().getDatabase(databaseName).getResource().getDataSources().isEmpty(),
"Database `%s` exists.", databaseName);
Review Comment:
The dataSources are checked here, but the message is 'Database `%s` exists',
which is not easy to understand.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]