-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
fix(core): Handle Redis disconnects gracefully #11007
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice improvement 👏 Couple questions / comments
if (cumulativeTimeout > this.config.maxTimeout) { | ||
const maxTimeout = Math.round(this.config.maxTimeout / 1000) + 's'; | ||
this.logger.error(`Unable to connect to Redis after trying to connect for ${maxTimeout}`); | ||
this.logger.error('Exiting process due to Redis connection error'); | ||
process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we should allow graceful exit of other parts of the app as well. Otherwise we might leave some resources in improper state, like DB connections etc. Just mentioning this, no need to act on it here
@@ -156,4 +190,33 @@ export class RedisClientService { | |||
return { host, port: parseInt(port) }; | |||
}); | |||
} | |||
|
|||
@Debounce(1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the debounce here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Debouncing prevents all six clients spamming the logs with their calls to retryStrategy
in quick succession, i.e. we consolidate all logs from those calls on connection-lost
and connection-recovered
from six to one.
export type RedisClientType = N8nRedisClientType | BullRedisClientType;
/**
* Redis client used by n8n.
*
* - `subscriber(n8n)` to listen for messages from scaling mode pubsub channels
* - `publisher(n8n)` to send messages into scaling mode pubsub channels
* - `cache(n8n)` for caching operations (variables, resource ownership, etc.)
*/
type N8nRedisClientType = 'subscriber(n8n)' | 'publisher(n8n)' | 'cache(n8n)';
/**
* Redis client used internally by Bull. Suffixed with `(bull)` at `ScalingService.setupQueue`.
*
* - `subscriber(bull)` for event listening
* - `client(bull)` for general queue operations
* - `bclient(bull)` for blocking operations when processing jobs
*/
type BullRedisClientType = 'subscriber(bull)' | 'client(bull)' | 'bclient(bull)';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
n8n
|
Project |
n8n
|
Branch Review |
master
|
Run status |
|
Run duration | 04m 24s |
Commit |
|
Committer | Iván Ovejero |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
1
|
|
0
|
|
0
|
|
435
|
View all changes introduced in this branch ↗︎ |
✅ All Cypress E2E specs passed |
Got released with |
Currently a Redis disconnect triggers all manner of logs from multiple related services and from all six Redis clients simultaneously. This PR handles Redis this scenario more gracefully.