Redis集群连接丢失

时间:2020-08-06 17:26:55

标签: kubernetes redis bitnami node-redis redis-cluster

我在Kubernetes中部署了带bitnami / redis-cluster图表的Redis集群。我使用redis-cluster npm包从nodejs连接到集群。建立连接后,我尝试连续设置数千个键。完成所有过程的时间预计为十分钟。但是在连接两分钟后,Redis连接断开。

连接是否有问题,我该怎么办?就像更改配置或进行其他操作一样。

在我的场景或常见场景中,失去连接的确切原因是什么?

我的代码:

const redis = require('redis');
const redisCluster = require('redis-clustr')
const redisClient = new redisCluster({
    servers: [
    { host: "IP", port: 6379 },
    { host: "IP", port: 6379 }, 
    { host: "IP", port: 6379 },  
    { host: "IP", port: 6379 },
    { host: "IP", port: 6379 }, 
    { host: "IP", port: 6379 } 
     ],
    createClient: (port, host) => {
      return redis.createClient({ 
       port,
       host,
       auth_pass: 'PASSWORD',
     });
   }
});
 <My data processing code to set thousands of keys>
(node:15827) UnhandledPromiseRejectionWarning: AbortError: Redis connection lost and command aborted. It might have been processed.
    at RedisClient.flush_and_error (/root/data-pipeline/node_modules/redis/index.js:362:23)
    at RedisClient.connection_gone (/root/data-pipeline/node_modules/redis/index.js:664:14)
    at Socket.<anonymous> (/root/data-pipeline/node_modules/redis/index.js:293:14)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at Socket.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickCallback (internal/process/next_tick.js:180:9)
(node:15827) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:15827) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

0 个答案:

没有答案