Re: [mongodb-user] replicate set upgrade without downtime?

133 views
Skip to first unread message

Scott Hernandez

unread,
Jun 18, 2012, 8:40:51 AM6/18/12
to mongod...@googlegroups.com
You can mark each secondary as hidden before you upgrade it but most
clients/driver have a connection pool so they have long lived
connections. It sounds like you are doing
slaveOk/ReadPreferences.SECONDARY queries so this is probably a good
idea. Different drivers will handle this better or worse in terms of
exposing the socket/connection error to your application; what
language are you using?

Your application must be written to reconnect/retry since there are
any number of transient (network) errors which could come up much like
the rolling upgrade process during normal operation.

As with the case of no primary for a short period of time, that is
unavoidable and your application needs to handle that as well. Not
every application wants the same behavior, and there is no one answer
to that question -- what should the app do if it can't write.

On Mon, Jun 18, 2012 at 1:10 PM, Oskar Liljeblad <os...@osk.mine.nu> wrote:
> It is possible to upgrade a MongoDB replica set without downtime? The reason
> I ask is because I followed the instructions on
> http://www.mongodb.org/display/DOCS/2.0+Release+Notes#2.0ReleaseNotes-Upgrading
> to upgrade secondaries, then use db.shutdownServer() on primary. The only
> problem is that when I shut down the secondary, existing (read-only) client
> connections were disconnected. And when I issued db.shutdownServer() on the
> primary, there was small delay (10-20 seconds or so) when no server was
> primary (or so at least it seemed). Is it possible to slowly drain
> connection from a server?
>
> Regards,
>
> Oskar Liljeblad
>
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb

Scott Hernandez

unread,
Jul 2, 2012, 7:26:55 AM7/2/12
to mongod...@googlegroups.com
Queries may be retried by the driver under some circumstances but writes will not be. Also, there is some limit to any number of retries.

I would suggest programming defensively and expect that some queries will fail and may need to reinitiated.

On Wed, Jun 20, 2012 at 9:01 PM, Adam Monsen <hai...@gmail.com> wrote:
On Monday, June 18, 2012 5:40:51 AM UTC-7, Scott Hernandez wrote:
Your application must be written to reconnect/retry since there are
any number of transient (network) errors which could come up much like
the rolling upgrade process during normal operation.

This is something huge, something I missed when creating my current application. :)

I just want to double-check here: you're saying that if you use replication (with or without slaveOk) you should always be retrying queries?

I'm currently dealing with this with Symfony2 / Doctrine MongoDB.

But, hmm, the Mongo PHP extension docs say

The driver will automatically retry "plain" queries (not commands) a couple of times if the first attempt failed for certain reasons. This is to cause fewer exceptions during replica set failover (although you will probably still have to deal with some) and gloss over transient network issues.

and I thought doctrine-mongodb just used that extension, so I guess I'm not sure if I need to worry about retries or not.

Adam Monsen

unread,
Nov 6, 2012, 1:05:35 PM11/6/12
to mongod...@googlegroups.com
I'm looking for an answer to http://stackoverflow.com/questions/11125389/doctrine-odm-mongodb-not-retrying-queries

I sweetened the pot with a bounty of +100 stackoverflow reputation points.

Adam Monsen

unread,
Nov 12, 2012, 6:26:11 PM11/12/12
to mongod...@googlegroups.com
This seems to be more of a Doctrine than a MongoDB issue. See
https://groups.google.com/d/msg/doctrine-user/_Zt8cVxnEuk/m_LOSdvAACsJ
for the rest of the story.
Reply all
Reply to author
Forward
0 new messages