From 2fe86aee755a74c81b5978a5a6b7e17628753ff5 Mon Sep 17 00:00:00 2001 From: Haoran Meng Date: Fri, 27 Dec 2024 17:24:47 +0800 Subject: [PATCH] Only delete versions smaller than the current active version --- .../persist/service/version/MetaDataVersionPersistService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/version/MetaDataVersionPersistService.java b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/version/MetaDataVersionPersistService.java index 7e7820493e43b..ea7a36d1800ed 100644 --- a/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/version/MetaDataVersionPersistService.java +++ b/kernel/metadata/core/src/main/java/org/apache/shardingsphere/metadata/persist/service/version/MetaDataVersionPersistService.java @@ -43,7 +43,7 @@ public void switchActiveVersion(final Collection metaDataVersio } repository.persist(each.getActiveVersionNodePath(), each.getNextActiveVersion()); getVersions(each.getVersionsPath()).stream() - .filter(version -> !version.equals(each.getNextActiveVersion())) + .filter(version -> Integer.parseInt(version) < Integer.parseInt(each.getNextActiveVersion())) .forEach(version -> repository.delete(each.getVersionsNodePath(version))); } }