PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Ellery, Michael BGI SF" <Michael dot Ellery at barclaysglobal dot com>
Subject: CTlib Error Hangs Script
Date: Mar 24 1999 2:04AM

I posted something about this problem a few days ago.  Since that time, I
have put together a test script that verifies (I think..) my problem.  The
basic problem is this--a certain error message causes my scripts to blow-up.
Exactly where, when, or if they blow up is totally unpredictable, but the
blow-up is always preceded by one or more occurrences of the following
errors:

---------------------------------------------------------------
Open Client Message:  (In msg_cb)
Message Number: LAYER = 5  ORIGIN = 3 
                SEVERITY = 4  NUMBER = 2 
Message String:  ct_connect(): network packet layer: internal net library
error: Attempt to use invalid address handle
---------------------------------------------------------------

Here is the test script that I put together -- it basically loops 100 times
and tries to set-up 5 simultaneous connections (note that the user/passwd
have been commented out).

---------------------------------------------------------------
#!/tools/common/bin/perl5.00404 -w

use Sybase::CTlib;

$ENV{SYBASE} = "/opt/sybase";
$ENV{SYBBIN} = "/opt/sybase/bin";
$ENV{DSQUERY} = "SF_DEV3";

$main::DB_USER =  "XXXXXX"; # Commented out
$main::DB_PWD =   "XXXXXX"; # Commented out
$main::SERVER =   "SF_DEV3";
$main::DATABASE = "beacon_db";

#select STDOUT; $| = 1;
#select STDERR; $| = 1;
      
ct_callback(CS_CLIENTMSG_CB, \&main::msg_cb);
ct_callback(CS_SERVERMSG_CB, \&main::srv_cb);

my $i;

  print "\n\n######################################\n";
  print "Starting TESTING\n";
  print "For Server: $main::SERVER and DB: $main::DATABASE\n ";
  print "######################################\n\n";
 
  for ($i = 0 ; $i <100 ; $i++) {
    &makeConnect(0,$i);
  }
  
  exit(0);

######## makeConnect ########

sub makeConnect {
  my $count = shift;
  my $iter = shift;
  
  my ($dbh,$result,$ref, );

  return if $count > 5;
  
  # Establish a connection onto the database server.
  
#  eval {$dbh = new Sybase::CTlib $main::DB_USER, $main::DB_PWD,
$main::SERVER};
  $dbh = new Sybase::CTlib $main::DB_USER, $main::DB_PWD, $main::SERVER;
  
#  print "**ITERATION $iter, LEVEL $count: \$\@ is $@.\n";
  
  if ($dbh == CS_FAIL) {
    print "**ITERATION $iter, LEVEL $count: Error connecting to DB:
$main::SERVER.\n";
    return;
  }
  else {
    print "**ITERATION $iter, LEVEL $count: Successfully connected to DB:
$main::SERVER.\n";
  }
 
  $dbh->ct_sql("use $main::DATABASE");

  $ref = $dbh->ct_sql("select 1");
  $result = $ref->[0]->[0];
  
  print "**ITERATION $iter, LEVEL $count: Selected $result.\n";

  $count++;
  
  &makeConnect($count,$iter);
  
  return;
}


######## msg_cb ########

sub msg_cb {
  my ($layer, $origin, $severity, $number, $msg, $osmsg) = @_;


  print "\nOpen Client Message:  (In msg_cb)\n";
  print "Message Number: LAYER = $layer  ORIGIN = $origin \n";
  print "                SEVERITY = $severity  NUMBER = $number \n";
  print "Message String:  $msg\n";

  if (defined($osmsg)) {
    print "Operating System Error:  $osmsg\n";
  }  #END if
 
  return CS_SUCCEED;

}  #END msg_cb


######## srv_cb ########

sub srv_cb {
  my ($cmd, $number, $severity, $state, $line, $server, $proc, $msg) = @_;

  return CS_SUCCEED if $number == 5701;
  
  print "\nServer Message:  (In srv_cb)\n";
  print "Message Number: NUMBER = $number  STATE = $state \n";
  print "                SEVERITY = $severity  LINE = $line \n";
  print "Message String:  $msg\n";

  if (defined($server)) {
    print "Server:  $server\n";
  }  #END if
  
  if (defined($proc)) {
    print "Procedure:  $proc\n";
  }  #END if
 
  return CS_SUCCEED;

}  #END srv_cb
---------------------------------------------------------------


I am attaching the output from one run that blew-up.  You can see that it
makes it to approx. iteration 80 and then stops cold.  Even worse, here's
what the process does at that point:

      TTY   PID USERNAME PRI NI   SIZE    RES STATE    TIME %WCPU  %CPU
COMMAND
pty/ttyp4  2613 fi-dvl   241 20  2560K  2172K run      1:36 93.73 93.56
test_conn2.pl

...whereas it normally only gobbles 8-10% of the CPU.

Not only has it stopped, but it is hogging the CPU!  This is a really
frustrating problem because it is so inconsistent - sometimes it happens,
sometimes it doesn't.  When it does happen, you can never be sure where your
script is going to actually stop and the process run away.  Also, the
blow-up only seems to happen with this particular error.  For instance, I
can put a bad password in and the connection will fail but the script won't
blow-up.  I have even occasionally gotten a few API layer (layer 1) errors
and not had the runaway problem.

Is this perhaps a problem with CTlib?  To my knowledge, we are using
OpenClient 10.3 and Sybperl 2.09.  The system is an HP 9000/856 with HP-UX.

I would greatly appreciate any input that people might have.  Has anyone
else experienced this kind of behavior from CTlib?

Apologies for the long-winded post.


 <> 
Michael Ellery
Barclays Global Investors
45 Fremont St., 6th Floor #102
San Francisco, CA  94105
(415) 908-7234 [PH],  (415) 597-2352 [FAX]
Email:  michael.ellery@barclaysglobal.com