Oracle 5.0 Reference Manual page 2595

Table of Contents

Advertisement

Mysqlnd replication and load balancing plugin (mysqlnd_ms)
The above example will output:
GTID after transaction 7
GTID after transaction 8
Applications can ask PECL mysqlnd_ms for a global transaction ID which belongs to the last write
operation performed by the application. The function
the GTID obtained when executing the SQL statement from the
global_transaction_id_injection
be called after the GTID has been incremented.
Applications are adviced not to run the SQL statement themselves as this bares the risk of accidently
causing an implicit GTID increment. Also, if the function is used, it is easy to migrate an application
from one SQL statement for fetching a transaction ID to another, for example, if any MySQL server
ever features built-in global transaction ID support.
The quickstart shows a SQL statement which will return a GTID equal or greater to that created for the
previous statement. It is exactly the GTID created for the previous statement if no other clients have
incremented the GTID in the time span between the statement execution and the
GTID. Otherwise, it is greater.
Example 20.243. Plugin config: Checking for a certain GTID
{
"myapp": {
"master": {
"master_0": {
"host": "localhost",
"socket": "\/tmp\/mysql.sock"
}
},
"slave": {
"slave_0": {
"host": "127.0.0.1",
"port": "3306"
}
},
"global_transaction_id_injection":{
"on_commit":"UPDATE test.trx SET trx_id = trx_id + 1",
"fetch_last_gtid" : "SELECT MAX(trx_id) FROM test.trx",
"check_for_gtid" : "SELECT trx_id FROM test.trx WHERE trx_id >= #GTID",
"report_error":true
}
}
}
Example 20.244. Session consistency service level and GTID combined
<?php
$mysqli = new mysqli("myapp", "username", "password", "database");
if (!$mysqli)
/* Of course, your error handling is nicer... */
die(sprintf("[%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()));
/* auto commit mode, transaction on master, GTID must be incremented */
if (!$mysqli->query("DROP TABLE IF EXISTS test") ||
!$mysqli->query("CREATE TABLE test(id INT)") ||
!$mysqli->query("INSERT INTO test(id) VALUES (1)"))
die(sprintf("[%d] %s\n", $mysqli->errno, $mysqli->error));
mysqlnd_ms_get_last_gtid
fetch_last_gtid
section from the plugins configuration file. The function may
2575
returns
entry of the
to fetch the
SELECT

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents