New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline queue doesn't works when redis server restarting. #2688
Comments
the client won't retry commands after they were written to the socket even if the offline queue is on because the client cannot know if the command was executed on the server or not (and rerunning commands like |
@leibale Well, but what is the purpose of the |
@mgsxman the client will write each command to the socket once. If the client wrote a command to the socket, then the socket drops, the client can't know if the command was executed on the server or not, and therefore won't retry them... |
@leibale Right, but according to the example mentioned above, the socket been dropped by shutting down the Redis server. After that during a certain period of time the client tried to write commands to the dropped socket and therefore were not written successfully yet because the socket already been dropped. And my assumption is that it should have been queue the remaining commands 10,11,12...25 for the new socket, ie. when the Redis server started again and retry those commands after the connection is established. But that did not happen, and all of the commands been removed and never retried. Why ? |
You are describing "offline queue" correctly, but missing some other things:
Using this code: import { createClient } from 'redis';
import { setTimeout } from 'node:timers/promises';
const client = await createClient()
.on('error', err => console.error('Redis client error', err))
.connect();
let i = 0;
while (true) {
const current = i++;
try {
console.log(
current,
await client.set(current.toString(), '')
);
} catch (err) {
console.error(current, err);
}
await setTimeout(500);
} when I restart the docker while the script is running I get one of the two:
|
Description
Hi. I'm trying to configure
redisClient
to flush the commands which was cached during redis server were offline but can'tBelow is my code. I'm trying to write values in infinity loop. I'm start the code and then restart docker container with redis instance. After that If I check
test:foo
set I saw 1,2,3,4,26,27,28 ..... So I miss 5-25 values or similar which the code tried to write while the server were off.How to configure offlineQueue correctly?
Node.js Version
v14.21.3
Redis Server Version
7.0.13
Node Redis Version
4.6.12
Platform
Windows
Logs
No response
The text was updated successfully, but these errors were encountered: