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

fix: Redis 4 does not reconnect after unhandled error #8706

Merged
merged 4 commits into from
Aug 30, 2023

Conversation

Vortec4800
Copy link
Contributor

Pull Request

Issue

Closes: #8705

Approach

Adds mostly empty event handlers to the Redis client, which is now required for Redis 4.

Tasks

  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check

@parse-github-assistant
Copy link

Thanks for opening this pull request!

@mtrezza mtrezza changed the title Fixed Redis 4 Reconnect Issue fix: Redis 4 does not reconnect after unhandled error Aug 3, 2023
Copy link
Member

@mtrezza mtrezza left a comment

Choose a reason for hiding this comment

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

Could you add a test that demonstrates the issue before adding the fix and the passes with the fix?

It seems strange that adding empty handlers fixed this. Could you add a Redis docs reference that describes this requirement?

This makes me think which version of Redis we are actually testing with. It seems we need a compatibility table to the README and test with multiple versions just like we do with MongoDB. In our CI we are currently not specifying a Redis version, so it's using the latest version from Docker, which I think is Redis 7.0.12. Without testing with explicit versions I don't think we should merge this PR because the change may break compatibility with another Redis version.

@Vortec4800
Copy link
Contributor Author

Vortec4800 commented Aug 3, 2023

I agree it's strange. Here is the Redis issue that led me to the solution for reference.

redis/node-redis#2032

There's also some discussion on how to reliably recreate the issue, it seems that hosted Redis servers like Digital Ocean or Heroku do this pretty often. I don't think the server version matters for this, only the client version, and it seems these handlers didn't change between version 3.x of the client and 4.x - only their requirement to exist.

From that issue it links to the main readme that has a bit more information, and that also confirms the need for event handlers and the error thrown if they aren't handled: https://github.com/redis/node-redis#events . It seems we technically only need to add an error handler and not the other ones from the PR, so that could potentially be optimized.

I'm not sure offhand how to test this scenario, but let me investigate and see if there's something I can put together for that.

@ChrisGrant
Copy link

For what it is worth, I am seeing the same issue on Heroku with the latest version of parse-server (6.2.1).

Redis version is 6.2.13.

@codecov
Copy link

codecov bot commented Aug 14, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01% 🎉

Comparison is base (42929e0) 94.32% compared to head (7b13b56) 94.33%.

❗ Current head 7b13b56 differs from pull request most recent head 83aba07. Consider uploading reports for the commit 83aba07 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #8706      +/-   ##
==========================================
+ Coverage   94.32%   94.33%   +0.01%     
==========================================
  Files         185      185              
  Lines       14762    14766       +4     
