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

Built-in support for Active Failover #477

Open
JLedel opened this issue Jun 29, 2023 · 3 comments
Open

Built-in support for Active Failover #477

JLedel opened this issue Jun 29, 2023 · 3 comments

Comments

@JLedel
Copy link
Contributor

JLedel commented Jun 29, 2023

If you're using an active failover setup and happens to query a follower, or there is a leader change, you'll get an exception telling that the node is not a leader anymore.

I guess the reasonable fix is to allow the HttpApiTransport class to be created with multiple endpoints, and then have the transport silently either try the other one suggested by the header, or just go through the list of provided servers until one that's leader is found.

Is there any interest to add support for this in this project as well? If so, we could try to coordinate it so that our implementation works for this connector as well.

@DiscoPYF
Copy link
Collaborator

DiscoPYF commented Jul 6, 2023

Hi @JLedel , it makes sense to me to add support for this in this project.

I'm not familiar with the active failover sequence and implementation in ArangoDB, I will take a closer look. But at a glance I would propose to:

  • Keep HttpApiTransport implementation as is.
  • Create a separate implementation of IApiClientTransport that deals with active failover, e.g. FailoverHttpApiTransport.
    • Could possibly inherit from/extend HttpApiTransport, or use composition and FailoverHttpApiTransport just switch between multiple HttpApiTransport as needed. There are a few possibilities, I'm thinking outloud at this point.

What do you think?

@JLedel
Copy link
Contributor Author

JLedel commented Jul 6, 2023

We looked at the go driver which just cycles between the connections until it finds a leader (for cluster as well): https://github.com/arangodb/go-driver/blob/ae64363de2bc9a13e5ef03115489e19fc9439793/cluster/cluster.go#L202

But yes, a FailOverHttpApiTransport would solve our case. We're working on it internally, so I'll make a PR once we've tested it a bit, and we can take it from there.

@DiscoPYF
Copy link
Collaborator

Sounds good 👍

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

No branches or pull requests

2 participants