Commit 48ed7f10 authored by Kentoku SHIBA's avatar Kentoku SHIBA

Add mysql.spider_xa_failed_log table.

parent a4db29a2
# Copyright (C) 2010-2011 Kentoku Shiba
# Copyright (C) 2010-2013 Kentoku Shiba
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -47,6 +47,30 @@ create table if not exists mysql.spider_xa_member(
default_group char(64) default null,
key idx1 (data, format_id, gtrid_length, host)
) engine=MyISAM default charset=utf8 collate=utf8_bin;
create table if not exists mysql.spider_xa_failed_log(
format_id int not null default 0,
gtrid_length int not null default 0,
bqual_length int not null default 0,
data char(128) charset binary not null default '',
scheme char(64) not null default '',
host char(64) not null default '',
port char(5) not null default '',
socket text not null default '',
username char(64) not null default '',
password char(64) not null default '',
ssl_ca text default null,
ssl_capath text default null,
ssl_cert text default null,
ssl_cipher char(64) default null,
ssl_key text default null,
ssl_verify_server_cert tinyint not null default 0,
default_file text default null,
default_group char(64) default null,
thread_id int default null,
status char(8) not null default '',
failed_time timestamp not null default current_timestamp,
key idx1 (data, format_id, gtrid_length, host)
) engine=MyISAM default charset=utf8 collate=utf8_bin;
create table if not exists mysql.spider_tables(
db_name char(64) not null default '',
table_name char(64) not null default '',
......
......@@ -1078,6 +1078,44 @@ int spider_log_tables_link_failed(
DBUG_RETURN(0);
}
int spider_log_xa_failed(
THD *thd,
TABLE *table,
XID *xid,
SPIDER_CONN *conn,
const char *status
) {
int error_num;
DBUG_ENTER("spider_log_xa_failed");
table->use_all_columns();
spider_store_xa_member_pk(table, xid, conn);
spider_store_xa_member_info(table, xid, conn);
if (thd)
{
table->field[18]->set_notnull();
table->field[18]->store(thd->thread_id, TRUE);
} else {
table->field[18]->set_null();
table->field[18]->reset();
}
table->field[19]->store(
status,
(uint) strlen(status),
system_charset_info);
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
#else
if (table->field[20] == table->timestamp_field)
table->timestamp_field->set_time();
#endif
if ((error_num = table->file->ha_write_row(table->record[0])))
{
table->file->print_error(error_num, MYF(0));
DBUG_RETURN(error_num);
}
DBUG_RETURN(0);
}
int spider_update_xa(
TABLE *table,
XID *xid,
......@@ -1933,6 +1971,43 @@ error:
DBUG_RETURN(error_num);
}
int spider_sys_log_xa_failed(
THD *thd,
XID *xid,
SPIDER_CONN *conn,
const char *status,
bool need_lock
) {
int error_num;
TABLE *table_tables = NULL;
#if MYSQL_VERSION_ID < 50500
Open_tables_state open_tables_backup;
#else
Open_tables_backup open_tables_backup;
#endif
DBUG_ENTER("spider_sys_log_xa_failed");
if (
!(table_tables = spider_open_sys_table(
thd, SPIDER_SYS_XA_FAILED_TABLE_NAME_STR,
SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN, TRUE, &open_tables_backup,
need_lock, &error_num))
) {
my_error(error_num, MYF(0));
goto error;
}
empty_record(table_tables);
if ((error_num = spider_log_xa_failed(thd, table_tables, xid, conn, status)))
goto error;
spider_close_sys_table(thd, table_tables, &open_tables_backup, need_lock);
table_tables = NULL;
DBUG_RETURN(0);
error:
if (table_tables)
spider_close_sys_table(thd, table_tables, &open_tables_backup, need_lock);
DBUG_RETURN(error_num);
}
int spider_get_sys_link_mon_key(
TABLE *table,
SPIDER_MON_KEY *mon_key,
......
......@@ -23,6 +23,8 @@
#define SPIDER_SYS_LINK_MON_TABLE_NAME_LEN (sizeof(SPIDER_SYS_LINK_MON_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_LINK_FAILED_TABLE_NAME_STR "spider_link_failed_log"
#define SPIDER_SYS_LINK_FAILED_TABLE_NAME_LEN (sizeof(SPIDER_SYS_LINK_FAILED_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_XA_FAILED_TABLE_NAME_STR "spider_xa_failed_log"
#define SPIDER_SYS_XA_FAILED_TABLE_NAME_LEN (sizeof(SPIDER_SYS_XA_FAILED_TABLE_NAME_STR) - 1)
#define SPIDER_SYS_XA_PREPARED_STR "PREPARED"
#define SPIDER_SYS_XA_NOT_YET_STR "NOT YET"
......@@ -255,6 +257,14 @@ int spider_log_tables_link_failed(
int link_idx
);
int spider_log_xa_failed(
THD *thd,
TABLE *table,
XID *xid,
SPIDER_CONN *conn,
const char *status
);
int spider_update_xa(
TABLE *table,
XID *xid,
......@@ -365,6 +375,14 @@ int spider_sys_log_tables_link_failed(
bool need_lock
);
int spider_sys_log_xa_failed(
THD *thd,
XID *xid,
SPIDER_CONN *conn,
const char *status,
bool need_lock
);
int spider_get_sys_link_mon_key(
TABLE *table,
SPIDER_MON_KEY *mon_key,
......
......@@ -1861,6 +1861,8 @@ int spider_internal_xa_commit(
if (!error_num && tmp_error_num)
error_num = tmp_error_num;
}
spider_sys_log_xa_failed(thd, &trx->xid, conn,
SPIDER_SYS_XA_COMMIT_STR, TRUE);
}
if ((tmp_error_num = spider_end_trx(trx, conn)))
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment