[AOLSERVER] nspostgres autoreconnect to db if pg restarted underneath

5 views
Skip to first unread message

Jim

unread,
Feb 25, 2012, 4:45:57 AM2/25/12
to aolserv...@lists.sourceforge.net
Hi Agustin, moving this to its own thread.

On 2/25/12, Agustin Lopez <agusti...@uv.es> wrote:
> Hi all!
>
> Talking about nspostgres, has anybody implemented any way to auto reconnect
> to the database in a Postgresql start / stop?
>
> Thanks,
> Agustin

Since the normal procedure when restarting pg is to stop pg client
programs, stop pg, start pg and start clients, I didn't see a use to
try implementing this. What I did see was extra code ran every time
nspostgres was used to query (or use ddl/dml) to make sure a
connection was stable, and that could be a heavy cost, especially if
pg is not running on the same machine as its clients (incl aolserver).

Having said that, I'd like to explore what would be required to make
that happen. It seems to me one of the better approaches, is don't
make the clients have to do anything different, that is, they don't
have to know the db closed and reopened. In this approach, there seems
to be three states for a connection: (1) it's good, and ready to
accept queries; (2) the database has restarted, it's up and ready, but
the underlying connection has to be replaced (leading to state 1); or
(3) the database is in the process of restarting, so a query is not
possible at this time.

If this is the approach we want, then the first order of business is
to determine which of the three states we're in. Can we start by just
assuming we're in state 1 and sending a query? If we do this and we're
in state 2, does the process segfault (due to the thing that used to
be in ram not being there)?

Let's start here.

-Jim

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
aolserver-talk mailing list
aolserv...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/aolserver-talk

Jim

unread,
Feb 25, 2012, 11:42:25 AM2/25/12
to Don Baccus, aolserv...@lists.sourceforge.net
Well Don,

I'm responding to two things, one is that Dossy had asked about this
some years back, and the other is the question that Agustin asked...
all I've done so far is think about it and invite comment.

Having said that, could you look at the other change I made on my fork
which is not going to be merged into the main repo unless someone
looks at it and sees "yes, this does fix existing problems, and we
should merge it"? There are other funcs where I think this should be
performed, but, one at a time, and with review each time.

On 2/25/12, Don Baccus <dho...@pacifier.com> wrote:


>
> On Feb 25, 2012, at 1:45 AM, Jim wrote:
>
>> Hi Agustin, moving this to its own thread.
>>
>> On 2/25/12, Agustin Lopez <agusti...@uv.es> wrote:
>>> Hi all!
>>>
>>> Talking about nspostgres, has anybody implemented any way to auto
>>> reconnect
>>> to the database in a Postgresql start / stop?
>>>
>>> Thanks,
>>> Agustin
>>
>> Since the normal procedure when restarting pg is to stop pg client
>> programs, stop pg, start pg and start clients, I didn't see a use to
>> try implementing this.
>

> That's right.


>
>> What I did see was extra code ran every time
>> nspostgres was used to query (or use ddl/dml) to make sure a
>> connection was stable, and that could be a heavy cost, especially if
>> pg is not running on the same machine as its clients (incl aolserver).
>

> nspostgres implements recovery after the failure (crash) of a single
> backend, not the starting/stopping of postmaster.
>
> That code's been around forever, is extremely stable, and while very few
> people now use aolserver some very large sites depend on it remaining
> stable.
>
> Unless you think you have a *really, really, really* good reason to muck
> with it, please don't.


>
>>
>> Having said that, I'd like to explore what would be required to make
>> that happen.
>

> I don't see why. How often do you start/stop postmaster? If you're doing
> so often, you're doing something wrong.

Not in at least 2-3 years, so I'm presently thinking the same. They're
so stable together that taking the time to restart things is no big
deal. Now having said that, if someone says "for me, restarting
aolserver takes 2 days from when I tell it to bounce", then I think
there's a problem. I don't expect to ever hear that :)

> If you're doing so rarely, then having to bounce aolserver, too, is no big
> deal.

That's what I thought too; let's see if there's a real use case for this...

Don Baccus

unread,
Feb 25, 2012, 9:50:46 AM2/25/12
to Jim, aolserv...@lists.sourceforge.net

On Feb 25, 2012, at 1:45 AM, Jim wrote:

> Hi Agustin, moving this to its own thread.
>
> On 2/25/12, Agustin Lopez <agusti...@uv.es> wrote:
>> Hi all!
>>
>> Talking about nspostgres, has anybody implemented any way to auto reconnect
>> to the database in a Postgresql start / stop?
>>
>> Thanks,
>> Agustin
>
> Since the normal procedure when restarting pg is to stop pg client
> programs, stop pg, start pg and start clients, I didn't see a use to
> try implementing this.

That's right.

> What I did see was extra code ran every time
> nspostgres was used to query (or use ddl/dml) to make sure a
> connection was stable, and that could be a heavy cost, especially if
> pg is not running on the same machine as its clients (incl aolserver).

nspostgres implements recovery after the failure (crash) of a single backend, not the starting/stopping of postmaster.

That code's been around forever, is extremely stable, and while very few people now use aolserver some very large sites depend on it remaining stable.

Unless you think you have a *really, really, really* good reason to muck with it, please don't.

>

> Having said that, I'd like to explore what would be required to make
> that happen.

I don't see why. How often do you start/stop postmaster? If you're doing so often, you're doing something wrong.

If you're doing so rarely, then having to bounce aolserver, too, is no big deal.
----
Don Baccus
http://donb.photo.net
http://birdnotes.net
http://openacs.org

Majid Khan

unread,
Feb 28, 2012, 3:17:41 PM2/28/12
to Jim, aolserv...@lists.sourceforge.net
Jim,
 
nsmysql spit the error like "lost connection..." and when MySQL server is up then nsmysql nicely reconnects without even making aolserver restart. Let me tell you the situation which I have been through. I had to tweak my pg server and for that I had to restart it while doing restart my all aolserver client getting restarted abruptly and imagine I have more then 50 aol client, so restart means disconnect users, recreating connection with other db's like Oracle and MySQL and making load high on those servers, it would be nice that if nspostgres would show a lost connection kind of message and then reconnects if pg server is up like nsmysql , this way at least I would have site up and running and only those area would get effected where pg procs are defined. Also we dont' do restart of the pg server frequently :)
 
P.S. AolServer connects to pgpool which connects to postgres

Jim

unread,
Feb 29, 2012, 11:07:30 AM2/29/12
to Majid Khan, aolserv...@lists.sourceforge.net
Heya Majid,

What were the reasons for the last (say) 5 times you restarted pg? I
guess when you did so, you had to also restart the clients? I'm also
curious when they were restarted, or at least for each, how long
between them.

One thing that comes to mind, is you could set up several machines
each running a pg being fed with replication... This way if a pg has
to be restarted, you wouldn't have to restart as many clients.

-Jim

Reply all
Reply to author
Forward
0 new messages