The DBI->trace output showed me that mysql_auto_reconnect was on when the script was run by Apache.

Note that this is true even if you don't have Apache::DBI (which completely overloads disconnect), and even if you don't have mod_perl. DBD::mysql checks for MOD_PERL or GATEWAY_INTERFACE in the env, and if it sees them, turns on mysql_auto_reconnect on the handle when you connect. (perldoc DBD::mysql for details.)

So in my case I needed to explicitly set  $dbh->{mysql_auto_reconnect} = 0 and then call $dbh->disconnect. Otherwise, when I "verify that it's disconnected" with the ping() call, I actually reconnect first. (The ping() was really just something I was doing to make sure that Apache::DBI hadn't snuck itself back in--a debugging device.)

Thanks again for help everyone.

Oh, also, in comparing two DBI->trace outputs I wrote a hack to help diff ignore the differences in memory addresses. Here it is:

#!perl -w #use like this, if file1 and file2 are two traces of similar db operat +ions: # perl ox2read <file1 >file1scrub # perl ox2read <file2 >file2scrub # diff -c file1scrub file2scrub >mydiff use strict; my @seen_addy = (); while (my $line = <>) { foreach my $sr ( @seen_addy ) { my $search = $sr->[0]; my $replace = $sr->[1]; $line =~ s/$search/$replace/g; } while ($line =~ /(0x\w+)/) { my $search = $1; my $last_replace = @seen_addy ? $seen_addy[$#seen_addy]->[1] : + 'addy001'; my $replace = ++$last_replace; push @seen_addy, [$search, $replace]; $line =~ s/$search/$replace/g; } print $line; }

In reply to Re^3: (Solved! mysql_auto_reconnect) disconnect, then ping returns true under apache, false from command line, no Apache::DBI around. Why would this be? by msouth
in thread disconnect, then ping returns true under apache, false from command line, no Apache::DBI around. Why would this be? by msouth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.