[MTOS-dev] Getting rid of intermittent errors withLaunchBackgroundTasks

Mark Carey mark at mt-hacks.com
Thu Feb 28 08:53:03 PST 2008


On Thu, Feb 28, 2008 at 8:24 AM, Fumiaki Yoshimatsu
<fyoshimatsu at sixapart.com> wrote:
> Bump.  Could someone ever try this?

I have not tried it yet but I plan to try it soon.  I will report back
with my findings when I do.

-Mark


>
>
>
>  > -----Original Message-----
>  > From: mtos-dev-bounces at sixapart.com
>  > [mailto:mtos-dev-bounces at sixapart.com] On Behalf Of Fumiaki Yoshimatsu
>  > Sent: Wednesday, February 27, 2008 10:20 AM
>  > To: MTOS dev
>  > Subject: [MTOS-dev] Getting rid of intermittent errors
>  > withLaunchBackgroundTasks
>  >
>  > Hello MTOS-dev,
>  >
>  > Excuse me cross posting this to the list in addition to ProNet ML.
>  > I have been working on getting rid of intermittent DBI error when
>  > LaunchBackgroundTasks turned on.  The issue was originally reported to
>  > ProNet thread.
>  >
>  > Although it is still intermittent, I could create an environment on my
>  > Virtual PC instance which reproduces the issue fairly reliably.  After
>  a
>  > few experiments on the environment, I came up another experimental
>  code
>  > to add to see if it solve the issue.
>  >
>  > I would like you to review and possibly try to apply the code change
>  > below, to see if it works.  We appreciate your help, especially since
>  > this issue only occurs intermittently and we can't be 100% sure if the
>  > fix actually solves the issue only by seeing it gone away on my
>  Virtual
>  > PC instance.  Thank you in advance.
>  >
>  > ---
>  >
>  > 1. Add the following method to MT::ObjectDriverFactory
>  > (lib/MT/ObjectDriverFactory.pm):
>  >
>  > sub cleanup {
>  >     @drivers = ();
>  >     if ( my $driver = $MT::Object::DRIVER ) {
>  >         if ( my $dbh = $driver->dbh ) {
>  >             $dbh->disconnect;
>  >         }
>  >         $MT::Object::DRIVER = undef;
>  >     }
>  > }
>  >
>  > 2. Modify the three lines in start_background_tasks method in MT::Util
>  > (lib/MT/Util.pm) so it has the code as follows:
>  >
>  > sub start_background_task {
>  >     my ($func) = @_;
>  >     if (!launch_background_tasks()) { $func->(); }
>  >     else {
>  > MT::ObjectDriverFactory->cleanup(); # <-- ADD THIS LINE
>  >         $| = 1;            # Flush open filehandles
>  >         my $pid = fork();
>  >         if (!$pid) {
>  >             # child
>  >             close STDIN; open STDIN, "</dev/null";
>  >             close STDOUT; open STDOUT, ">/dev/null";
>  >             close STDERR; open STDERR, ">/dev/null";
>  >
>  > MT::Object->driver; # <-- CHANGE THIS LINE TO THIS
>  >             MT::ObjectDriverFactory->configure();
>  >             $func->();
>  >             CORE::exit(0) if defined($pid) && !$pid;
>  >         } else {
>  > MT::Object->driver; # <-- CHANGE THIS LINE TO THIS
>  >             MT::ObjectDriverFactory->configure();
>  >             return 1;
>  >         }
>  >     }
>  > }
>  >
>  > Fumiaki Yoshimatsu
>  > Movable Type Engineering,
>  > Six Apart K.K.
>  >
>  > P.S.
>  >
>  > The environment I have been testing on:
>  > * CentOS 3.1 ( "server" install )
>  > * Apache 2.0.46 ( installed in CentOS installer )
>  > * MySQL 4.0.26 ( installed manually )
>  > * DBI 1.32 ( default )
>  > ** DBD::mysql 2.1021 ( default )
>  >
>  >
>  > _______________________________________________
>  > MTOS-dev mailing list
>  > MTOS-dev at sixapart.com
>  > http://www.sixapart.com/mailman/listinfo/mtos-dev
>
>  _______________________________________________
>  MTOS-dev mailing list
>  MTOS-dev at sixapart.com
>  http://www.sixapart.com/mailman/listinfo/mtos-dev
>


More information about the MTOS-dev mailing list