I would like to provide power-users with a CGI interface to a database;
this interface would allow arbitrary SQL. I would also like to be able to
throttle queries that take too long to stop the db server getting backed
up with killer queries.

Right now I am doing this:

                my $tag = "kill$$"."TAG";
                my $tagf = "/tmp/$tag";
                system("touch $tagf && chmod 777 $tagf && sleep 15 &&
                        test -f $tagf && kill -9 $$ && rm $tagf &");

                # execute query
                $results = $dbh->do(...)

                # inactivate killer
                system("rm $tagf &");

                # print results....

However, this isn't much good as it just kills the CGI process, the killer
query carries on running on the db server.

I have thought about extending my hacky shell kill pipe to also run
mysqladmin -kill and whatever the postgresql equivalent is, but then
thought:

  - way too messy and hacky
  - someone must have solved this one already

However, I couldn't find any module for dealing with this. Any
suggestions?

Cheers
Chris

Reply via email to