Michael Peppler
Sybase Consulting
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
Sybase on Linux FAQ
Sybperl FAQ
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Wechsler, Steven M" <WechslerSM at bernstein dot com>
Subject: sybperl killing connections in forked procs
Date: Dec 9 1998 4:46PM

I'm having kind of an usual problem; I hope I can explain it fully.

I have a scheduler that I've written in Perl/Sybperl (DBLib), running on
Digital Unix that schedules a bunch of scripts (shell and Perl) that run
against Sybase.  The scheduler script runs (as root, so it can su to
whatever userid is requested for a particular job) on every machine on which
we run jobs, and all schedulers call a stored proc on a central Sybase
server to get a list of jobs to run.  The sequence is as follows:

while (1) {
  open connection to server
  use database
  send stored procedure request to server with dbsqlsend()
  use dbpoll() with 30 second timeout
  get returned job list if dbpoll successful, otherwise close connection and
go back to start of loop
  close connection
  foreach (job) {
    fork process;
    if in child, su to appropriate userid, run a script with system() that
calls Sybase isql; then exit;
   waitpid (-1, 1) for process(es) to complete, then go back to beginning of

Most of the time, everything works fine.   However, if a dbpoll timeout
occurs, any new child processes can no longer communicate with Sybase (via
isql; this is a somewhat rare occurrence, so I haven't yet seen what it does
to scripts that use Sybperl/DBlib) even though I'm not passing any DB
handles to the child.  Oddly enough, the parent process has no problem
opening up a new connection after the timeout; the trouble seems only to
affect the child process.

Any help would be greatly appreciated.


Steve Wechsler/Senior DB Administrator/Sanford C. Bernstein & Co. 
"Never underestimate the power of human stupidity" - Lazarus Long
Support the Anti-SPAM amendment: