xaRecover method
xa_recover: list every XID currently in the XaState.prepared
state on the resource manager. Used after process restart to
discover branches awaiting a Phase 2 decision.
Resume each XID with xaResumePrepared and call
XaTransactionHandle.commitPrepared / XaTransactionHandle.rollbackPrepared
per the Transaction Manager's recovery decision.
Returns an empty list when no prepared XIDs exist; returns
null on FFI failure (call getStructuredErrorForConnection).
Implementation
List<Xid>? xaRecover(int connectionId) {
final count = _native.xaRecoverCount(connectionId);
if (count < 0) return null;
final out = <Xid>[];
for (var i = 0; i < count; i++) {
final entry = _native.xaRecoverGet(i);
if (entry == null) continue;
// Skip malformed neighbours that violated X/Open length limits
// instead of aborting recovery for every prepared branch.
if (entry.gtrid.isEmpty ||
entry.gtrid.length > 64 ||
entry.bqual.length > 64) {
continue;
}
out.add(
Xid(
formatId: entry.formatId,
gtrid: entry.gtrid,
bqual: entry.bqual,
),
);
}
return out;
}