IlyaSkriblovsky/txredisapi

Redis reconnect broken when dbid != 0, or password is used.

jonathanslenders opened this issue · 6 comments

Hi all,

I would really discorage the use of any other database than 0, as well as the use of a password. Reconnect is broken.

Right now we have a very large database which takes a while to come up. So if we shut down the database, and bring it up again; redis needs some time for it to load into memory. Every command will be replied with something like this:

Failure: exceptions.ValueError: Redis error: could not set dbid=0: LOADING Redis is loading the dataset in memory 

So, obviously we cannot set the database id right after a TCP reconnect, but we have to wait for redis to be loaded into memory.

I have no patch for it to fix yet, but all feedback is welcome!

Cheers,
Jonathan

Hi, I've been using a dbid > 0 w/o recon problems but my db is small. What's the db size ? Is the problem happening with password ? My conn pool size is the default 10. If there's any event that we can capture to help delay the select would be good but I dont think there is. Probably the best idea would be to set a block/backoff strategy when applying select to try again. Ideas are welcome. Thanks

This is very bad news to me. On the other hand, why would redis listen on the port but not take commands during the start up? We can definitely work around it.

  • Does redis reply to any command during the start up? If so, we can use that to determine the connection state
  • Does it always reply with the same error? If so, we can also leverage that

Once we know the status we can defer the select() command, and keep the driver in "disconnected" mode. A task would eventually retry to select(), and once replied with successful response the driver would make the pool available again.

We have about 4,000,000 keys. And it happens also without password. The problem is that selecting the database doesn't work. I haven't had the time to figure it out, but I think it responds to any command like that.

However, I also don't see any reason why redis needs to have the database in memory for executing a select command. It doesn't touch the actual data set.

Gotta love the Internet.

gotta love @antirez