Skip to content
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

TypeORM Cache with Redis Cluster throws errors #11224

Open
1 of 18 tasks
starci183 opened this issue Jan 5, 2025 · 1 comment
Open
1 of 18 tasks

TypeORM Cache with Redis Cluster throws errors #11224

starci183 opened this issue Jan 5, 2025 · 1 comment

Comments

@starci183
Copy link

starci183 commented Jan 5, 2025

Issue description

TypeORM Cache with Redis Cluster throws errors Unexpected error processing request: Error: MOVED 4035 10.0.2.16:6379

Expected Behavior

Cached successfully

Actual Behavior

Throws error: Unexpected error processing request: Error: MOVED 4035 10.0.2.16:6379

Steps to reproduce

I have run 6 instances of Redis Clusters (3 masters, 3 slaves), they work well in Docker.

I have also try to use redis/ioredis to test connection.

const connection = new Cluster([
            {   
                host: "127.0.0.1",
                port: 6379
            }
        ], {
            natMap: {
                "172.25.0.7:6379": { host: "127.0.0.1", port: 6382 },  // Slave node
                "172.25.0.3:6379": { host: "127.0.0.1", port: 6381 },  // Master node (slot range: 5461-10922)
                "172.25.0.2:6379": { host: "127.0.0.1", port: 6379 },  // Slave node
                "172.25.0.4:6379": { host: "127.0.0.1", port: 6384 },  // Master node (slot range: 0-5460)
                "172.25.0.6:6379": { host: "127.0.0.1", port: 6380 },  // Slave node
                "172.25.0.5:6379": { host: "127.0.0.1", port: 6383 }   // Master node (slot range: 10923-16383)
            }
        })
        const x = await connection.set("foo", "bar")
        console.log(x)

It works.
But when i set the similar config to typeorm cache options, it fails.

        options: {
                startupNodes: [
                    {
                         host: "127.0.0.1",
                         port: 6379
                    }
                ],
                natMap: {
                "172.25.0.7:6379": { host: "127.0.0.1", port: 6382 },  // Slave node
                "172.25.0.3:6379": { host: "127.0.0.1", port: 6381 },  // Master node (slot range: 5461-10922)
                "172.25.0.2:6379": { host: "127.0.0.1", port: 6379 },  // Slave node
                "172.25.0.4:6379": { host: "127.0.0.1", port: 6384 },  // Master node (slot range: 0-5460)
                "172.25.0.6:6379": { host: "127.0.0.1", port: 6380 },  // Slave node
                "172.25.0.5:6379": { host: "127.0.0.1", port: 6383 }   // Master node (slot range: 10923-16383)
            }
      }

It fails. And the error is Error: MOVED 4035 10.0.2.16:6379.
As I know, this error is created when use redis-cli without -c, Redis cluster can auto redirect to correct slot. So that maybe it a bug from typeorm code or wrong depencies?

My Environment

Dependency Version
Operating System
Node.js version 23.3.0
Typescript version ^5.1.3
TypeORM version "0.3.20",

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

@OSA413
Copy link
Collaborator

OSA413 commented Jan 5, 2025

Hi! Can you please provide a repository with all things configured (minimal reproducible example) so we can easily investigate the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants