MySQL/MariaDB XA RECOVER changes
The current code in liblixamy.c is just using XA RECOVER statement as below, but I discovered is probably not running as expected for MySQL 8.0.x, at least 8.0.41.
Executing the command:
/opt/lixa/bin/lixar -p -b
it's possible to get something like this in the trace:
2025-03-16 19:40:23.388389 [18734/139717313821632] lixa_my_recover
2025-03-16 19:40:23.388396 [18734/139717313821632] lixa_my_recover_core
2025-03-16 19:40:23.388399 [18734/139717313821632] lixa_my_recover_core: executing XA RECOVER
2025-03-16 19:40:23.388605 [18734/139717313821632] lixa_my_recover_core: num_fields=4
2025-03-16 19:40:23.388623 [18734/139717313821632] lixa_my_recover_core: formatID=1279875137, gtrid_length=16, bqual_length=16, data=j<A8><B6>3.,I<AD><8E>^Zjl7^^G(<98><82><D2><D7><F3><98>O<AF>I<AB><93><A3><AC>^P<AA><D4><F5>
2025-03-16 19:40:23.388627 [18734/139717313821632] lixa_my_xid_deserialize: formatID='1279875137', gtrid_length='16', bqual_length='16', data='j<A8><B6>3.,I<AD><8E>^Zjl7^G(<98><82><D2><D7><F3><98>O<AF>I<AB><93><A3><AC>^P<AA><D4><F5>'
2025-03-16 19:40:23.388631 [18734/139717313821632] lixa_my_xid_deserialize: 'j<A<A8><B6>3.,I<AD><8E>^Zjl7^G(<98><82><D2><D7><F3><98>O<AF>I<AB><93><A3><AC>^P<AA><D4><F5>' invalid characters found:
2025-03-16 19:40:23.388633 [18734/139717313821632] lixa_my_recover_core: unable to deserialize the XID retrieved with XA RECOVER
2025-03-16 19:40:23.388638 [18734/139717313821632] lixa_my_recover_core/excp=6/xa_rc=0
2025-03-16 19:40:23.388640 [18734/139717313821632] lixa_my_recover/excp=1/xa_rc=0
unfortunately the lixar utility silently proceeds and the result is that it does not report transactions that requires a recovery.
The current deserialization code in lixa_my_xid_deserialize function is absolutely not able to deal with binary data:
p = data;
for (i=0; i<s; ++i) {
q = p+1;
if (((*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f')) &&
((*q >= '0' && *q <= '9') || (*q >= 'a' && *q <= 'f'))) {
tmp[0] = *p;
tmp[1] = *q;
sscanf(tmp, "%x", &b);
xid->data[i] = b;
} else {
LIXA_TRACE(("lixa_my_xid_deserialize: '%s' invalid "
"characters found:\n", p));
return FALSE;
}
p += 2;
}
I'm supposing something changed from MySQL 5 and MySQL 8.
The bad news is described as
XID values may contain nonprintable characters. XA RECOVER permits an optional CONVERT XID clause so that clients can request XID values in hexadecimal.
and the syntax is:
XA RECOVER CONVERT XID
at the end of the page: https://dev.mysql.com/doc/refman/8.4/en/xa-statements.html
Unfortunately for MariaDB a different syntax applies:
XA RECOVER [FORMAT=['RAW'|'SQL']]
as described here: https://mariadb.com/kb/en/xa-transactions/
Additional info for MySQL are available here: https://www.mydbops.com/blog/troubleshooting-xa-transactions-in-mysql