List:General Discussion« Previous MessageNext Message »
From:Reindl Harald Date:October 12 2012 2:02pm
Subject:Re: innodb_lock_wait_timeout
View as plain text  

Am 12.10.2012 15:39, schrieb Markus Falb:
> With a low timeout the connection will be terminated sooner, but if the
> application retries another connection is taken. I could have raised the
> timeout with the same effect on the db side (1 process is waiting) but
> maybe more performant (no new connection necessary) and with simpler
> logic on the application side (no retry logic)
> 
> Maybe you imply that there is some kind of sleep before the retry, so
> that other statements could be fulfilled?
> 
> I still don't get it

usually if you implement a db-layer with reconnect on error
you will also make a sleep before re-connect

below the relevant snippet of my since years used mysql-layer
this is from the connect-method, the query()-method itself
does disconect/connect on recoverable errors and try the same
query again after a succesfull re-connect

the intention here was to allow restart mysqld at every time
without breaking webserver-requests, usually you do not recognize
the short lag, and yes - this sort of error-handling relaxes locks

     $rw = @mysqli_real_connect($this->conn, $this->host, $this->user,
$this->pwd, $this->db, $this->port, '', $flags);
     if(!$rw)
     {
      for($retry=1; $retry<=240; $retry++)
      {
       $this->conn = @mysqli_init();
       if($this->ssl)
       {
        if($this->ssl_crt === '')
        {
         $this->ssl_crt = 'dummy.crt';
        }
        /** SSL aktivieren */
        $this->conn->ssl_set($this->ssl_key, $this->ssl_crt, $this->ssl_ca,
NULL, NULL);
       }
       $rw = @mysqli_real_connect($this->conn, $this->host, $this->user,
$this->pwd, $this->db, $this->port, '',
$flags);
       if($rw)
       {
        $this->conn = @mysqli_init();
        if($this->ssl)
        {
         if($this->ssl_crt === '')
         {
          $this->ssl_crt = 'dummy.crt';
         }
         $this->conn->ssl_set($this->ssl_key, $this->ssl_crt,
$this->ssl_ca, NULL, NULL);
        }
        $rw = @mysqli_real_connect($this->conn, $this->host, $this->user,
$this->pwd, $this->db, $this->port, '',
$flags);
        break;
       }
       usleep(62500);
      }
      if(!$rw)
      {
       $this->conn = 0;
       $this->error(mysqli_connect_error());
      }
     }


Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Thread
innodb_lock_wait_timeoutMarkus Falb11 Oct
  • Re: innodb_lock_wait_timeoutJohan De Meersman11 Oct
    • Re: innodb_lock_wait_timeoutAndrĂ©s Tello11 Oct
      • Re: innodb_lock_wait_timeoutAkshay Suryavanshi11 Oct
        • RE: innodb_lock_wait_timeoutRick James11 Oct
    • Re: innodb_lock_wait_timeoutMarkus Falb12 Oct
      • Re: innodb_lock_wait_timeoutReindl Harald12 Oct
        • Re: innodb_lock_wait_timeoutMichael Dykman12 Oct
      • Re: innodb_lock_wait_timeoutJohan De Meersman15 Oct
  • Re: innodb_lock_wait_timeoutPerrin Harkins11 Oct
Re: innodb_lock_wait_timeoutJohan De Meersman15 Oct