Hi, Paul! On Dec 02, Paul McCullagh wrote:
Now, if a binlog doesn't indicate a crash (last binlog file was closed properly, showing a normal shutdown procedure) or, for example, there're no binlog files at all, the server cannot perform the recovery - it doesn't know what transactions should be committed and what transactions should be rolled back. A transaction may be prepared in one engine and already committed (or rolled back) in another. In this case the server requests the user to make the decision, the user has to request an explicit commit or rollback with --tc-heuristic-recover command-line switch.
So if I understand this correctly, tc-heuristic-recover handles a situation that should actually never occur.
Yes, that's mainly to account for a user mistake - deleting binlog after a crash or copying the live datadir from master to a slave without binlog. Or something similar.
But if there's only one XA-capable storage engine, it's always safe to rollback all prepared transactions, there can be no other engine that has them committed. That's what the ifdef-ed code does - if InnoDB is the only XA-capable storage engine on recovery without binlog it forces a rollback of all not committed transactions, preserving the pre-XA InnoDB behavior.
So, in fact, we could change this code:
to:
if (total_ha_2pc == (ulong) opt_bin_log+1) { tc_heuristic_recover= TC_HEURISTIC_RECOVER_ROLLBACK; // forcing ROLLBACK info.dry_run=FALSE; }
I intentionally did it with ifdef - the idea was that if there could *possibly* be another XA-engine, we need to go the safe way. Otherwise one could, for example, restart the server with disabled pbxt and unknowingly enable auto-rollback mode, causing inconsistent data. Regards / Mit vielen Grüßen, Sergei -- __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@sun.com> / /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server Architect /_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München 161028 <___/ Sonnenallee 1, 85551 Kirchheim-Heimstetten Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel Vorsitzender des Aufsichtsrates: Martin Häring