<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Garbage collects unfinished XA transactions after severe errors</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mysqlnd-ms-xa-commit.html">mysqlnd_ms_xa_commit</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mysqlnd-ms-xa-rollback.html">mysqlnd_ms_xa_rollback</a></div> <div class="up"><a href="ref.mysqlnd-ms.html">Mysqlnd_ms Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.mysqlnd-ms-xa-gc" class="refentry"> <div class="refnamediv"> <h1 class="refname">mysqlnd_ms_xa_gc</h1> <p class="verinfo">(PECL mysqlnd_ms < 1.6.0)</p><p class="refpurpose"><span class="refname">mysqlnd_ms_xa_gc</span> — <span class="dc-title">Garbage collects unfinished XA transactions after severe errors</span></p> </div> <div class="refsect1 description" id="refsect1-function.mysqlnd-ms-xa-gc-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>mysqlnd_ms_xa_gc</strong></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$connection</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$gtrid</code></span> [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$ignore_max_retries</code></span> ]] )</div> <p class="para rdfs-comment"> Garbage collects unfinished XA transactions. </p> <p class="para"> The XA protocol is a blocking protocol. There exist cases when servers participating in a global transaction cannot make progress when the transaction coordinator crashes or disconnects. In such a case, the MySQL servers keep waiting for instructions to finish the XA transaction in question. Because transactions occupy resources, transactions should always be terminated properly. </p> <p class="para"> Garbage collection requires configuring a state store to track global transactions. Should a PHP client crash in the middle of a transaction and a new PHP client be started, then the built-in garbage collection can learn about the aborted global transaction and terminate it. If you do not configure a state store, the garbage collection cannot perform any cleanup tasks. </p> <p class="para"> The state store should be crash-safe and be highly available to survive its own crash. Currently, only MySQL is supported as a state store. </p> <p class="para"> Garbage collection can also be performed automatically in the background. See the plugin configuration directive <em>garbage_collection</em> for details. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <strong>Experimental</strong><br /> <p class="para"> The feature is currently under development. There may be issues and/or feature limitations. Do not use in production environments. </p> </p></blockquote> </div> <div class="refsect1 parameters" id="refsect1-function.mysqlnd-ms-xa-gc-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <code class="parameter">connection</code></dt> <dd> <p class="para"> A MySQL connection handle obtained from any of the connect functions of the <a href="ref.mysqli.html" class="link">mysqli</a>, <a href="ref.mysql.html" class="link">mysql</a> or <a href="ref.pdo-mysql.html" class="link">PDO_MYSQL</a> extensions. </p> </dd> <dt> <code class="parameter">gtrid</code></dt> <dd> <p class="para"> Global transaction identifier (gtrid). If given, the garbage collection considers the transaction only. Otherwise, the state store is scanned for any unfinished transaction. </p> </dd> <dt> <code class="parameter">ignore_max_retries</code></dt> <dd> <p class="para"> Whether to ignore the plugin configuration <em>max_retries</em> setting. If garbage collection continuously fails and the <em>max_retries</em> limit is reached prior to finishing the failed global transaction, you can attempt further runs prior to investigating the cause and solving the issue manually by issuing appropriate SQL statements on the participants. Setting the parameter has the same effect as temporarily setting <em>max_retries = 0</em>. </p> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-function.mysqlnd-ms-xa-gc-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <strong><code>TRUE</code></strong> if garbage collection was successful. Otherwise, returns <strong><code>FALSE</code></strong> </p> </div> <div class="refsect1 seealso" id="refsect1-function.mysqlnd-ms-xa-gc-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <a href="mysqlnd-ms.quickstart.xa_transactions.html" class="link">Quickstart XA/Distributed transactions</a> </li> <li class="member"> <a href="mysqlnd-ms.configuration.html" class="link">Runtime configuration</a> </li> <li class="member"> <a href="mysqlnd-ms.plugin-ini-json.html#ini.mysqlnd-ms-plugin-config-v2.xa" class="link">State store configuration</a> </li> <li class="member"> <span class="function"><a href="function.mysqlnd-ms-get-stats.html" class="function" rel="rdfs-seeAlso">mysqlnd_ms_get_stats()</a> - Returns query distribution and connection statistics</span> </li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mysqlnd-ms-xa-commit.html">mysqlnd_ms_xa_commit</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mysqlnd-ms-xa-rollback.html">mysqlnd_ms_xa_rollback</a></div> <div class="up"><a href="ref.mysqlnd-ms.html">Mysqlnd_ms Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>