in reply to share MySQL resources among threads

Two options:

  1. Confine all your interactions with the DB to a single thread.

    Have your other threads make requests to that thread, and retrieve results from it, via queues.

  2. Use DBIx::Threaded.

    If you have a degree in over-engineering and performance is not an issue, this may be the route for you.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re: share MySQL resources among threads

Replies are listed 'Best First'.
Re^2: share MySQL resources among threads
by jeanluca (Deacon) on Sep 06, 2007 at 11:39 UTC
    I just tried option 2, because I get the impression that I only have to change the connect statement, right ?

    Anyway, it worked. However when the server stops I get the following:
    (in cleanup) Can't call method "FETCH" on an undefined value a +t /usr/lib/perl5/site_perl/5.8.8/DBIx/Threaded.pm line 1727 during gl +obal destruction. (in cleanup) Can't call method "FETCH" on an undefined value a +t /usr/lib/perl5/site_perl/5.8.8/DBIx/Threaded.pm line 1727 during gl +obal destruction. (in cleanup) Can't call method "FETCH" on an undefined value a +t /usr/lib/perl5/site_perl/5.8.8/DBIx/Threaded.pm line 1727 during gl +obal destruction. (in cleanup) Can't call method "FETCH" on an undefined value a +t /usr/lib/perl5/site_perl/5.8.8/DBIx/Threaded.pm line 1727 during gl +obal destruction. (in cleanup) Can't call method "FETCH" on an undefined value a +t /usr/lib/perl5/site_perl/5.8.8/DBIx/Threaded.pm line 1727 during gl +obal destruction. A thread exited while 4 threads were running.
    Any suggestions what might be the reason of this message ?
      Looks like another instance where the object and tied hash get DESTROYed in an odd order. Note that the DESTROY() for DBIx::Threaded::db wraps the same code in an eval{} to make it go away, so I'd suggest trying the same. Just edit your copy of Threaded.pm at line 1727 to
      eval { $obj->{_inner}--; $obj->_send_simplex('DESTROY') unless $obj->{_inner}; };
      and that should silence the errors.

      Perl Contrarian & SQL fanboy