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(connection): remove heartbeat check in load balanced mode #15089

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

vkarpov15
Copy link
Collaborator

cc @alexbevi

Fix #15042
Revert #14812

Summary

We've gotten a few bug reports that indicate connectivity issues with Mongoose 8.7, including #14971 etc. Most notably, we've confirmed that #15042 is caused by the heartbeat check we added in #14812: we should not use that heartbeat check if the topology is LoadBalanced because the MongoDB Node driver doesn't send heartbeats in that case, so for LoadBalanced topology Mongoose currently loses connectivity after 20 seconds. Given this and all the issues we've gotten specifically referencing connectivity issues in Mongoose 8.7.0, I think it is prudent to remove this check for now.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

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

Because #14812 main functionality is reverted, should we re-open #14727?

@vkarpov15 vkarpov15 changed the title fix(connection): remove heartbeat check when getting connection readyState fix(connection): remove heartbeat check in load balanced mode Dec 11, 2024
…nection as heartbeat to avoid other cases where there is no heartbeat
@vkarpov15
Copy link
Collaborator Author

Based on convo with @alexbevi I'm thinking it's better to make the following 2 changes:

  1. Avoid the stale heartbeat check in LoadBalanced mode. Apparently the MongoDB Node driver doesn't receive heartbeats in LoadBalanced mode, and that's the mode the driver runs in when connected to MongoDB behind haproxy or when connected to Atlas serverless instances.
  2. Don't treat successful connection as a heartbeat. Part of the problem here is that Mongoose thinks it received a heartbeat because we set _lastHeartbeatAt when Mongoose successfully connects, but then no other heartbeats are ever received. With this change, if Mongoose never received an actual successful heartbeat event, it won't use the stale heartbeat check. This change is a precaution for other edge cases where Mongoose might not receive any heartbeats for some reason.

@vkarpov15 vkarpov15 added this to the 8.9 milestone Dec 12, 2024
@vkarpov15 vkarpov15 merged commit 5c0f300 into master Dec 12, 2024
74 checks passed
@hasezoey hasezoey deleted the vkarpov15/gh-15042 branch December 13, 2024 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

loadBalanced=true drops connection after a delay and never reconnects
2 participants