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

Prevent duplicate intervals being set. #1244

Merged
merged 2 commits into from
Dec 13, 2020
Merged

Prevent duplicate intervals being set. #1244

merged 2 commits into from
Dec 13, 2020

Conversation

jshbrntt
Copy link
Contributor

@jshbrntt jshbrntt commented Nov 26, 2020

After calling redis.quit there are still many open setInterval handles that have not been cleared.

These uncleared setInternal appear to be because everytime connect is called in the reconnectTimeout the this._addedScriptHashesCleanInterval is overridden by a new one, but the old one is still running in the background.

https://github.com/luin/ioredis/blob/v4.19.2/lib/cluster/index.ts#L311-L313

When you call redis.quit it only clears the current one retained by this._addedScriptHashesCleanInterval.

[WTF Node?] open handles:
- File descriptors: (note: stdio always exists)
  - fd 1 (tty) (stdio)
  - fd 0 (tty)
  - fd 2 (tty) (stdio)
- Intervals:
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258

After calling `redis.quit` there are still many open `setInterval` handles that have not been cleared.

These uncleared `setInternal` appear to be because everytime `connect` is called in the `reconnectTimeout` the `this._addedScriptHashesCleanInterval` is overrided but the old one still exists in the background.

https://github.com/luin/ioredis/blob/v4.19.2/lib/cluster/index.ts#L311-L313

When you call `redis.quit` it only clears the current one retained by `this._addedScriptHashesCleanInterval`.

```
[WTF Node?] open handles:
- File descriptors: (note: stdio always exists)
  - fd 1 (tty) (stdio)
  - fd 0 (tty)
  - fd 2 (tty) (stdio)
- Intervals:
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
  - (60000 ~ 60 s) (anonymous) @ /srv/app/node_modules/ioredis/built/redis/index.js:258
```
Update other site where setInterval is used in the same way.
@luin luin merged commit 515d9ea into redis:master Dec 13, 2020
ioredis-robot pushed a commit that referenced this pull request Dec 13, 2020
## [4.19.4](v4.19.3...v4.19.4) (2020-12-13)

### Bug Fixes

* prevent duplicate intervals being set. ([#1244](#1244)) ([515d9ea](515d9ea)), closes [#1232](#1232) [#1226](#1226) [#1232](#1232) [/github.com/luin/ioredis/blob/v4.19.2/lib/cluster/index.ts#L311-L313](https://github.com//github.com/luin/ioredis/blob/v4.19.2/lib/cluster/index.ts/issues/L311-L313)
@ioredis-robot
Copy link
Collaborator

🎉 This PR is included in version 4.19.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

janus-dev87 added a commit to janus-dev87/ioredis-work that referenced this pull request Mar 1, 2024
## [4.19.4](redis/ioredis@v4.19.3...v4.19.4) (2020-12-13)

### Bug Fixes

* prevent duplicate intervals being set. ([#1244](redis/ioredis#1244)) ([515d9ea](redis/ioredis@515d9ea)), closes [#1232](redis/ioredis#1232) [#1226](redis/ioredis#1226) [#1232](redis/ioredis#1232) [/github.com/luin/ioredis/blob/v4.19.2/lib/cluster/index.ts#L311-L313](https://github.com//github.com/luin/ioredis/blob/v4.19.2/lib/cluster/index.ts/issues/L311-L313)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants