From 6c23e9a5a89dfb9aa8cff778609fcc5a7bfc0d6c Mon Sep 17 00:00:00 2001 From: Lucian <943071074@qq.com> Date: Wed, 8 Feb 2023 14:58:41 +0800 Subject: [PATCH] fix app revision clean bug (#276) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 江村 --- VERSION | 2 +- client/all/pom.xml | 2 +- client/api/pom.xml | 2 +- client/impl/pom.xml | 2 +- client/log/pom.xml | 2 +- client/pom.xml | 2 +- core/pom.xml | 2 +- pom.xml | 2 +- server/common/model/pom.xml | 2 +- server/common/pom.xml | 2 +- server/common/util/pom.xml | 2 +- server/distribution/all/pom.xml | 2 +- server/distribution/pom.xml | 2 +- server/pom.xml | 2 +- server/remoting/api/pom.xml | 2 +- server/remoting/bolt/pom.xml | 2 +- server/remoting/http/pom.xml | 2 +- server/remoting/pom.xml | 2 +- server/server/data/pom.xml | 2 +- server/server/integration/pom.xml | 2 +- server/server/meta/pom.xml | 2 +- .../meta/cleaner/AppRevisionCleaner.java | 44 +++++++++++++++++-- .../meta/cleaner/AppRevisionCleanerTest.java | 7 +++ server/server/pom.xml | 2 +- server/server/session/pom.xml | 2 +- server/server/shared/pom.xml | 2 +- server/store/api/pom.xml | 2 +- server/store/jdbc/pom.xml | 2 +- server/store/jraft/pom.xml | 2 +- server/store/pom.xml | 2 +- test/pom.xml | 2 +- 31 files changed, 77 insertions(+), 32 deletions(-) diff --git a/VERSION b/VERSION index 1dd8be08f..2597c9909 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.1.8 +6.1.9 diff --git a/client/all/pom.xml b/client/all/pom.xml index 3365e8eda..cd649f5e7 100644 --- a/client/all/pom.xml +++ b/client/all/pom.xml @@ -6,7 +6,7 @@ com.alipay.sofa registry-client-all - 6.1.8 + 6.1.9 ${project.groupId}:${project.artifactId} http://github.com/alipay/sofa-registry diff --git a/client/api/pom.xml b/client/api/pom.xml index 568f4f7f5..ffa752e67 100644 --- a/client/api/pom.xml +++ b/client/api/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-client-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/client/impl/pom.xml b/client/impl/pom.xml index dbea3a627..3d32b60ad 100644 --- a/client/impl/pom.xml +++ b/client/impl/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-client-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/client/log/pom.xml b/client/log/pom.xml index ec291986f..92a7b7c48 100644 --- a/client/log/pom.xml +++ b/client/log/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-client-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/client/pom.xml b/client/pom.xml index 69bcd69ee..5e1372243 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -7,7 +7,7 @@ com.alipay.sofa registry-parent - 6.1.8 + 6.1.9 ../pom.xml diff --git a/core/pom.xml b/core/pom.xml index 91b68b9af..85c373a52 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index f1880c48c..b15ed91dd 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.alipay.sofa registry-parent - 6.1.8 + 6.1.9 pom ${project.groupId}:${project.artifactId} diff --git a/server/common/model/pom.xml b/server/common/model/pom.xml index 324b161db..37437abfe 100644 --- a/server/common/model/pom.xml +++ b/server/common/model/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-common - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/common/pom.xml b/server/common/pom.xml index 315969598..1a6617a8b 100644 --- a/server/common/pom.xml +++ b/server/common/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-server-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/common/util/pom.xml b/server/common/util/pom.xml index 97640bf4a..4fe142164 100644 --- a/server/common/util/pom.xml +++ b/server/common/util/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-common - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/distribution/all/pom.xml b/server/distribution/all/pom.xml index ef943630b..e0eeda810 100644 --- a/server/distribution/all/pom.xml +++ b/server/distribution/all/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-distribution - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/distribution/pom.xml b/server/distribution/pom.xml index 05b5f01e2..45793b35b 100644 --- a/server/distribution/pom.xml +++ b/server/distribution/pom.xml @@ -6,7 +6,7 @@ com.alipay.sofa registry-server-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/pom.xml b/server/pom.xml index 60f6695c8..451d88f4e 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -7,7 +7,7 @@ com.alipay.sofa registry-parent - 6.1.8 + 6.1.9 ../pom.xml diff --git a/server/remoting/api/pom.xml b/server/remoting/api/pom.xml index a569c2b27..568349a2c 100644 --- a/server/remoting/api/pom.xml +++ b/server/remoting/api/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-remoting - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/remoting/bolt/pom.xml b/server/remoting/bolt/pom.xml index 66cacd611..d5174a7c1 100644 --- a/server/remoting/bolt/pom.xml +++ b/server/remoting/bolt/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-remoting - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/remoting/http/pom.xml b/server/remoting/http/pom.xml index f2e5cd39f..6e2615798 100644 --- a/server/remoting/http/pom.xml +++ b/server/remoting/http/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-remoting - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/remoting/pom.xml b/server/remoting/pom.xml index faf893233..466ebb203 100644 --- a/server/remoting/pom.xml +++ b/server/remoting/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-server-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/server/data/pom.xml b/server/server/data/pom.xml index ea9e66720..5892f94da 100644 --- a/server/server/data/pom.xml +++ b/server/server/data/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-server - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/server/integration/pom.xml b/server/server/integration/pom.xml index b20f3ab6c..53de71635 100644 --- a/server/server/integration/pom.xml +++ b/server/server/integration/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-server - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/server/meta/pom.xml b/server/server/meta/pom.xml index fb853beae..8bdb65af0 100644 --- a/server/server/meta/pom.xml +++ b/server/server/meta/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-server - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleaner.java b/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleaner.java index 1de6f29ad..e6a330f39 100644 --- a/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleaner.java +++ b/server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleaner.java @@ -16,6 +16,7 @@ */ package com.alipay.sofa.registry.server.meta.cleaner; +import com.alipay.remoting.util.StringUtils; import com.alipay.sofa.registry.cache.ConsecutiveSuccess; import com.alipay.sofa.registry.common.model.console.PersistenceData; import com.alipay.sofa.registry.common.model.console.PersistenceDataBuilder; @@ -24,6 +25,7 @@ import com.alipay.sofa.registry.common.model.metaserver.cleaner.AppRevisionSliceRequest; import com.alipay.sofa.registry.common.model.store.AppRevision; import com.alipay.sofa.registry.jdbc.config.MetadataConfig; +import com.alipay.sofa.registry.jdbc.convertor.AppRevisionDomainConvertor; import com.alipay.sofa.registry.log.Logger; import com.alipay.sofa.registry.log.LoggerFactory; import com.alipay.sofa.registry.server.meta.MetaLeaderService; @@ -35,6 +37,7 @@ import com.alipay.sofa.registry.store.api.date.DateNowRepository; import com.alipay.sofa.registry.store.api.repository.AppRevisionRepository; import com.alipay.sofa.registry.util.ConcurrentUtils; +import com.alipay.sofa.registry.util.JsonUtils; import com.alipay.sofa.registry.util.StringFormatter; import com.alipay.sofa.registry.util.WakeUpLoopRunnable; import com.google.common.collect.Lists; @@ -143,11 +146,46 @@ void markDeleted() { appRevisionRepository.getExpired( dateBeforeNow(metadataConfig.getRevisionRenewIntervalMinutes() * 5), metaServerConfig.getAppRevisionMaxRemove()); + // before markDeleted refresh app revision switch + appRevisionSwitchRefresh(); for (AppRevision revision : expired) { revision.setDeleted(true); - appRevisionRepository.replace(revision); - LOG.info("mark deleted revision: {}", revision.getRevision()); - ConcurrentUtils.sleepUninterruptibly(10, TimeUnit.MILLISECONDS); + try { + appRevisionRepository.replace(revision); + LOG.info("mark deleted revision: {}", revision.getRevision()); + ConcurrentUtils.sleepUninterruptibly(10, TimeUnit.MILLISECONDS); + } catch (Throwable e) { + LOG.error("mark deleted revision failed: {}", revision.getRevision(), e); + } + } + } + + private void appRevisionSwitchRefresh() { + DBResponse ret = + provideDataService.queryProvideData(ValueConstants.APP_REVISION_WRITE_SWITCH_DATA_ID); + AppRevisionDomainConvertor.EnableConfig enableConfig = null; + if (ret.getOperationStatus() == OperationStatus.SUCCESS) { + PersistenceData data = ret.getEntity(); + String switchString = data.getData(); + if (StringUtils.isNotBlank(switchString)) { + try { + enableConfig = + JsonUtils.read(switchString, AppRevisionDomainConvertor.EnableConfig.class); + } catch (Throwable e) { + LOG.error("Decode appRevision write switch failed", e); + } + } + } + if (enableConfig != null) { + LOG.info( + "appRevisionSwitch prev={}/{}", + AppRevisionDomainConvertor.getEnableConfig().isServiceParams(), + AppRevisionDomainConvertor.getEnableConfig().isServiceParamsLarge()); + AppRevisionDomainConvertor.setEnableConfig(enableConfig); + LOG.info( + "appRevisionSwitch update={}/{}", + enableConfig.isServiceParams(), + enableConfig.isServiceParamsLarge()); } } diff --git a/server/server/meta/src/test/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleanerTest.java b/server/server/meta/src/test/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleanerTest.java index 47db73b7b..75351fa5c 100644 --- a/server/server/meta/src/test/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleanerTest.java +++ b/server/server/meta/src/test/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleanerTest.java @@ -67,6 +67,13 @@ public void beforeTest() throws Exception { .when(appRevisionCleaner.provideDataService) .queryProvideData(anyString()); // doReturn(new DateNowDomain(new Date())).when(appRevisionCleaner.appRevisionMapper).getNow(); + doReturn( + new DBResponse<>( + PersistenceDataBuilder.createPersistenceData( + ValueConstants.APP_REVISION_WRITE_SWITCH_DATA_ID, "{\"serviceParams\":false,\"serviceParamsLarge\":true}"), + OperationStatus.SUCCESS)) + .when(appRevisionCleaner.provideDataService) + .queryProvideData(anyString()); } @After diff --git a/server/server/pom.xml b/server/server/pom.xml index e39c0abb5..12e34d193 100644 --- a/server/server/pom.xml +++ b/server/server/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-server-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/server/session/pom.xml b/server/server/session/pom.xml index 5a772a1ab..efbfd1ea3 100644 --- a/server/server/session/pom.xml +++ b/server/server/session/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-server - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/server/shared/pom.xml b/server/server/shared/pom.xml index b12f18c26..ad8455844 100644 --- a/server/server/shared/pom.xml +++ b/server/server/shared/pom.xml @@ -5,7 +5,7 @@ registry-server com.alipay.sofa - 6.1.8 + 6.1.9 4.0.0 diff --git a/server/store/api/pom.xml b/server/store/api/pom.xml index 1a215c299..09636ccf7 100644 --- a/server/store/api/pom.xml +++ b/server/store/api/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-store - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/server/store/jdbc/pom.xml b/server/store/jdbc/pom.xml index 425a03683..3d5ff24c5 100644 --- a/server/store/jdbc/pom.xml +++ b/server/store/jdbc/pom.xml @@ -6,7 +6,7 @@ com.alipay.sofa registry-store - 6.1.8 + 6.1.9 ../pom.xml diff --git a/server/store/jraft/pom.xml b/server/store/jraft/pom.xml index b859684dd..bad8bda4f 100644 --- a/server/store/jraft/pom.xml +++ b/server/store/jraft/pom.xml @@ -6,7 +6,7 @@ com.alipay.sofa registry-store - 6.1.8 + 6.1.9 ../pom.xml diff --git a/server/store/pom.xml b/server/store/pom.xml index 0ceb73355..12197c5bd 100644 --- a/server/store/pom.xml +++ b/server/store/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-server-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0 diff --git a/test/pom.xml b/test/pom.xml index 78402973e..407791188 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -5,7 +5,7 @@ com.alipay.sofa registry-parent - 6.1.8 + 6.1.9 ../pom.xml 4.0.0