提交 be1aab25 编写于 作者: N Nikita Koksharov

Fixed - Redisson shutdown takes much time after RBatch execution #3653

上级 e9a7703e
......@@ -78,11 +78,11 @@ public class RedisQueuedBatchExecutor<V, R> extends BaseRedisBatchExecutor<V, R>
@Override
protected void releaseConnection(RPromise<R> attemptPromise, RFuture<RedisConnection> connectionFuture) {
if (RedisCommands.EXEC.getName().equals(command.getName())) {
super.releaseConnection(attemptPromise, connectionFuture);
}
if (RedisCommands.DISCARD.getName().equals(command.getName())) {
if (RedisCommands.EXEC.getName().equals(command.getName())
|| RedisCommands.DISCARD.getName().equals(command.getName())) {
super.releaseConnection(attemptPromise, connectionFuture);
} else {
connectionManager.getShutdownLatch().release();
}
}
......@@ -95,17 +95,13 @@ public class RedisQueuedBatchExecutor<V, R> extends BaseRedisBatchExecutor<V, R>
}
if (RedisCommands.DISCARD.getName().equals(command.getName())) {
super.handleSuccess(promise, connectionFuture, null);
if (executed.compareAndSet(false, true)) {
connectionFuture.getNow().forceFastReconnectAsync().onComplete((r, e) -> {
releaseConnection(promise, connectionFuture);
});
}
return;
}
try {
BatchPromise<R> batchPromise = (BatchPromise<R>) promise;
RPromise<R> sentPromise = (RPromise<R>) batchPromise.getSentPromise();
System.out.println("res " + res);
super.handleSuccess(sentPromise, connectionFuture, null);
} finally {
latch.countDown();
......
......@@ -556,10 +556,24 @@ public class RedissonBatchTest extends BaseTest {
redisson.shutdown();
}
@ParameterizedTest
@MethodSource("data")
@MethodSource("data")
public void testShutdownTimeout(BatchOptions batchOptions) {
org.junit.jupiter.api.Assertions.assertTimeout(Duration.ofMillis(500), () -> {
RedissonClient redisson = createInstance();
RBatch batch = redisson.createBatch(batchOptions);
for (int i = 0; i < 10; i++) {
RFuture<Void> f = batch.getBucket("test").setAsync(123);
}
batch.execute();
redisson.shutdown();
});
}
@ParameterizedTest
@MethodSource("data")
public void testBatchBigRequest(BatchOptions batchOptions) {
Config config = createConfig();
config.useSingleServer().setTimeout(15000);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册