Skip to content

Commit 6c23e9a

Browse files
huanglongchao江村
and
江村
authored
fix app revision clean bug (#276)
Co-authored-by: 江村 <[email protected]>
1 parent fce2785 commit 6c23e9a

File tree

31 files changed

+77
-32
lines changed

31 files changed

+77
-32
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.1.8
1+
6.1.9

client/all/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.alipay.sofa</groupId>
88
<artifactId>registry-client-all</artifactId>
9-
<version>6.1.8</version>
9+
<version>6.1.9</version>
1010

1111
<name>${project.groupId}:${project.artifactId}</name>
1212
<url>http://github.com/alipay/sofa-registry</url>

client/api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-client-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

client/impl/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-client-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

client/log/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-client-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

client/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.alipay.sofa</groupId>
99
<artifactId>registry-parent</artifactId>
10-
<version>6.1.8</version>
10+
<version>6.1.9</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<modelVersion>4.0.0</modelVersion>
77
<groupId>com.alipay.sofa</groupId>
88
<artifactId>registry-parent</artifactId>
9-
<version>6.1.8</version>
9+
<version>6.1.9</version>
1010
<packaging>pom</packaging>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>

server/common/model/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-common</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/common/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-server-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/common/util/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-common</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/distribution/all/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-distribution</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/distribution/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa</groupId>
88
<artifactId>registry-server-parent</artifactId>
9-
<version>6.1.8</version>
9+
<version>6.1.9</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212
<modelVersion>4.0.0</modelVersion>

server/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.alipay.sofa</groupId>
99
<artifactId>registry-parent</artifactId>
10-
<version>6.1.8</version>
10+
<version>6.1.9</version>
1111
<relativePath>../pom.xml</relativePath>
1212
</parent>
1313

server/remoting/api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-remoting</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/remoting/bolt/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-remoting</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/remoting/http/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-remoting</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/remoting/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-server-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/server/data/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-server</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/server/integration/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-server</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/server/meta/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-server</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/server/meta/src/main/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleaner.java

+41-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package com.alipay.sofa.registry.server.meta.cleaner;
1818

19+
import com.alipay.remoting.util.StringUtils;
1920
import com.alipay.sofa.registry.cache.ConsecutiveSuccess;
2021
import com.alipay.sofa.registry.common.model.console.PersistenceData;
2122
import com.alipay.sofa.registry.common.model.console.PersistenceDataBuilder;
@@ -24,6 +25,7 @@
2425
import com.alipay.sofa.registry.common.model.metaserver.cleaner.AppRevisionSliceRequest;
2526
import com.alipay.sofa.registry.common.model.store.AppRevision;
2627
import com.alipay.sofa.registry.jdbc.config.MetadataConfig;
28+
import com.alipay.sofa.registry.jdbc.convertor.AppRevisionDomainConvertor;
2729
import com.alipay.sofa.registry.log.Logger;
2830
import com.alipay.sofa.registry.log.LoggerFactory;
2931
import com.alipay.sofa.registry.server.meta.MetaLeaderService;
@@ -35,6 +37,7 @@
3537
import com.alipay.sofa.registry.store.api.date.DateNowRepository;
3638
import com.alipay.sofa.registry.store.api.repository.AppRevisionRepository;
3739
import com.alipay.sofa.registry.util.ConcurrentUtils;
40+
import com.alipay.sofa.registry.util.JsonUtils;
3841
import com.alipay.sofa.registry.util.StringFormatter;
3942
import com.alipay.sofa.registry.util.WakeUpLoopRunnable;
4043
import com.google.common.collect.Lists;
@@ -143,11 +146,46 @@ void markDeleted() {
143146
appRevisionRepository.getExpired(
144147
dateBeforeNow(metadataConfig.getRevisionRenewIntervalMinutes() * 5),
145148
metaServerConfig.getAppRevisionMaxRemove());
149+
// before markDeleted refresh app revision switch
150+
appRevisionSwitchRefresh();
146151
for (AppRevision revision : expired) {
147152
revision.setDeleted(true);
148-
appRevisionRepository.replace(revision);
149-
LOG.info("mark deleted revision: {}", revision.getRevision());
150-
ConcurrentUtils.sleepUninterruptibly(10, TimeUnit.MILLISECONDS);
153+
try {
154+
appRevisionRepository.replace(revision);
155+
LOG.info("mark deleted revision: {}", revision.getRevision());
156+
ConcurrentUtils.sleepUninterruptibly(10, TimeUnit.MILLISECONDS);
157+
} catch (Throwable e) {
158+
LOG.error("mark deleted revision failed: {}", revision.getRevision(), e);
159+
}
160+
}
161+
}
162+
163+
private void appRevisionSwitchRefresh() {
164+
DBResponse<PersistenceData> ret =
165+
provideDataService.queryProvideData(ValueConstants.APP_REVISION_WRITE_SWITCH_DATA_ID);
166+
AppRevisionDomainConvertor.EnableConfig enableConfig = null;
167+
if (ret.getOperationStatus() == OperationStatus.SUCCESS) {
168+
PersistenceData data = ret.getEntity();
169+
String switchString = data.getData();
170+
if (StringUtils.isNotBlank(switchString)) {
171+
try {
172+
enableConfig =
173+
JsonUtils.read(switchString, AppRevisionDomainConvertor.EnableConfig.class);
174+
} catch (Throwable e) {
175+
LOG.error("Decode appRevision write switch failed", e);
176+
}
177+
}
178+
}
179+
if (enableConfig != null) {
180+
LOG.info(
181+
"appRevisionSwitch prev={}/{}",
182+
AppRevisionDomainConvertor.getEnableConfig().isServiceParams(),
183+
AppRevisionDomainConvertor.getEnableConfig().isServiceParamsLarge());
184+
AppRevisionDomainConvertor.setEnableConfig(enableConfig);
185+
LOG.info(
186+
"appRevisionSwitch update={}/{}",
187+
enableConfig.isServiceParams(),
188+
enableConfig.isServiceParamsLarge());
151189
}
152190
}
153191

server/server/meta/src/test/java/com/alipay/sofa/registry/server/meta/cleaner/AppRevisionCleanerTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ public void beforeTest() throws Exception {
6767
.when(appRevisionCleaner.provideDataService)
6868
.queryProvideData(anyString());
6969
// doReturn(new DateNowDomain(new Date())).when(appRevisionCleaner.appRevisionMapper).getNow();
70+
doReturn(
71+
new DBResponse<>(
72+
PersistenceDataBuilder.createPersistenceData(
73+
ValueConstants.APP_REVISION_WRITE_SWITCH_DATA_ID, "{\"serviceParams\":false,\"serviceParamsLarge\":true}"),
74+
OperationStatus.SUCCESS))
75+
.when(appRevisionCleaner.provideDataService)
76+
.queryProvideData(anyString());
7077
}
7178

7279
@After

server/server/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-server-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/server/session/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-server</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/server/shared/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>registry-server</artifactId>
77
<groupId>com.alipay.sofa</groupId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

server/store/api/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-store</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

server/store/jdbc/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa</groupId>
88
<artifactId>registry-store</artifactId>
9-
<version>6.1.8</version>
9+
<version>6.1.9</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

server/store/jraft/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.alipay.sofa</groupId>
88
<artifactId>registry-store</artifactId>
9-
<version>6.1.8</version>
9+
<version>6.1.9</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

server/store/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-server-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

test/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.alipay.sofa</groupId>
77
<artifactId>registry-parent</artifactId>
8-
<version>6.1.8</version>
8+
<version>6.1.9</version>
99
<relativePath>../pom.xml</relativePath>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>

0 commit comments

Comments
 (0)