redis / ioredis

🚀 A robust, performance-focused, and full-featured Redis client for Node.js.
MIT License
14.26k stars 1.19k forks source link

Weird issues on `this.sentinels.splice is not a function` in SentinelIterator , SentinelConnector #1306

Closed divineforge closed 3 years ago

divineforge commented 3 years ago

hi I have an odd issue happening in one of my application servers. (only 1) the others are behaving correctly. I checked to ensure the redis and redis-sentinel are working correctly sentinels information are passed correctly. No errors are thrown during making Redis client connection.

Hence looking for a clue what could go wrong? attaching a screenshot below.

Screenshot 2021-03-18 at 3 30 02 PM

divineforge commented 3 years ago

additional info: "ioredis": "^4.19.2"

luin commented 3 years ago

Hey @divineforge,

That looks strange especially given only one server had this issue. SentinelIterator#sentinels should never be reassigned so the only reason I can think of is you passed a non-array value for the sentinels option, ex a string. Like instead of:

new Redis({
  sentinels: 'https://xx'
})

You should use:

new Redis({
  sentinels: ['https://xx']
})

Is this your case?

divineforge commented 3 years ago

thanks for the heads up. I'll further debug along this line. :)

divineforge commented 3 years ago

Actually, I don't seem to find anything yet @luin All the previous Redis connect in the log, shows successfully connected. and also from the console output, the sentinels info are read as array correctly.

the point is doesn't work in that particular server, was the moment when about to call for 'client.subscribe'.. any further clue you could think of? Possiblyy throwing this error? or in any other way, could put some debugging or catch the error from that redis client?

luin commented 3 years ago

Hmm...I can't think of any. The code is here in case you want to double-check: https://github.com/luin/ioredis/blob/master/lib/connectors/SentinelConnector/SentinelIterator.ts#L33

I don't find any cases in this file that this.sentinels is reassigned so if its initial value is an array, it should always be an array.

divineforge commented 3 years ago

hi @luin , thanks actually I found it's caused by the mis-configuration in the redis-sentinel. at such the redis-sentinel service in RHEL is forcing the Redis-server as slave of its own instance, instead of connecting to the actual master node.

thanks for attending to this.