Re: Database transaction across multiple web requests

2006-04-01 Thread Jeff

 Original Message  
From: Enno <[EMAIL PROTECTED]>
To: Perrin Harkins <[EMAIL PROTECTED]>
Cc: Jeff <[EMAIL PROTECTED]>, modperl@perl.apache.org
Subject: Re:Database transaction across multiple web requests
Date: Fri Mar 31 2006 15:38:47



On Fri, 31 Mar 2006, Perrin Harkins wrote:


Jeff wrote:

Your application simply uses approach (b) and MySQL does the rest
automatically. So if you

  SELECT * FROM mytable WHERE something='complex' LIMIT 0,30;

and then on another page / connection:

  SELECT * FROM mytable WHERE something='complex' LIMIT 30,30;

and then...

  SELECT * FROM mytable WHERE something='complex' LIMIT 60,30;

The main hit is on the first query, and provided that the data is not
updated on the server, query 2 and query 3 are served directly from the
cache.

Have you tried this?  I was under the impression that MySQL would just
stop when it finds enough row to satisfy LIMIT, so it wouldn't cache the
whole result set.


If you have an ordered query, doesn't it have to place ALL the 
qualifying items in order before it can decide how many to return from 
whichever starting point that you asked for?




- Perrin



MySQL's cache only works for exact query matches, including the values you
use for LIMIT.

Enno



Oops - checked the docs looks like you are right! I was fooled by
  Qcache hits -> 64798787
and as most of our access is SELECT LIMIT... I assumed these
were cleverly cached. MySQL is even faster than I thought!
I have logged a feature request with them.

Sorry for the error,
Jeff




Apache::Status and B::TerseSize error

2006-04-01 Thread tom . kirkpatrick
When attempting to view mod_perl memory usage via Apache::Status, I 
encounter the following error:

Prototype mismatch: sub B::OP::size: none vs () at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 24.
 at /usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 24
require B/Size.pm called at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/TerseSize.pm line 16
B::TerseSize::BEGIN() called at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 0
eval {...} called at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 0
require B/TerseSize.pm called at (eval 18) line 3
eval 'require B::TerseSize
;' called at /usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 0

In my httpd.conf I have the following:

  PerlModule B::TerseSize
  PerlModule B::Terse

  
  SetHandler  perl-script
  PerlHandler Apache::Status
  PerlSetVar StatusOptionsAll On
  PerlSetVar StatusTerse On
  PerlSetVar StatusTerseSize On
  PerlSetVar StatusTerseSizeMainSummary On
  

The new 'Memory Usage' option shows up in the main perl-status page, but 
clicking on it results in the above error. I have the latest versions of 
B::Size & B::TerseSize installed and am Apache 1.3 running on FreeBSD. Any 
ideas how I can get this to work?

many thanks


-- 
Tom Kirkpatrick
Web Developer - Virus Bulletin


Re: Apache::Status and B::TerseSize error

2006-04-01 Thread tom . kirkpatrick
I also get this in the logs:

Can't locate object method "size" via package "\b" at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 28,  line 
6.\n




[EMAIL PROTECTED] 
01/04/2006 12:18

To
modperl@perl.apache.org
cc

Subject
Apache::Status and B::TerseSize error






When attempting to view mod_perl memory usage via Apache::Status, I 
encounter the following error:

Prototype mismatch: sub B::OP::size: none vs () at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 24.
 at /usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 24
require B/Size.pm called at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/TerseSize.pm line 16
B::TerseSize::BEGIN() called at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 0
eval {...} called at 
/usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 0
require B/TerseSize.pm called at (eval 18) line 3
eval 'require B::TerseSize
;' called at /usr/local/lib/perl5/site_perl/5.8.7/mach/B/Size.pm line 0

In my httpd.conf I have the following:

  PerlModule B::TerseSize
  PerlModule B::Terse

  
  SetHandler  perl-script
  PerlHandler Apache::Status
  PerlSetVar StatusOptionsAll On
  PerlSetVar StatusTerse On
  PerlSetVar StatusTerseSize On
  PerlSetVar StatusTerseSizeMainSummary On
  

The new 'Memory Usage' option shows up in the main perl-status page, but 
clicking on it results in the above error. I have the latest versions of 
B::Size & B::TerseSize installed and am Apache 1.3 running on FreeBSD. Any 

ideas how I can get this to work?

many thanks


-- 
Tom Kirkpatrick
Web Developer - Virus Bulletin



-- 
Tom Kirkpatrick
Web Developer - Virus Bulletin


