php-doc-en/reference/mysqlnd_ms/functions/mysqlnd-ms-xa-gc.xml
2015-01-27 16:18:12 +00:00

148 lines
4.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.mysqlnd-ms-xa-gc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mysqlnd_ms_xa_gc</refname>
<refpurpose>Garbage collects unfinished XA transactions after severe errors</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type>
<methodname>mysqlnd_ms_xa_gc</methodname>
<methodparam><type>mixed</type><parameter>connection</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>gtrid</parameter></methodparam>
<methodparam choice="opt"><type>boolean</type><parameter>ignore_max_retries</parameter></methodparam>
</methodsynopsis>
<para>
Garbage collects unfinished XA transactions.
</para>
<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.
</para>
<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.
</para>
<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.
</para>
<para>
Garbage collection can also be performed automatically in the background.
See the plugin configuration directive <literal>garbage_collection</literal>
for details.
</para>
<note>
<title>Experimental</title>
<para>
The feature is currently under development. There may be issues and/or
feature limitations. Do not use in production environments.
</para>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>connection</parameter></term>
<listitem>
<para>
A MySQL connection handle obtained from any of the
connect functions of the <link linkend="ref.mysqli">mysqli</link>,
<link linkend="ref.mysql">mysql</link> or
<link linkend="ref.pdo-mysql">PDO_MYSQL</link> extensions.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>gtrid</parameter></term>
<listitem>
<para>
Global transaction identifier (gtrid). If given, the garbage
collection considers the transaction only. Otherwise,
the state store is scanned for any unfinished transaction.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>ignore_max_retries</parameter></term>
<listitem>
<para>
Whether to ignore the plugin configuration <literal>max_retries</literal> setting.
If garbage collection continuously fails and the <literal>max_retries</literal>
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 <literal>max_retries = 0</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns &true; if garbage collection was successful. Otherwise, returns &false;
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member>
<link linkend="mysqlnd-ms.quickstart.xa_transactions">Quickstart XA/Distributed transactions</link>
</member>
<member>
<link linkend="mysqlnd-ms.configuration">Runtime configuration</link>
</member>
<member>
<link linkend="ini.mysqlnd-ms-plugin-config-v2.xa">State store configuration</link>
</member>
<member>
<function>mysqlnd_ms_get_stats</function>
</member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->