Skip to content

Conversation

@mfsiega
Copy link
Contributor

@mfsiega mfsiega commented Jan 29, 2026

Summary

If the Redis server fails over, it will start to throw READONLY errors when you try to write because you're trying to write to a readonly server. In this case, the client should reconnect.

By default this doesn't happen, so we leave this disabled by default as well, but we expose an option to enable it.

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/CAT-2240/n8n-fails-to-reconnect-after-redisvalkey-failover-in-multi-az-setup

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@codecov
Copy link

codecov bot commented Jan 29, 2026

Bundle Report

Changes will increase total bundle size by 40.94MB (100.0%) ⬆️⚠️, exceeding the configured threshold of 5%.

Bundle name Size Change
editor-ui-esm 40.94MB 40.94MB (100%) ⬆️⚠️

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/cli/src/services/redis-client.service.ts 37.50% 5 Missing ⚠️

📢 Thoughts on this report? Let us know!

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jan 29, 2026
@blacksmith-sh

This comment has been minimized.

@mfsiega mfsiega requested review from a team, despairblue and ivov and removed request for a team January 29, 2026 13:13

/** Whether to reconnect to Redis on READONLY errors i.e., failover events. */
@Env('QUEUE_BULL_REDIS_RECONNECT_ON_FAILOVER')
reconnectOnFailover: boolean = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we not enabling this by default?

Comment on lines +176 to +186
if (reconnectOnFailover) {
options.reconnectOnError = (redisErr: Error) => {
const targetError = 'READONLY';
if (redisErr.message.includes(targetError)) {
this.logger.warn('Reconnecting to Redis due to READONLY error (possible failover event)');
return true;
}
return false;
};
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if a write e.g. to enqueue a Bull job fails and we fail over that job is lost forever? Should we resend the failed write as well?

This feature is useful when using Amazon ElastiCache instances with Auto-failover disabled. On these instances, test your reconnectOnError handler by manually promoting the replica node to the primary role using the AWS console. The following writes fail with the error READONLY. Using reconnectOnError, we can force the connection to reconnect on this error in order to connect to the new master. Furthermore, if the reconnectOnError returns 2, ioredis will resend the failed command after reconnecting.

https://github.com/redis/ioredis

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

Labels

core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants