Commit ec372b09 authored by unknown's avatar unknown
Browse files

print xa recovery progress

add names to handlertons
trans_need_2pc() macro


sql/examples/ha_archive.cc:
  add names to handlertons
sql/ha_berkeley.cc:
  add names to handlertons
sql/ha_innodb.cc:
  add names to handlertons
sql/ha_ndbcluster.cc:
  add names to handlertons
sql/handler.cc:
  print xa recovery progress
sql/handler.h:
  add names to handlertons
  trans_need_2pc() macro
sql/log.cc:
  add names to handlertons
parent deabb450
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ static HASH archive_open_tables;

/* dummy handlerton - only to have something to return from archive_db_init */
static handlerton archive_hton = {
  "archive",
  0,       /* slot */
  0,       /* savepoint size. */
  0,       /* close_connection */
+1 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ static int berkeley_commit(THD *thd, bool all);
static int berkeley_rollback(THD *thd, bool all);

static handlerton berkeley_hton = {
  "BerkeleyDB",
  0, /* slot */
  0, /* savepoint size */
  berkeley_close_connection,
+2 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ have disables the InnoDB inlining in this file. */
/* TODO list for the InnoDB handler in 5.0:
  - Remove the flag trx->active_trans and look at the InnoDB
    trx struct state field
  - fix savepoint functions to use savepoint storage area
  - Find out what kind of problems the OS X case-insensitivity causes to
    table and database names; should we 'normalize' the names like we do
    in Windows?
@@ -157,6 +158,7 @@ static int innobase_savepoint(THD* thd, void *savepoint);
static int innobase_release_savepoint(THD* thd, void *savepoint);

static handlerton innobase_hton = {
  "InnoDB",
  0,				/* slot */
  sizeof(trx_named_savept_t),	/* savepoint size. TODO: use it */
  innobase_close_connection,
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ static int ndbcluster_commit(THD *thd, bool all);
static int ndbcluster_rollback(THD *thd, bool all);

static handlerton ndbcluster_hton = {
  "ndbcluster",
  0, /* slot */
  0, /* savepoint size */
  ndbcluster_close_connection,
+73 −5
Original line number Diff line number Diff line
@@ -485,6 +485,16 @@ void ha_close_connection(THD* thd)
/* ========================================================================
 ======================= TRANSACTIONS ===================================*/

/*
  Register a storage engine for a transaction

  DESCRIPTION
    Every storage engine MUST call this function when it starts
    a transaction or a statement (that is it must be called both for the
    "beginning of transaction" and "beginning of statement").
    Only storage engines registered for the transaction/statement
    will know when to commit/rollback it.
*/
void trans_register_ha(THD *thd, bool all, handlerton *ht_arg)
{
  THD_TRANS *trans;
@@ -742,6 +752,45 @@ int ha_commit_or_rollback_by_xid(LEX_STRING *ident, bool commit)
  return res;
}

#ifndef DBUG_OFF
/* this does not need to be multi-byte safe or anything */
static char* xid_to_str(char *buf, XID *xid)
{
  int i;
  char *s=buf;
  *s++='\'';
  for (i=0; i < xid->gtrid_length+xid->bqual_length; i++)
  {
    uchar c=(uchar)xid->data[i];
    if (i == xid->gtrid_length)
    {
      *s++='\'';
      if (xid->bqual_length)
      {
        *s++='.';
        *s++='\'';
      }
    }
    if (c < 32 || c > 126)
    {
      *s++='\\';
      *s++='x';
      *s++=_dig_vec_lower[c >> 4];
      *s++=_dig_vec_lower[c & 15];
    }
    else
    {
      if (c == '\'' || c == '\\')
        *s++='\\';
      *s++=c;
    }
  }
  *s++='\'';
  *s=0;
  return buf;
}
#endif

/*
  recover() step of xa

@@ -772,11 +821,14 @@ int ha_recover(HASH *commit_list)
  /* commit_list and tc_heuristic_recover cannot be set both */
  DBUG_ASSERT(commit_list==0 || tc_heuristic_recover==0);
  /* if either is set, total_ha_2pc must be set too */
  DBUG_ASSERT((commit_list==0 && tc_heuristic_recover==0) || total_ha_2pc>0);
  DBUG_ASSERT(dry_run || total_ha_2pc>opt_bin_log);

  if (total_ha_2pc == 0)
  if (total_ha_2pc <= opt_bin_log)
    DBUG_RETURN(0);

  if (commit_list)
    sql_print_information("Starting crash recovery...");

#ifndef WILL_BE_DELETED_LATER
  /*
    for now, only InnoDB supports 2pc. It means we can always safely
@@ -803,6 +855,8 @@ int ha_recover(HASH *commit_list)
      continue;
    while ((got=(*(*ht)->recover)(list, len)) > 0 )
    {
      sql_print_information("Found %d prepared transaction(s) in %s",
                            got, (*ht)->name);
      for (int i=0; i < got; i ++)
      {
        my_xid x=list[i].get_my_xid();
@@ -820,10 +874,22 @@ int ha_recover(HASH *commit_list)
        if (commit_list ?
            hash_search(commit_list, (byte *)&x, sizeof(x)) != 0 :
            tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT)
        {
#ifndef DBUG_OFF
          char buf[XIDDATASIZE*4+6]; // see xid_to_str
          sql_print_information("commit xid %s", xid_to_str(buf, list+i));
#endif
          (*(*ht)->commit_by_xid)(list+i);
        }
        else
        {
#ifndef DBUG_OFF
          char buf[XIDDATASIZE*4+6]; // see xid_to_str
          sql_print_information("rollback xid %s", xid_to_str(buf, list+i));
#endif
          (*(*ht)->rollback_by_xid)(list+i);
        }
      }
      if (got < len)
        break;
    }
@@ -842,6 +908,8 @@ int ha_recover(HASH *commit_list)
                    found_my_xids, opt_tc_log_file);
    DBUG_RETURN(1);
  }
  if (commit_list)
    sql_print_information("Crash recovery finished.");
  DBUG_RETURN(0);
}

Loading