==========================================
+ Hits        13924    13930       +6     
+ Misses        838      836       -2     
Files Changed Coverage Δ
src/Adapters/Cache/RedisCacheAdapter.js 92.00% <100.00%> (+0.69%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtrezza
Copy link
Member

mtrezza commented Aug 15, 2023

@Vortec4800 Did you find a way to add a test for this? If not, we may as well merge as is; if you could just take a look at the Lint error. We just have to be sure that this is not a breaking change in a certain scenario.

@Vortec4800
Copy link
Contributor Author

I'm sorry - work got busy and I haven't had a chance to look at this further. I did just add a quick change that should address the lint error, and log client errors via the internal logger. Take a look and let me know if that's appropriate. I can also add info logs to the other client events if you think that would be a good idea.

@mtrezza
Copy link
Member

mtrezza commented Aug 21, 2023

Thanks for the commits, let's see if the CI passes...

Signed-off-by: Cory Imdieke <cory.imdieke@gmail.com>
Signed-off-by: Cory Imdieke <cory.imdieke@gmail.com>
Signed-off-by: Cory Imdieke <cory.imdieke@gmail.com>
Signed-off-by: Cory Imdieke <cory.imdieke@gmail.com>
@mtrezza
Copy link
Member

mtrezza commented Aug 29, 2023

It's strange that this one Postgres job keeps failing in the CI, I've restarted it several times. Restarted again.

@mtrezza mtrezza merged commit 2b3d4e5 into parse-community:alpha Aug 30, 2023
24 checks passed
parseplatformorg pushed a commit that referenced this pull request Aug 30, 2023
# [6.3.0-alpha.8](6.3.0-alpha.7...6.3.0-alpha.8) (2023-08-30)

### Bug Fixes

* Redis 4 does not reconnect after unhandled error ([#8706](#8706)) ([2b3d4e5](2b3d4e5))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.3.0-alpha.8

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Aug 30, 2023
@Vortec4800 Vortec4800 deleted the patch-1 branch August 30, 2023 13:19
parseplatformorg pushed a commit that referenced this pull request Sep 16, 2023
# [6.4.0-beta.1](6.3.0...6.4.0-beta.1) (2023-09-16)

### Bug Fixes

* Parse Server option `fileUpload.fileExtensions` does not work with an array of extensions ([#8688](#8688)) ([6a4a00c](6a4a00c))
* Redis 4 does not reconnect after unhandled error ([#8706](#8706)) ([2b3d4e5](2b3d4e5))
* Remove config logging when launching Parse Server via CLI ([#8710](#8710)) ([ae68f0c](ae68f0c))
* Server does not start via CLI when `auth` option is set ([#8666](#8666)) ([4e2000b](4e2000b))

### Features

* Add conditional email verification via dynamic Parse Server options `verifyUserEmails`, `sendUserEmailVerification` that now accept functions ([#8425](#8425)) ([44acd6d](44acd6d))
* Add property `Parse.Server.version` to determine current version of Parse Server in Cloud Code ([#8670](#8670)) ([a9d376b](a9d376b))
* Add TOTP authentication adapter ([#8457](#8457)) ([cc079a4](cc079a4))

### Performance Improvements

* Improve performance of recursive pointer iterations ([#8741](#8741)) ([45a3ed0](45a3ed0))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.4.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Sep 16, 2023
parseplatformorg pushed a commit that referenced this pull request Sep 20, 2023
# [6.4.0-alpha.1](6.3.0...6.4.0-alpha.1) (2023-09-20)

### Bug Fixes

* Parse Server option `fileUpload.fileExtensions` does not work with an array of extensions ([#8688](#8688)) ([6a4a00c](6a4a00c))
* Redis 4 does not reconnect after unhandled error ([#8706](#8706)) ([2b3d4e5](2b3d4e5))
* Remove config logging when launching Parse Server via CLI ([#8710](#8710)) ([ae68f0c](ae68f0c))
* Server does not start via CLI when `auth` option is set ([#8666](#8666)) ([4e2000b](4e2000b))

### Features

* Add conditional email verification via dynamic Parse Server options `verifyUserEmails`, `sendUserEmailVerification` that now accept functions ([#8425](#8425)) ([44acd6d](44acd6d))
* Add context to Cloud Code Triggers `beforeLogin` and `afterLogin` ([#8724](#8724)) ([a9c34ef](a9c34ef))
* Add property `Parse.Server.version` to determine current version of Parse Server in Cloud Code ([#8670](#8670)) ([a9d376b](a9d376b))
* Add TOTP authentication adapter ([#8457](#8457)) ([cc079a4](cc079a4))

### Performance Improvements

* Improve performance of recursive pointer iterations ([#8741](#8741)) ([45a3ed0](45a3ed0))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.4.0-alpha.1

parseplatformorg pushed a commit that referenced this pull request Nov 16, 2023
# [6.4.0](6.3.1...6.4.0) (2023-11-16)

### Bug Fixes

* Parse Server option `fileUpload.fileExtensions` does not work with an array of extensions ([#8688](#8688)) ([6a4a00c](6a4a00c))
* Redis 4 does not reconnect after unhandled error ([#8706](#8706)) ([2b3d4e5](2b3d4e5))
* Remove config logging when launching Parse Server via CLI ([#8710](#8710)) ([ae68f0c](ae68f0c))
* Server does not start via CLI when `auth` option is set ([#8666](#8666)) ([4e2000b](4e2000b))

### Features

* Add conditional email verification via dynamic Parse Server options `verifyUserEmails`, `sendUserEmailVerification` that now accept functions ([#8425](#8425)) ([44acd6d](44acd6d))
* Add property `Parse.Server.version` to determine current version of Parse Server in Cloud Code ([#8670](#8670)) ([a9d376b](a9d376b))
* Add TOTP authentication adapter ([#8457](#8457)) ([cc079a4](cc079a4))

### Performance Improvements

* Improve performance of recursive pointer iterations ([#8741](#8741)) ([45a3ed0](45a3ed0))
@parseplatformorg
Copy link
Contributor

🎉 This change has been released in version 6.4.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Latest version of Redis won't automatically reconnect without error handling
4 participants