This repository has been archived by the owner on Feb 14, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continued from initial reproduction at #77 (comment)
Okay so to recap:
saveApiResponses.mjs
script crashing withReplyError: Ready check failed: ERR max number of clients reached
redis-cli
then asking forCLIENT LIST
, which lists all the open ones.redis-cli CLIENT LIST | wc -l
is the one-liner to count themyarn fetch
keeps running and time passes, we can watch this list grows in real time and the number never decreasesredis-cli CONFIG GET MAXCLIENTS
(which is at10000
here), we can't open any new connection and the script goes kaboomyarn develop
(the side that reads off the data stored in redis for display), the number is growing, so we know the culprit isyarn fetch
(the side that puts the data into redis)yarn fetch
instantly resets the open connections count to zero, so it seems to beyarn fetch
abnormally holding onto its end of the open connections, not redis itself.saveApiResponses.mjs
we find we can make the problem disappear by just removing lines 47-53:withCache
.withCache
is callingredis.createClient
every time it checks for a key, and then never closes it withclient.quit
nodeAccounts
we try to lookup, which explains why every[chaosnet]: starting data fetch...
adds another 60 open clients on redisgetAsync/setAsync
are now able to reuse the globalclient
redis instance:Thus to confirm the change:
yarn fetch
redis-cli CLIENT LIST | wc -l
repeatedly to see connections pile upyarn fetch
redis-cli CLIENT LIST | wc -l
and see connection count remain at oneNote that this was very likely the problem #77 (comment) was trying to mitigate, making it not so useful anymore.