You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by he...@apache.org on 2021/05/13 19:43:38 UTC
[geode] branch support/1.14 updated: GEODE-9155: Change frequency
of passive expiration (#6419) (#6432)
This is an automated email from the ASF dual-hosted git repository.
heybales pushed a commit to branch support/1.14
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/support/1.14 by this push:
new fb00b27 GEODE-9155: Change frequency of passive expiration (#6419) (#6432)
fb00b27 is described below
commit fb00b2730cc6cc0ee1d13b1d44d3273b8aa6727b
Author: Nabarun Nag <na...@users.noreply.github.com>
AuthorDate: Thu May 13 12:42:32 2021 -0700
GEODE-9155: Change frequency of passive expiration (#6419) (#6432)
GEODE-9155: Change frequency of passive expiration
change the interval in the PassiveExpirationManager from 1 second to 3
minutes. this significantly reduces the CPU load of passive expiration.
this change requires that one redis test must be commented out in the
patch file.
(cherry picked from commit 113aa7d487e2cf717cfbeb986114f28f6d988932)
Co-authored-by: Hale Bales <hb...@vmware.com>
---
.../resources/0001-configure-redis-tests.patch | 34 ++++++++++++++++------
.../geode/redis/internal/GeodeServerRunTest.java | 3 +-
.../server/AbstractHitsMissesIntegrationTest.java | 4 ++-
.../redis/internal/PassiveExpirationManager.java | 9 +++---
4 files changed, 35 insertions(+), 15 deletions(-)
diff --git a/geode-apis-compatible-with-redis/src/acceptanceTest/resources/0001-configure-redis-tests.patch b/geode-apis-compatible-with-redis/src/acceptanceTest/resources/0001-configure-redis-tests.patch
index 9bf0bf9..e83bf1d 100644
--- a/geode-apis-compatible-with-redis/src/acceptanceTest/resources/0001-configure-redis-tests.patch
+++ b/geode-apis-compatible-with-redis/src/acceptanceTest/resources/0001-configure-redis-tests.patch
@@ -162,17 +162,33 @@ index de24eabed..aeeb1da7f 100644
test {PERSIST returns 0 against non existing or non volatile keys} {
r set x foo
-@@ -154,39 +154,39 @@ start_server {tags {"expire"}} {
- set size1 [r dbsize]
- # Redis expires random keys ten times every second so we are
- # fairly sure that all the three keys should be evicted after
+@@ -149,44 +149,44 @@ start_server {tags {"expire"}} {
+- test {Redis should actively expire keys incrementally} {
+- r flushdb
+- r psetex key1 500 a
+- r psetex key2 500 a
+- r psetex key3 500 a
+- set size1 [r dbsize]
+- # Redis expires random keys ten times every second so we are
+- # fairly sure that all the three keys should be evicted after
- # one second.
- after 1000
-+ # two seconds.
-+ after 2000
- set size2 [r dbsize]
- list $size1 $size2
- } {3 0}
+- set size2 [r dbsize]
+- list $size1 $size2
+- } {3 0}
++# test {Redis should actively expire keys incrementally} {
++# r flushdb
++# r psetex key1 500 a
++# r psetex key2 500 a
++# r psetex key3 500 a
++# set size1 [r dbsize]
++# # Redis expires random keys ten times every second so we are
++# # fairly sure that all the three keys should be evicted after
++# # one second.
++# after 1000
++# set size2 [r dbsize]
++# list $size1 $size2
++# } {3 0}
- test {Redis should lazy expire keys} {
- r flushdb
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/GeodeServerRunTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/GeodeServerRunTest.java
index 1ba35a1..639c8f3 100755
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/GeodeServerRunTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/GeodeServerRunTest.java
@@ -30,9 +30,10 @@ public class GeodeServerRunTest {
@Test
@Ignore("This is a no-op test to conveniently run redis api for geode server for local development/testing purposes")
- public void runGeodeServer() {
+ public void runGeodeServer() throws InterruptedException {
LogService.getLogger().warn("Server running on port: " + server.getPort());
while (true) {
+ Thread.sleep(1000);
}
}
}
diff --git a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/server/AbstractHitsMissesIntegrationTest.java b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/server/AbstractHitsMissesIntegrationTest.java
index 1e9a29f..eead406 100644
--- a/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/server/AbstractHitsMissesIntegrationTest.java
+++ b/geode-apis-compatible-with-redis/src/integrationTest/java/org/apache/geode/redis/internal/executor/server/AbstractHitsMissesIntegrationTest.java
@@ -31,6 +31,7 @@ import org.junit.Test;
import redis.clients.jedis.BitOP;
import redis.clients.jedis.Jedis;
+import org.apache.geode.redis.internal.PassiveExpirationManager;
import org.apache.geode.test.awaitility.GeodeAwaitility;
import org.apache.geode.test.dunit.rules.RedisPortSupplier;
@@ -169,7 +170,8 @@ public abstract class AbstractHitsMissesIntegrationTest implements RedisPortSupp
public void testPassiveExpiration() {
runCommandAndAssertNoStatUpdates("hash", (k) -> {
jedis.expire(k, 1);
- GeodeAwaitility.await().during(Duration.ofSeconds(3)).until(() -> true);
+ GeodeAwaitility.await().atMost(Duration.ofMinutes(PassiveExpirationManager.INTERVAL * 2))
+ .until(() -> jedis.keys("hash").isEmpty());
});
}
diff --git a/geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/PassiveExpirationManager.java b/geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/PassiveExpirationManager.java
index c5edd81..37a0ef3 100644
--- a/geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/PassiveExpirationManager.java
+++ b/geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/PassiveExpirationManager.java
@@ -16,7 +16,7 @@
package org.apache.geode.redis.internal;
-import static java.util.concurrent.TimeUnit.SECONDS;
+import static java.util.concurrent.TimeUnit.MINUTES;
import static org.apache.geode.logging.internal.executors.LoggingExecutors.newSingleThreadScheduledExecutor;
import java.util.Map;
@@ -24,6 +24,7 @@ import java.util.concurrent.ScheduledExecutorService;
import org.apache.logging.log4j.Logger;
+import org.apache.geode.annotations.VisibleForTesting;
import org.apache.geode.cache.CacheClosedException;
import org.apache.geode.cache.EntryDestroyedException;
import org.apache.geode.cache.Region;
@@ -42,15 +43,15 @@ public class PassiveExpirationManager {
private final ScheduledExecutorService expirationExecutor;
private final RedisStats redisStats;
+ @VisibleForTesting
+ public static final int INTERVAL = 3;
public PassiveExpirationManager(Region<RedisKey, RedisData> dataRegion, RedisStats redisStats) {
this.dataRegion = dataRegion;
this.redisStats = redisStats;
expirationExecutor = newSingleThreadScheduledExecutor("GemFireRedis-PassiveExpiration-");
- int INTERVAL = 1;
expirationExecutor.scheduleWithFixedDelay(() -> doDataExpiration(dataRegion), INTERVAL,
- INTERVAL,
- SECONDS);
+ INTERVAL, MINUTES);
}
public void stop() {