Apache error logging under mod_perl

2006-04-01 Thread Jonathan Field

Hi all,

I've noticed that under mod_perl any die() (or croak()) calls get rewritten 
with a timestamp, a loglevel flag, and escaped newlines before going to the 
error log.  For example, under CGI if I call die("hello") from a script called 
foo.cgi I get:


  hello at /home/zappos/zappos.com/serverroot/foo/foo.cgi line 8.

However, if I put the same exact script under mod_perl using Apache::Registry I 
get:


  [Sat Apr  1 13:25:56 2006] [error] hello at 
/usr/lib/perl5/site_perl/5.8.6/i586-linux-thread-multi/Apache/Registry.pm

  line 149\n

Has this always been the case?  For some reason I feel like this is a change, 
but I don't have any machines around with old mod_perl versions to try it out.


I am wondering if there is any way around this... or if it is due to some kind 
of configuration error on my part.  As it stands the error becomes pretty 
obfuscated.  And it causes problems if you use croak() from within a module, 
since it no longer respects the trailing newline you get confusing messages 
like:


  [Sat Apr  1 13:49:31 2006] [error] DBD::mysql::st execute failed:
  Unknown column 'foobar' in 'field list' at 
/usr/lib/perl5/site_perl/JF/Database.pm

  line 170.\n at /home/zappos/zappos.com/serverroot/noauth/foo.cgi line 10\n

I guess what I am wondering is if there is a way to prevent this rewriting?  I 
understand the benefit of the timestamp, but the change in newline (and tab) 
handling causes problems for formatting suscinct and clear error messages. 
I've tried using CORE::die() and it seems to have the same behavior.  I was 
able to get things back to normal with:


  $SIG{__DIE__} = sub { print STDERR @_; exit 1; };

At the top of my script.  I could put this in a startup file or something, but 
I am a bit wary of mucking with signal handlers (even perl internal ones) 
across the whole system.


Anyways, thanks for any input.  My system info is below.

Jonathan Field
zappos.com

PS - The searchable mailing list archive URL that goes out in the inital 
subscription email is no longer valid: http://mathforum.org/epigone/modperl

I tried some usenet searches but couldn't find anything.

---
System Info
---

Apache Startup:

[Sat Apr  1 14:03:40 2006] [notice] Apache/1.3.33 (Unix) mod_perl/1.29 
mod_ssl/2.8.24 OpenSSL/0.9.7e configured -- resuming normal operations



[EMAIL PROTECTED]: .../JF]$ uname -a
Linux dev1 2.6.11.4-20a-smp #1 SMP Wed Mar 23 21:52:37 UTC 2005 i686 i686 i386 
GNU/Linux



[EMAIL PROTECTED]: .../JF]$ perl -V
Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
  Platform:
osname=linux, osvers=2.6.9, archname=i586-linux-thread-multi
uname='linux salieri 2.6.9 #1 smp fri jan 14 15:41:33 utc 2005 i686 athlon 
i386 gnulinux '
config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr -Dinstallusrbinperl 
-Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm -Duseshrplib=true -Doptimize=-O2 
-march=i586 -mcpu=i686 -fmessage-length=0 -Wall -g -Wall -pipe'

hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define 
usemultiplicity=define

useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
  Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS 
-DDEBUGGING -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64',
optimize='-O2 -march=i586 -mcpu=i686 -fmessage-length=0 -Wall -g -Wall 
-pipe',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -DDEBUGGING 
-fno-strict-aliasing -pipe'
ccversion='', gccversion='3.3.5 20050117 (prerelease) (SUSE Linux)', 
gccosandvers=''

intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', 
lseeksize=8

alignbytes=4, prototype=define
  Linker and Libraries:
ld='cc', ldflags =''
libpth=/lib /usr/lib /usr/local/lib
libs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.3.4'
  Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E 
-Wl,-rpath,/usr/lib/perl5/5.8.6/i586-linux-thread-multi/CORE'

cccdlflags='-fPIC', lddlflags='-shared'


Characteristics of this binary (from libperl):
  Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS USE_LARGE_FILES 
PERL_IMPLICIT_CONTEXT

  Built under linux
  Compiled at Mar 19 2005 17:34:48
  @INC:
/usr/lib/perl5/5.8.6/i586-linux-thread-multi
/usr/lib/perl5/5.8.6
/usr/lib/perl5/site_perl/5.8.6/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.6
/usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.6/i586-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.6
/usr/lib/perl5/vendor_perl