Re: Apache::DBI on mp2
Ask Bjoern Hansen wrote: On Fri, 7 Mar 2003, Stas Bekman wrote: If the physical connection is still there, would the database server do a rollback? If earlier the rollback worked correctly with $dbh ||= connect();, this will work the same, since it performs the same operation, but rips off only parts of $dbh, because of the constraints of sharing Perl datastructures and underlying C structs. Apache::DBI explicitly calls $dbh->rollback (when things are configured so it makes sense). Or maybe I am completely misunderstanding you. All I was saying is, that whatever worked for Apache::DBI will work for internal pooling. ps. yes, your DBI::Pool work is great. Thank you. :-) My pleasure. Thanks for the kind words. It's quite challenging, though you stop getting excited about segfaults and ddd (gdb frontend) is nowadays my best friend ;) :-) You are quite the masochist if you ever got excited about segfaults. I only recall segfaults making me slam my head into the wall to conceal the pain. I meant in the way that when something is repeated too many times it's not the same anymore ;) so s/excited/annoyed/ will do ;) __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Apache::DBI on mp2
On Fri, 7 Mar 2003, Stas Bekman wrote: > > If the physical connection is still there, would the database server > > do a rollback? > > If earlier the rollback worked correctly with > $dbh ||= connect();, this will work the same, since it performs the same > operation, but rips off only parts of $dbh, because of the constraints of > sharing Perl datastructures and underlying C structs. Apache::DBI explicitly calls $dbh->rollback (when things are configured so it makes sense). Or maybe I am completely misunderstanding you. > > ps. yes, your DBI::Pool work is great. Thank you. :-) > > My pleasure. Thanks for the kind words. It's quite challenging, though you > stop getting excited about segfaults and ddd (gdb frontend) is nowadays my > best friend ;) :-) You are quite the masochist if you ever got excited about segfaults. I only recall segfaults making me slam my head into the wall to conceal the pain. - ask -- ask bjoern hansen, http://www.askbjoernhansen.com/ !try; do();
Re: Apache::DBI on mp2
Ask Bjoern Hansen wrote: On Thu, 6 Mar 2003, Stas Bekman wrote: re: rollback, the DBD drivers will perform the normal disconnect(), but without doing the physical disconnect, and normal DESTROY, without destroying the datastructures which maintain the physical connection, so there shouldn't be much to change for this feature. If the physical connection is still there, would the database server do a rollback? If earlier the rollback worked correctly with $dbh ||= connect();, this will work the same, since it performs the same operation, but rips off only parts of $dbh, because of the constraints of sharing Perl datastructures and underlying C structs. ps. yes, your DBI::Pool work is great. Thank you. :-) My pleasure. Thanks for the kind words. It's quite challenging, though you stop getting excited about segfaults and ddd (gdb frontend) is nowadays my best friend ;) __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Apache::DBI on mp2
On Thu, 6 Mar 2003, Stas Bekman wrote: > re: rollback, the DBD drivers will perform the normal disconnect(), but > without doing the physical disconnect, and normal DESTROY, without destroying > the datastructures which maintain the physical connection, so there shouldn't > be much to change for this feature. If the physical connection is still there, would the database server do a rollback? - ask ps. yes, your DBI::Pool work is great. Thank you. :-) -- ask bjoern hansen, http://www.askbjoernhansen.com/ !try; do();
Re: Apache::DBI on mp2
Perrin Harkins wrote: Stas Bekman wrote: FWIW, we are discussing the internal DBI pooling mechanism at the dbi-dev list and having already a sort-of-working prototype. So hopefully there will be no need for Apache::DBI in the near future, as DBI will be able to handle pooling internally. However it may take some time, as the drivers will have to adjust to support the new functionality. You can see the thread here: http://archive.develooper.com/[EMAIL PROTECTED]/index.html#02118 Some working examples are attached to this message: http://archive.develooper.com/[EMAIL PROTECTED]/msg02134.html This is totally cool, Stas! Nice work. I look forward to answering "yes" when people ask if mod_perl has database connections pooling. ;) actually it's going to be: "if perl has database connections pooling", which will include mod_perl by definition. Also, the pooling mechanism should work transparently w/ and w/o threads on the user level. By the way, to completely get rid of Apache::DBI this would need to cover the safety functionality in there as well, i.e. the pinging and the part where it rolls back any pending transactions when a a handle is returned to the pool. Certainly. Quite a few features are missing. The first step was (is) to make the dbh shared between threads (which is far from trivial). The rest should be just a matter of coding. re: rollback, the DBD drivers will perform the normal disconnect(), but without doing the physical disconnect, and normal DESTROY, without destroying the datastructures which maintain the physical connection, so there shouldn't be much to change for this feature. Only the ping() is needed to be added to connect(). __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Apache::DBI on mp2
Stas Bekman wrote: FWIW, we are discussing the internal DBI pooling mechanism at the dbi-dev list and having already a sort-of-working prototype. So hopefully there will be no need for Apache::DBI in the near future, as DBI will be able to handle pooling internally. However it may take some time, as the drivers will have to adjust to support the new functionality. You can see the thread here: http://archive.develooper.com/[EMAIL PROTECTED]/index.html#02118 Some working examples are attached to this message: http://archive.develooper.com/[EMAIL PROTECTED]/msg02134.html This is totally cool, Stas! Nice work. I look forward to answering "yes" when people ask if mod_perl has database connections pooling. By the way, to completely get rid of Apache::DBI this would need to cover the safety functionality in there as well, i.e. the pinging and the part where it rolls back any pending transactions when a a handle is returned to the pool. - Perrin
Re: Apache::DBI on mp2
Ask Bjoern Hansen wrote: On Wed, 5 Mar 2003, Stas Bekman wrote: Great. I've already committed that patch. Perhaps Ask could load 'Apache::compat' inside Apache::DBI if mp2 is used. Or to use the mp2 API if mp2 is used. That seems like it'll be an easy solution. I thought loading Apache::compat would have global side effects though? (i.e. for people trying to make their system run without Apache::compat). Please scratch that idea than ;) Though it can be documented, including the "Apache::compat warning" ;) And instead simply add the code to handle it differently if $mod_perl::VERSION >= 1.99, using the 2.0 API. __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Apache::DBI on mp2
On Wed, 5 Mar 2003, Stas Bekman wrote: > Great. I've already committed that patch. > > Perhaps Ask could load 'Apache::compat' inside Apache::DBI if mp2 is used. Or > to use the mp2 API if mp2 is used. That seems like it'll be an easy solution. I thought loading Apache::compat would have global side effects though? (i.e. for people trying to make their system run without Apache::compat). - ask -- ask bjoern hansen, http://www.askbjoernhansen.com/ !try; do();
Re: Apache::DBI on mp2
Haroon Rafique wrote: On Today at 11:16am, SB=>Stas Bekman <[EMAIL PROTECTED]> wrote: SB> FWIW, we are discussing the internal DBI pooling mechanism at the SB> dbi-dev list and having already a sort-of-working prototype. So SB> hopefully there will be no need for Apache::DBI in the near future, as SB> DBI will be able to handle pooling internally. However it may take SB> some time, as the drivers will have to adjust to support the new SB> functionality. SB> SB> You can see the thread here: SB> http://archive.develooper.com/[EMAIL PROTECTED]/index.html#02118 SB> SB> Some working examples are attached to this message: SB> http://archive.develooper.com/[EMAIL PROTECTED]/msg02134.html SB> Stas, Thanks for your response. I will try and keep up with the developments in the above-mentioned threads. However, for now, I'll focus on your alternate solution as mentioned below. If I find some free time (what are the chances?) I may also give DBI::Pool a try under mp2. I've already tried it and it works ;) However DBI::Pool won't have a life on its own and will be integrated into DBI itself and its DBD drivers. SB> [..snip..] SB> SB> If you apply the following patch (will commit it soon) against the modperl-2.0 SB> source, you will be able to use connect_on_init unmodified, assuming that SB> Apache::compat was loaded before Apache::DBI. Let me know whether it works for SB> you. SB> I'm happy to report that the patch to lib/Apache/compat.pm works. I did not even have to use CVS versions of any of the packages. Apache/2.0.44 (Gentoo/Linux) mod_perl/1.99_08 Perl/v5.8.0 I simply patched: /usr/lib/perl5/vendor_perl/5.8.0/i686-linux/Apache2/Apache/compat.pm with your patch and connect_on_init works unmodified. And as mentioned in your email, I do have Apache::compat loaded before Apache::DBI. Great. I've already committed that patch. Perhaps Ask could load 'Apache::compat' inside Apache::DBI if mp2 is used. Or to use the mp2 API if mp2 is used. __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: Apache::DBI on mp2
On Today at 11:16am, SB=>Stas Bekman <[EMAIL PROTECTED]> wrote: SB> FWIW, we are discussing the internal DBI pooling mechanism at the SB> dbi-dev list and having already a sort-of-working prototype. So SB> hopefully there will be no need for Apache::DBI in the near future, as SB> DBI will be able to handle pooling internally. However it may take SB> some time, as the drivers will have to adjust to support the new SB> functionality. SB> SB> You can see the thread here: SB> http://archive.develooper.com/[EMAIL PROTECTED]/index.html#02118 SB> SB> Some working examples are attached to this message: SB> http://archive.develooper.com/[EMAIL PROTECTED]/msg02134.html SB> Stas, Thanks for your response. I will try and keep up with the developments in the above-mentioned threads. However, for now, I'll focus on your alternate solution as mentioned below. If I find some free time (what are the chances?) I may also give DBI::Pool a try under mp2. SB> [..snip..] SB> SB> If you apply the following patch (will commit it soon) against the modperl-2.0 SB> source, you will be able to use connect_on_init unmodified, assuming that SB> Apache::compat was loaded before Apache::DBI. Let me know whether it works for SB> you. SB> I'm happy to report that the patch to lib/Apache/compat.pm works. I did not even have to use CVS versions of any of the packages. Apache/2.0.44 (Gentoo/Linux) mod_perl/1.99_08 Perl/v5.8.0 I simply patched: /usr/lib/perl5/vendor_perl/5.8.0/i686-linux/Apache2/Apache/compat.pm with your patch and connect_on_init works unmodified. And as mentioned in your email, I do have Apache::compat loaded before Apache::DBI. Cheers, -- Haroon Rafique <[EMAIL PROTECTED]>
Re: Apache::DBI on mp2
FWIW, we are discussing the internal DBI pooling mechanism at the dbi-dev list and having already a sort-of-working prototype. So hopefully there will be no need for Apache::DBI in the near future, as DBI will be able to handle pooling internally. However it may take some time, as the drivers will have to adjust to support the new functionality. You can see the thread here: http://archive.develooper.com/[EMAIL PROTECTED]/index.html#02118 Some working examples are attached to this message: http://archive.develooper.com/[EMAIL PROTECTED]/msg02134.html Haroon Rafique wrote: My setup is as follows: Apache/2.0.44 (Gentoo/Linux) mod_perl/1.99_08 Perl/v5.8.0 mod_perl was built from CVS. I was interested in getting Apache::DBI to run under mp2. I did read Ask's message at http://marc.theaimsgroup.com/?l=apache-modperl&m=104225578207460&w=2 which leads me to my question. What would it take to get connect_on_init to run under mp2? With the following patch I was able to get connect_on_init to work under mp2. Remember that my objective was to JUST get it to run. This is NOT release quality code. I'm happy to report that it works for me, so far. Anyone else who is running mp2 (no compat mode) willing to give it a try? Of course, then the gurus can come in and clean up the code so that it works under either mp1 or mp2. If you apply the following patch (will commit it soon) against the modperl-2.0 source, you will be able to use connect_on_init unmodified, assuming that Apache::compat was loaded before Apache::DBI. Let me know whether it works for you. Index: lib/Apache/compat.pm === RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v retrieving revision 1.81 diff -u -r1.81 compat.pm --- lib/Apache/compat.pm19 Feb 2003 23:55:23 - 1.81 +++ lib/Apache/compat.pm3 Mar 2003 23:49:19 - @@ -125,6 +125,16 @@ die $err if $err; } +sub push_handlers { +shift; +Apache->server->push_handlers(@_); +} + +sub set_handlers { +shift; +Apache->server->set_handlers(@_); +} + package Apache::Constants; use Apache::Const (); __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com