mysql:2153
From: "N.Yoshida" <"N.Yoshida" <yosh_no@xxxxxxxxxx>>
Date: Fri, 02 Jun 2000 11:39:40 +0900
Subject: [mysql 02153] mysql デーモンの負荷テストで不可解な現象
  吉田です。
  MySQLを使用したシステムを本運用しようとしてMySQLデーモンの負荷テスト
をしていたところ次のような現象が発生し困っています。何か解決のヒントが
あれば教えていただきたいと思っています。
【環境】
         DBサーバ                         APLサーバ
    ┌────────┐             ┌────────┐
    │                │             │                │
    │    MySQL←───────────テストスクリプト│
    │                │             │                │
    │                │             │                │
    └────────┘             └────────┘
  (DBサーバ)
   OS     Slackware 3.5ベースのLinux kernel(2.2.15)
   MySQL  3.22.32(3.22.30で発生したのでエンハンスしたが同じ現象発生)
   Linuxthread-0.6
   Data-Dumper-2.09
   DBI-1.13
   Msql-Mysql-modules-1.2209(1.2214でも同じ現象発生)
   Perl5.005_03 + jperl5.005_03-990403.pat
  (APLサーバ)
   OS     TurboLinux 6.0ベースのLinux kernel(2.2.15)
   他はDBサーバと同じ
【現象】
     MySQLへコネクトし、テーブルに対してselect *をかけて結果をフェッチ
   しディスコネクトする処理を無限に繰り返すPERLスクリプトを6多重で実行
   したところ10分程度でMySQLデーモンが落ちた。(アベンドまでの時間はさ
   まざま) 
     傾向としては多重度を上げればデーモンアベンドする時間が短くなるよう
   です。
     Topでmysqldを見ているとSIZEの値が徐々に増加し、4XXX位になるとデー
   モンがアベンドするようにみえます。デーモンのメモリ上のデータが壊れて
   起きているのではとも推測できますが....(SIZE値はテーブルでさまざま)
     デーモンアベンドに際して、クライアントプログラムではfetchやexecute
   がエラーとなります。(次がエラーメッセージ)
  -----------------------------------------------------------------------
  DBD::mysql::st fetchrow_array failed: fetch() without execute() 
       at dummy.pl line 47.
  または
  DBD::mysql::st execute failed: Lost connection to MySQL server during query
       at dummy.pl line 46.
  または
  DBD::mysql::st execute failed: MySQL server has gone away 
       at dummy.pl line46.
  -----------------------------------------------------------------------
==【参考】=====(スクリプト始まり)======================================
#! /usr/bin/perl -Lsjis
#--------------------------------------------------------------------
#   DBサーバ負荷耐久テスト                              dummy  .pl 
#     ダミー検索プログラム                    最終更新日  00/05/29   
#--------------------------------------------------------------------
    use DBI;
    use FileHandle;
    $dbname    = "bics";                          # MySQL
    $hostname  = "fz002086";
    $pid    = $0;                                 # PROGRAM-ID
    $num    = '^[0-9]+$';                         # 文字列の全てが数字
    $otfl1  = "$$.lst";                           # 出力ファイル名
    open (OT,">$otfl1");
    OT->autoflush(1);
    for(;;) {
      $dbh     = DBI->connect("DBI:mysql:$dbname:$hostname","root","");
      $dbh || die "connect err :$dbname:$hostname";
      $fields  =  "SYSYCD";
      $cond    =  "where SYSLVL = '2'";
      $state   =  "select $fields from SZK $cond";
      $sth = $dbh->prepare($state) || die $dbh->errstr;
      $sth->execute || die $sth->errstr;
      while (@SYSYCD = $sth->fetchrow_array) {  #検索:約120レコード◆
          &GetYMY($SYSYCD[0]);
#         sleep(5);
      }
      $sth->finish;
      $dbh->disconnect;
}
    close(OT);
sub GetYMY   {   #
    my $SYSYCD  = shift(@_);
    $SYSYCD     = substr($SYSYCD, 0, 6);
    my $dbh     = DBI->connect("DBI:mysql:$dbname:$hostname", "root", "");
    $dbh || die "connect err :$dbname:$hostname";
    my $fields  =  "*";
    my $cond    =  "where SEKACD like '$SYSYCD%'";
    my $state   =  "select $fields from YMY $cond";
    print (OT "$state\n");
    my $sth = $dbh->prepare($state) || die $dbh->errstr;
    $sth->execute || die $sth->errstr;
    while (@YMY = $sth->fetchrow_array) {   #検索:数100~1000レコード◆
      printf("(@YMY)\n");          #perl dummy3ny.pl>/dev/null&で起動◆
    }
    $sth->finish;
    $dbh->disconnect;
}
=============(スクリプト終わり)=========================================
-------------------------------------------------------------------------
  吉田 伸次(N.Yoshida) E-mail:yosh_no@xxxxxxxxxx
                       nifty :TCN00171@xxxxxxxxxx
-------------------------------------------------------------------------
-> 2153 2000-06-02 11:39 ["N.Yoshida" <yosh_no] mysql デーモンの負荷テストで不可解な現象 2154 2000-06-02 17:32 ┗[<takeshi@xxxxxxxxxx>] 2156 2000-06-02 20:12 ┗["N.Yoshida" <yosh_no] 2158 2000-06-02 22:43 ┗[<takeshi@xxxxxxxxxx>] 2163 2000-06-05 14:58 ┗["N.Yoshida" <yosh_no] 2164 2000-06-05 16:14 ┗[Seiji Tateyama <tate] 2165 2000-06-05 19:41 ┗["N.Yoshida" <yosh_no] 2166 2000-06-05 21:44 ┣[<takeshi@xxxxxxxxxx>] 2188 2000-06-10 19:27 ┃┗["N.Yoshida" <yosh_no] 2167 2000-06-06 01:42 ┗[tateyan <tateyan@xxx] 2168 2000-06-06 10:22 ┗["N.Yoshida" <yosh_no]