Skip to content

Offline queue doesn't works when redis server restarting. #2688

@Dr-klo

Description

@Dr-klo

Description

Hi. I'm trying to configure redisClient to flush the commands which was cached during redis server were offline but can't
Below 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?


const redisClient = redis.createClient({
  socket:{
  host:config.redis.host, 
  port:config.redis.port,
  reconnectStrategy:  retries => Math.min(retries * 50, 5000)},
  commandsQueueMaxLength: 99999,
  disableOfflineQueue:false,
});
redisClient.on('error', error => console.log(`Redis exception on worker ${process.env.workerType} (pid  ${process.pid}): ${error}`));

async function loop(i){
  try{
    console.log('loop '+i);
    let multi = redisClient.multi();
    await multi.zAdd('test:foo', {score:i, value:i.toString()}).exec();
  }catch (e) {
    console.log('catch',e)
  }
}
(async()=>{
  await redisClient.connect()
  let i = 0;
  setInterval(()=> loop(++i), 1000);
})();

Node.js Version

v14.21.3

Redis Server Version

7.0.13

Node Redis Version

4.6.12

Platform

Windows

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions