moleculerjs / moleculer

:rocket: Progressive microservices framework for Node.js
https://moleculer.services/
MIT License
6.16k stars 586 forks source link

Redis discoverer implements scan incorrectly for Cluster configurations #938

Open JordanPawlett opened 3 years ago

JordanPawlett commented 3 years ago

https://github.com/moleculerjs/moleculer/blob/6f6225d6079af2116a2b4713c5d00037512131f4/src/registry/discoverers/redis.js#L375

this.client.scanStream is used in multiple locations through the custom redis discoverer. scanStream does not exist on client for Redis.Cluster. I believe must iterate over client.nodes('master') to perform a scan, similar to how the Redis' cacher is written.

icebob commented 3 years ago

Thanks.

icebob commented 3 years ago

Could you create a PR?

intech commented 3 years ago

Now I will make and add tests

intech commented 3 years ago

The preliminary result is that simply sending the request through master will not work. I'm figuring out if this problem is related to my tests or it's a bug in ioredis

intech commented 3 years ago

@JordanPawlett

  1. You could clarify how exactly your cluster is assembled through sentinel or redis cluster
  2. Its configuration is how many masters and slaves per master.
  3. And is there a helm or docker-compose with sh scripts to configure it? Or maybe it's some kind of DBaaS solution?

I am testing on 2 different cluster configurations and am getting 2 completely different problems.

JordanPawlett commented 3 years ago

I've since moved to use etcd for service-discovery. If i remember correctly the Redis discovery worked correctly with a Sentinel setup. However, breaks for redisCluster, as scanStream does not exist on that client.

Both redis-cluster and redis-sentinel were deployed in a k8s cluster using bitnami helm charts.

What problems specifically are you encountering?

intech commented 3 years ago

If i remember correctly the Redis discovery worked correctly with a Sentinel setup. However, breaks for redisCluster, as scanStream does not exist on that client.

Sentinel works differently, unlike redisCluster, a similar problem does not occur there. With redisCluster, additional commands are sent to redis-server which results in an error.

scanStream exists in ioredis and scan command is supported in redis-server with cluster. Errors occur when trying to work with data, the scan command on the server in one case CROSSSLOT error, in another cluster All keys in the pipeline should belong to the same slots allocation group when requesting for any node (master/slave).

icebob commented 2 years ago

Any news about it?

intech commented 2 years ago

Any news about it?

Alas, I don't have a solution yet. In testing, I didn't a solution with client.nodes ('master'). I will run tests again with the current versions of redis and ioredis to make a final conclusion where the problem is.