Re: [Perl-workflow-devel] RT #52558
Brought to you by:
jonasbn
From: Danny S. <da...@sa...> - 2011-02-15 13:41:40
|
no pressure. ——— Danny Sadinoff da...@sa... On Tue, Feb 15, 2011 at 14:49, Jonas Brømsø Nielsen <jo...@gm...>wrote: > Hi Danny, > > I never followed-up on this, I am sorry. > > I will give Worflow some attention soon. I have been buried in work since > January and have only did a little Open Source stuff. > > But I will have a look at it ASAP. > > jonasbn > -- > AIM: BjonasN Gtalk: jo...@gm... > ICQ: 62401545 MSN: jo...@io... > twitter: jonasbn blog: http://e-diot.dk/ > > On 09/02/2011, at 14.49, Danny Sadinoff wrote: > > > Did this ever happen? I'm all for the suggested implementation. I'm > still battling this bug with tactical process restarts, when a reconnect is > really the right approach. > > > > you may also want to consider the approach that slashcode takes, which is > to validate the handle before each use. > > > > > http://slashcode.git.sourceforge.net/git/gitweb.cgi?p=slashcode/slashcode;a=blob;f=Slash/DB/Utility/Utility.pm;h=6acba030be7085d6e878a13326d4a4d04566471e;hb=live > > ——— > > Danny Sadinoff > > da...@sa... > > > > > > > > On Sat, Jan 30, 2010 at 21:34, Jonas Brømsø Nielsen <jo...@gm...> > wrote: > > Hello All and Danny, > > > > Danny asked a very interesting question, in relation to using a DBI bases > persister and MySQL. > > > > He observed that the connection would go away to he wondered where one > would code a reconnect. > > > > See the original ticket: > https://rt.cpan.org/Ticket/Display.html?id=52558 > > > > Here is my shot at a possible solution: > > > > The actual database connection is made in Workflow::Persister::DBI lines > 82-89, including logging. > > > > $dbh->{RaiseError} = 1; > > $dbh->{PrintError} = 0; > > $dbh->{ChopBlanks} = 1; > > $dbh->{AutoCommit} = $self->autocommit(); > > $self->handle($dbh); > > $log->is_debug > > && $log->debug( "Connected to database '", > > $self->dsn, "' and ", "assigned to persister ok" ); > > > > The interesting part is the association with $self, where the database > handle $dbh is given to the getter: handle. > > > > We could move the database connectivity part to a separate private method > with singleton behavior, so when accessing handle (this would be it) access > to the database would be tested, if connectivity existing the handled would > be returned else connection would be made or in some cases reconnected. > > > > I have used this pattern before and it seems to work quite nicely. > > > > DBI even has a ping method to check connectivity. > > > > http://search.cpan.org/~timb/DBI-1.609/DBI.pm#ping > > > > Does anybody have reflections, objections or anything? - else I will > initiate implementation ASAP. > > > > jonasbn > > -- > > AIM: BjonasN Gtalk: jo...@gm... > > ICQ: 62401545 MSN: jo...@io... > > twitter: jonasbn blog: http://e-diot.dk/ > > > > > > |