← Back to team overview

maria-developers team mailing list archive

Re: [Merge] lp:~paul-mccullagh/maria/maria-pbxt-rc3 into lp:maria

 

Hi Sergei,

Thanks for the great explanation.

On Dec 1, 2009, at 2:50 PM, Sergei Golubchik wrote:

Hi, Paul!

On Dec 01, Paul McCullagh wrote:

Thanks for the heads-up on that!

The code in question is as follows:

#ifndef WILL_BE_DELETED_LATER
 /*
   for now, only InnoDB supports 2pc. It means we can always safely
rollback all pending transactions, without risking inconsistent data
 */
DBUG_ASSERT(total_ha_2pc == (ulong) opt_bin_log+1); // only InnoDB and binlog tc_heuristic_recover= TC_HEURISTIC_RECOVER_ROLLBACK; // forcing ROLLBACK
 info.dry_run=FALSE;
#endif

What would be the affect of removing these lines?

I'd better start from "what is the effect of these lines" :)

2PC (with a binlog) works as follows:

  prepare in all affected storage engines
  binlog write
  commit in all affected storage engines

XA recovery (with a binlog) works as follows:

ask storage engines about the prepared but not committed transactions
  ask engines to commit every such a transaction that is in a binlog
  and ask engines to rollback other prepared transactions

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.

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:

#ifndef WILL_BE_DELETED_LATER
  /*
    for now, only InnoDB supports 2pc. It means we can always safely
rollback all pending transactions, without risking inconsistent data
  */
DBUG_ASSERT(total_ha_2pc == (ulong) opt_bin_log+1); // only InnoDB and binlog tc_heuristic_recover= TC_HEURISTIC_RECOVER_ROLLBACK; // forcing ROLLBACK
  info.dry_run=FALSE;
#endif

to:

if (total_ha_2pc == (ulong) opt_bin_log+1) {
tc_heuristic_recover= TC_HEURISTIC_RECOVER_ROLLBACK; // forcing ROLLBACK
  info.dry_run=FALSE;
}


And what do you think we would need to test when we take out the lines?

Start a transaction, do some table writes. Crash the server during the
2pc, for example:

 SET @@debug="d,crash_commit_after_prepare";
 COMMIT;

delete all binlog files (or only the last one), try to start mysqld - it
should abort with an error.

OK, thanks. I will give this a try.

The error message tells what to do - I hope
you'll find it clear enough (but please complain, if not).

Will do!

Best regards,

Paul



On Dec 1, 2009, at 1:14 PM, Sergei Golubchik wrote:
On Dec 01, Paul McCullagh wrote:

This patch changes MariaDB code in one case:

File handler.cc, Line 1591

DBUG_ASSERT(total_ha_2pc == (ulong) opt_bin_log+1); // only InnoDB and
binlog

This line has been commented out, because the assertions fails now
that PBXT supports XA.

Although this assertion implies that not everything will work, I have not found any problem with the stability of MySQL due to the addition
of PBXT XA.

Eh, no, not exactly. This assertion was to make sure that the ifdef'ed
code only runs when InnoDB is the only XA-capable engine.

As it's no longer the case, you need to remove the whole ifdef block,
not only the assert.

PBXT XA can be disabled by setting pbxt_support_xa=0, it is enabled by
default.

Regards / Mit vielen Grüßen,
Sergei

--
 __  ___     ___ ____  __
/  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@xxxxxxx>
/ /|_/ / // /\ \/ /_/ / /__ 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



--
Paul McCullagh
PrimeBase Technologies
www.primebase.org
www.blobstreaming.org
pbxt.blogspot.com




Regards / Mit vielen Grüßen,
Sergei

--
  __  ___     ___ ____  __
 /  |/  /_ __/ __/ __ \/ /   Sergei Golubchik <serg@xxxxxxx>
/ /|_/ / // /\ \/ /_/ / /__ 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



--
Paul McCullagh
PrimeBase Technologies
www.primebase.org
www.blobstreaming.org
pbxt.blogspot.com






Follow ups

References