-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Database failover #203
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
Comments
Hey, Are you talking about the RedisArray functionality, or just generally. The way I usually handle this sort of problem, is by wrapping my phpredis calls on the PHP side. I don't wrap calls to actual data functions themselves because that introduces too much of a performance penalty, but rather to the process of connecting. We actually use a seperate Redis instance that containes our nodes, and then attempt to get a connection, failing over if one is down. |
Hi. Sorry, I should have been more specific. This is wrt using Redis as a session store and the session.save_path param in the php.ini file. Today, you can pass multiple Redis instances in, but as far as I understand, phpredis uses those connections in a round robin fashion. We need to be able to support failover on the session store. Thanks, ~ sent from the road ~ On Jun 27, 2012, at 5:39 PM, Michael [email protected] wrote:
|
I don't think phpredis supports this at the present moment. Right now I think if the connection times out it will just fail. @nicolasff If you think failover is a reasonable idea, I can look into what it would take to make that work. |
@michael-grunder already looking into it, thanks! |
@cirruspath the way sessions work is by calling a specific Should you not expect the write to fail in that case, and just let it fail? I assume you don't want to write the session to the slave, do you? That could lead to inconsistencies when the master comes back... @michael-grunder any suggestions? My changes are on the session-failover branch. |
@nicolasff I think you're probably correct to let the session handler fail on write. The only real way I can see around this would add quite a bit of complexity to phpredis (e.g. keep track of session server states, etc). I don't even know how we could do this properly, and if the use case was using an actual master->slave configuration, any attempt on our end to keep such context could get nuked when the master came back up. Truth be told, however, I haven't ever used PHP sessions at all, so I'll have to dig into it a little deeper to come up with any good ideas. :) |
@nicolasff - I don't know the implementation of it in phpredis, but if a On Thu, Jun 28, 2012 at 3:06 PM, Michael Grunder <
|
@cirruspath yes, that's exactly what I did for the read path. Consider the following script:
I'm keen on adding this feature, but I'm afraid it will still be kinda limited. |
Got it. You know, our sessions don't change much once they're established. We use So... I say write it back to the slave. On Fri, Jun 29, 2012 at 7:55 AM, Nicolas Favre-Felix <
|
I had to introduce a "nothrow" flag in the RedisSock object in order to avoid throwing exceptions in the context of a session write. When PHP finishes and closes the session, it doesn't consider exceptions to be valid and simply bails out without giving the caller a chance to catch it. I replaced zend_throw_exception with redis_throw_exception which checks for this flag and just returns if we are in a session close context.
@cirruspath the changes are in, you can try out the feature using the "session-failover" branch on GitHub. |
Nicolas - Thank you! Let me review and I'll let you know if I have any questions. Thanks, Ryan Huff (949) 354-4134http://twitter.com/#%21/cirruscg On Wed, Jul 4, 2012 at 2:24 PM, Nicolas Favre-Felix <
|
@nicolasff Looks good to me. Similar to the destructor issue. |
It works great, but if I understand correct . The "failover=" param only works with the short "host:port" , and not with the "tcp://" scheme ? |
There only seems to be a issue when "auth=" is used, in that case : auth must be the same on both servers. And when the failover happends, the connection goes to the slave. But only the AUTH and GET are issued, and no new keys are SET. At the same time the following error is logged : |
@nicolasff would this be available soon in a stable release? |
Hey there, There are a few feature branches that we want to get merged into master soon. I'm curious if you (or anyone else) has had success with the changes. @cirruspath, how did it work out for you? @nicolasff You at all worried about these changes? Cheers guys :) |
Is it in a specific branch? I still have a test setup, so I can test it out . |
I'm pretty sure it's in Cheers, |
Hello guys! Just reminding you about this feature. Any progress on that? |
Hi |
Closing in favor of #1214 |
Hi. I have a master/slave setup already working with my redis database, and instead of the "round-robin" approach that is currently implemented in the config file, do you have any suggestions for implementing failover such that if the connection to host #1 fails, it moves to host #2? Same/similar configuration envisioned.
The text was updated successfully, but these errors were encountered: