Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-742

LP:803649 - Xa recovery failed on client disconnection

    XMLWordPrintable

Details

    Description

      Dispite prepare phase have been rich you will get nothing when doing a xa recover if the client get disconnected befor commit

      In the following php script an error is generated to force the COMMIT to failed cf:XA COMMITEE and close the connection.

       
      <?php
       
      $dt = date_create();
      $xid = date_timestamp_get($dt);
      echo "xid : ".$xid;
       
      $logger1 = new mysqli('localhost', 'root', 'xxxxx', 'test');
      if (mysqli_connect_error()) {
          die('Erreur de connexion (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
      }
      $potest = new mysqli('192.168.45.166', 'test', 'xxxxxxx', 'test');
      if (mysqli_connect_error()) {
          $logger1->close();
          die('Erreur de connexion (' . mysqli_connect_errno() . ') '. mysqli_connect_error());
      }
       
      echo 'SuccËs logger1 ' . $logger1->host_info . "\n";
      echo 'SuccËs potest ' . $potest->host_info . "\n";
       
       
      ##################################
      $queryXA = 'XA START "'.$xid.'"';
       
      $queryRes = $logger1->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide logger1: ' . $logger1->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
      $queryRes = $potest->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide potest: ' . $potest->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
      ##################################
       
       
      ##################################
      $queryXA = 'INSERT INTO mthoxa(xamtho_tc) values ("'.$xid.'")';
      $queryRes = $logger1->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide logger1: ' . $logger1->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
       
      $queryRes = $potest->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide logger1: ' . $logger1->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
      ##################################
       
       
      ##################################
      $queryXA = 'XA END "'.$xid.'"';
       
      $queryRes = $logger1->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide logger1: ' . $logger1->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
      $queryRes = $potest->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide potest: ' . $potest->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
      ##################################
       
       
      ##################################
      $queryXA = 'XA PREPARE "'.$xid.'"';
      $queryRes = $logger1->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide logger1: ' . $logger1->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
       
      $queryRes = $potest->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide potest: ' . $potest->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
       
      ##################################
       
       
      ##################################
      $queryXA = 'XA COMMIT "'.$xid.'"';
      $queryRes = $logger1->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide logger1: ' . $logger1->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          $logger1->close();
          $potest->close();
          die($message);
      }
       
      $queryXA = 'XA COMMITEE "'.$xid.'"';
      $queryRes = $potest->query($queryXA);
      if (!$queryRes) {
          $message  = 'RequÍte invalide potest: ' . $potest->error . "\n";
          $message .= 'RequÍte complËte : ' . $queryXA;
          
          $queryXA = 'XA RECOVER';
          $queryRes = $potest->query($queryXA);
          while ($r=$queryRes->fetch_assoc())
          	print_r($r);
          
          
          $logger1->close();
          $potest->close();
          die($message);
      }
      ##################################
       
      $logger1->close();
      $potest->close();
       
      echo "Finish !\n"
       
      ?>

      Attachments

        Issue Links

          Activity

            People

              Elkin Andrei Elkin
              stephanevaroqui Stephane VAROQUI (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.