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

chore(test): easy way to get cluster stuck #741

Open
wants to merge 2 commits into
base: v4
Choose a base branch
from

Conversation

AVVS
Copy link
Contributor

@AVVS AVVS commented Oct 26, 2018

No description provided.

@AVVS
Copy link
Contributor Author

AVVS commented Oct 27, 2018

Pushed a possible solution to the problem

Problem that I'm trying to solve:

resolve is lost when we issue .disconnect(true)

Workaround

start tracking all .connect() promises via .connectionPromise private variable, which exposes resolve and reject for the next connect promise and self-erases upon resolution

Things to think about

  • garbage collection - I do seem to be cleaning up everything, but it still introduces tons of cross-references
  • instead listen to events (?), ie ready, close inside the ready handler alongside .disconnect(true)
  • simply reject() .connect() promise - that requires a breaking change to current behaviour, as one would have to implement retrying outside of ioredis
  • reject & implement retrying (via bluebird-retry library for instance)

@AVVS AVVS requested a review from luin October 27, 2018 00:19
@AVVS
Copy link
Contributor Author

AVVS commented Oct 31, 2018

@luin any thoughts on that?

@AVVS AVVS requested a review from shaharmor November 6, 2018 11:11
@AVVS
Copy link
Contributor Author

AVVS commented Nov 7, 2018

@shaharmor issue described here - #709

@stale
Copy link

stale bot commented Dec 7, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed.

@stale stale bot added the wontfix label Dec 7, 2018
@luin luin added pinned and removed wontfix labels Dec 8, 2018
@AVVS
Copy link
Contributor Author

AVVS commented Dec 11, 2018

@luin what do you think of the approach, should we just redo this into event-based handling instead of chaining promises?

@luin
Copy link
Collaborator

luin commented Dec 12, 2018

@luin what do you think of the approach, should we just redo this into event-based handling instead of chaining promises?

Sorry for the late response! Been pretty busy lately 😢 . This approach works while add a little complexity. I would consider Cluster#connect() failed when the current connection attempt is not successful (although the subsequent ones may success). This keeps the same behavios as Redis#connect(). People need to rely on the events like "ready"/"connect"/"close"/"end" if they need to know the connection status in a higher level (most cases will be this).

Currently, the problem seems to be that we remove the close handler too early so the "reject()" won't be called if a disconnection happens between the "refresh" event and "ready" event. To solve that, we may move the removeListener('close') to the ready event callback, so the Cluster#connect() will be rejected in your test case (although the cluster wil be ready eventually). What do you think?

@AVVS
Copy link
Contributor Author

AVVS commented Dec 19, 2018

Currently, the problem seems to be that we remove the close handler too early so the "reject()" won't be called if a disconnection happens between the "refresh" event and "ready" event. To solve that, we may move the removeListener('close') to the ready event callback, so the Cluster#connect() will be rejected in your test case (although the cluster wil be ready eventually). What do you think?

I think rejecting makes sense, and then users can handle what to do - as long as promise is not stuck forever we are already way ahead of this

At the same time I think it would be great to add a convenience method, which would do auto-reconnect sort of thing with listening to ready/close/error events and possibly some sort of auto-retry strategy with a finite end

@AVVS
Copy link
Contributor Author

AVVS commented May 9, 2019

@luin do you think you'd have time to do something about this? :)

@luin
Copy link
Collaborator

luin commented May 15, 2019

@AVVS Not have time digging into it currently, but likely can find some time for it within the next two months. I think the issue still exists, doesn't it?

@AVVS
Copy link
Contributor Author

AVVS commented Nov 24, 2019

@luin the issue still exists, indeed :) do you think you might have time to review the code or come up with a better solution than the one I've coded?

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.

2 participants