pyArango icon indicating copy to clipboard operation
pyArango copied to clipboard

More Failover support?

Open decay29 opened this issue 4 years ago • 5 comments

Are there plans for failover support by supporting multiple URLs like the Go driver does? Would the interim solution to be to create multiple connections and switch between them if a 503, "Not a leader" comes back? This is the situation when the leader drops and then comes back as a follower.

Note the driver works fine when the leader goes offline and the follower becomes the leader (requests are handled properly), but when the former leader is brought back, and it becomes a follower, and that is when the 503 shows.

decay29 avatar Sep 18 '19 20:09 decay29

Thanks for posting this, it could be added in the next updates. in the meantime you could try this simple hack:

connection.arangoURL = [list of new endpoints]
connection.currentURLId = 0

Let me know if that helps

tariqdaouda avatar Sep 19 '19 21:09 tariqdaouda

Thanks for replying:

I get this:

No connection adapters were found for '['http://192.168.1.77:8529', 'http://192.168.1.72:8529']/_db/_system/_api/cursor'

I first construct a Connection object and then swap out the single arangoURL for the list. This is using the latest from github

decay29 avatar Sep 19 '19 22:09 decay29

Could you copy/past the code you've used?

tariqdaouda avatar Sep 26 '19 17:09 tariqdaouda

       self.urls = ["http://192.168.1.77:8529",
                     "http://192.168.1.72:8529"]
def selectConnection(self, index = 0):
    try:
               self.connection = Connection(arangoURL=self.urls[index],
                                        username="blah",
                                        password="blah",
                                        verify=False)
                self.db = self.connection["_system"]
                self.connection.arangoURL = [self.urls]
                self.connection.currentURLId = 0
                print("connected")
                self.currentURL = self.urls[index]
 

Anyway, I have it working by just juggling the connections manually by checking for a connection exception, such as whether the url for the db is the leader, whether it is reachable etc.

decay29 avatar Sep 30 '19 16:09 decay29

Thanks @decay29 I'll keep that in mind for the next version.

tariqdaouda avatar Oct 09 '19 19:10 tariqdaouda