Skip to content

Commit 5298884

Browse files
committedFeb 27, 2025·
Merge branch 'v1.3.3'
2 parents dcc929d + 742267b commit 5298884

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed
 

‎camellia-redis-proxy/camellia-redis-proxy-core/src/main/java/com/netease/nim/camellia/redis/proxy/upstream/kv/gc/KvGcExecutor.java

+15-7
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public class KvGcExecutor {
4343
private final KvConfig kvConfig;
4444
private final MpscSlotHashExecutor deleteExecutor;
4545
private final ThreadPoolExecutor submitExecutor;
46-
private final ScheduledThreadPoolExecutor scheduleExecutor;
46+
private final ScheduledThreadPoolExecutor scheduler;
47+
private final ThreadPoolExecutor scheduleExecutor;
4748
private RedisTemplate redisTemplate;
4849

4950
public KvGcExecutor(KVClient kvClient, KeyDesign keyDesign, KvConfig kvConfig) {
@@ -55,7 +56,9 @@ public KvGcExecutor(KVClient kvClient, KeyDesign keyDesign, KvConfig kvConfig) {
5556
kvConfig.gcExecutorQueueSize(), new MpscSlotHashExecutor.CallerRunsPolicy());
5657
this.submitExecutor = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS,
5758
new LinkedBlockingQueue<>(1024*128), new CamelliaThreadFactory("camellia-kv-gc-submit"), new ThreadPoolExecutor.AbortPolicy());
58-
this.scheduleExecutor = new ScheduledThreadPoolExecutor(1, new CamelliaThreadFactory("camellia-kv-gc-scheduler"));
59+
this.scheduler = new ScheduledThreadPoolExecutor(1, new CamelliaThreadFactory("camellia-kv-gc-scheduler"));
60+
this.scheduleExecutor = new ThreadPoolExecutor(2, 2, 0, TimeUnit.SECONDS,
61+
new LinkedBlockingQueue<>(32), new CamelliaThreadFactory("camellia-kv-gc-scheduler-executor"));
5962

6063
boolean gcScheduleEnable = ProxyDynamicConf.getBoolean("kv.gc.schedule.enable", false);
6164
if (gcScheduleEnable) {
@@ -74,7 +77,7 @@ public KvGcExecutor(KVClient kvClient, KeyDesign keyDesign, KvConfig kvConfig) {
7477
}
7578

7679
public void start() {
77-
scheduleExecutor.scheduleAtFixedRate(() -> {
80+
scheduler.scheduleAtFixedRate(() -> {
7881
try {
7982
boolean gcScheduleEnable = ProxyDynamicConf.getBoolean("kv.gc.schedule.enable", false);
8083
if (!gcScheduleEnable) {
@@ -95,12 +98,17 @@ public void start() {
9598
return;
9699
}
97100

98-
boolean scanMetaKeysSuccess = true;
101+
//meta-key scan
102+
Future<Boolean> metaKeyScanFuture;
99103
if (!kvClient.supportTTL()) {
100-
scanMetaKeysSuccess = scanMetaKeys();
104+
metaKeyScanFuture = scheduleExecutor.submit(this::scanMetaKeys);
105+
} else {
106+
metaKeyScanFuture = CompletableFuture.completedFuture(true);
101107
}
102-
boolean scanSubKeysSuccess = scanSubKeys();
103-
if (scanMetaKeysSuccess && scanSubKeysSuccess) {
108+
//sub-key scan
109+
Future<Boolean> subKeyScanFuture = scheduleExecutor.submit(this::scanSubKeys);
110+
//
111+
if (metaKeyScanFuture.get() && subKeyScanFuture.get()) {
104112
KvGcEnv.updateGcTime(namespace, System.currentTimeMillis());
105113
}
106114
} catch (Throwable e) {

‎update-en.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* camellia-redis-proxy, kv, optimize log of lru-cache
1616
* camellia-redis-proxy, kv, when configure zset encode version=1, index write async in default
1717
* camellia-redis-proxy, kv, bump obkv-client to 1.4.0
18+
* camellia-redis-proxy,kv, add gc scan keys count monitor
19+
* camellia-redis-proxy,kv, gc schedule task, scan meta key and sub key in concurrent
1820

1921
### fix
2022
* camellia-redis-proxy, when use ConsensusProxyClusterModeProvider to deploy redis-cluster-mode, fix slot calc wrong in some case

‎update-zh.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* camellia-redis-proxy,kv,优化了lru-cache的日志打印
1616
* camellia-redis-proxy,kv,在zset的version=1下,index默认开启异步写入
1717
* camellia-redis-proxy,kv,obkv-client升级版本到1.4.0
18+
* camellia-redis-proxy,kv,增加gc扫描key数量的监控
19+
* camellia-redis-proxy,kv,gc扫描时,meta-key和sub-key并发执行
1820

1921
### fix
2022
* camellia-redis-proxy,使用ConsensusProxyClusterModeProvider部署为redis-cluster模式时,修复边界情况下slot计算错误的问题

0 commit comments

Comments
 (0)
Please sign in to comment.