You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2025/06/27 11:08:28 UTC
(shardingsphere) branch master updated: Fix error when modifying the collection while iterating it in StatisticsStorageEngine (#35806)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 a48d861f16a Fix error when modifying the collection while iterating it in StatisticsStorageEngine (#35806)
a48d861f16a is described below
commit a48d861f16a2e3c2ee76c39e5f20f85bc26cc36b
Author: jiangML <10...@qq.com>
AuthorDate: Fri Jun 27 19:08:23 2025 +0800
Fix error when modifying the collection while iterating it in StatisticsStorageEngine (#35806)
* Fix error when modifying the collection while iterating it in StatisticsStorageEngine
* Optimize StatisticsStorageEngine
---
.../manager/cluster/statistics/StatisticsStorageEngine.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/statistics/StatisticsStorageEngine.java b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/statistics/StatisticsStorageEngine.java
index f0d8ade0c7d..eabd6698c30 100644
--- a/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/statistics/StatisticsStorageEngine.java
+++ b/mode/type/cluster/core/src/main/java/org/apache/shardingsphere/mode/manager/cluster/statistics/StatisticsStorageEngine.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -66,19 +67,18 @@ public final class StatisticsStorageEngine {
}
private TableStatistics getCurrentTableStatistics() {
+ TableStatistics result = new TableStatistics(tableName);
ShardingSphereStatistics currentStatistics = contextManager.getMetaDataContexts().getStatistics();
if (!currentStatistics.containsDatabaseStatistics(databaseName)) {
- return new TableStatistics(tableName);
+ return result;
}
DatabaseStatistics databaseStatistics = currentStatistics.getDatabaseStatistics(databaseName);
if (!databaseStatistics.containsSchemaStatistics(schemaName)) {
- return new TableStatistics(tableName);
+ return result;
}
SchemaStatistics schemaStatistics = databaseStatistics.getSchemaStatistics(schemaName);
- if (!schemaStatistics.containsTableStatistics(tableName)) {
- return new TableStatistics(tableName);
- }
- return schemaStatistics.getTableStatistics(tableName);
+ Optional.ofNullable(schemaStatistics.getTableStatistics(tableName)).ifPresent(optional -> result.getRows().addAll(optional.getRows()));
+ return result;
}
private AlteredDatabaseStatistics createAlteredDatabaseStatistics(final ShardingSphereTable table, final TableStatistics currentTableStatistics, final TableStatistics changedTableStatistics) {