Commit 3a0f7fd7 authored by Rich Prohaska's avatar Rich Prohaska

#172 map ydb errors to handler errors in prelocking functions

parent ef1eb023
\N,\N,\N,\N,-1,\N,\N,,0,\N,,\N,\N,\N,,\N,2004-11-01 01:02:04.031903,\N,\N,0000-00-00,\N,\N,0000-00-00,\N,\N,\N,\N,,0,\N,\N,0,\N,0000-00-00,1,0,\N
\N,\N,\N,\N,,\N,\N,,0,\N,,\N,\N,\N,,\N,,\N,\N,0000-00-00,\N,\N,0000-00-00,\N,\N,\N,\N,,0,\N,9,0,\N,0000-00-00,2,0,\N
This source diff could not be displayed because it is too large. You can view the blob instead.
set default_storage_engine=tokudb;
drop table if exists t1,t2;
CREATE TABLE `t1` (
`c4` int(11) DEFAULT NULL,
`c5` int(11) DEFAULT NULL,
`c26` text,
`c18` blob,
`c29` text NOT NULL,
`c3` int(10) unsigned DEFAULT NULL,
`c25` text,
`c17` varchar(240) NOT NULL,
`c11` int(10) unsigned NOT NULL,
`c0` int(11) DEFAULT NULL,
`c22` blob NOT NULL,
`c13` varchar(240),
`c19` blob,
`c20` blob,
`c23` blob NOT NULL,
`c27` text,
`c28` text NOT NULL,
`c2` int(10) unsigned DEFAULT NULL,
`c12` varchar(240) DEFAULT NULL,
`c34` date NOT NULL,
`c30` date DEFAULT NULL,
`c31` date DEFAULT NULL,
`c24` date NOT NULL DEFAULT '0000-00-00',
`c33` date DEFAULT NULL,
`c21` blob,
`c1` int(11),
`c15` varchar(240) DEFAULT NULL,
`c16` varchar(240) NOT NULL,
`c9` int(11) NOT NULL,
`c32` date DEFAULT NULL,
`c7` int(10) unsigned DEFAULT NULL,
`c8` int(11) NOT NULL,
`c14` varchar(240) DEFAULT NULL,
`c35` date NOT NULL,
`pk` int(11) NOT NULL AUTO_INCREMENT,
`c10` int(10) unsigned NOT NULL,
`c6` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `c5` (`c5`),
KEY `c29` (`c29`(255)),
KEY `c3` (`c3`),
KEY `c25` (`c25`(255)),
KEY `c17` (`c17`),
KEY `c11` (`c11`),
KEY `c13` (`c13`),
KEY `c19` (`c19`(255)),
KEY `c23` (`c23`(255)),
KEY `c27` (`c27`(255)),
KEY `c31` (`c31`),
KEY `c33` (`c33`),
KEY `c21` (`c21`(255)),
KEY `c1` (`c1`),
KEY `c15` (`c15`),
KEY `c9` (`c9`),
KEY `c7` (`c7`),
KEY `c35` (`c35`)
);
CREATE TABLE `t2` (
`c12` varchar(240) DEFAULT NULL,
`c15` varchar(240) DEFAULT NULL,
`c19` blob,
`c14` varchar(240) DEFAULT NULL,
`c6` int(10) unsigned DEFAULT NULL,
`c11` int(10) unsigned NOT NULL,
`c30` date DEFAULT NULL,
`c29` text NOT NULL,
`c20` blob,
`c18` blob,
`c23` blob NOT NULL,
`c16` varchar(240) NOT NULL,
`c10` int(10) unsigned NOT NULL,
`c25` text,
`c21` blob,
`c7` int(10) unsigned DEFAULT NULL,
`c9` int(11) NOT NULL,
`c5` int(11) DEFAULT NULL,
`c35` date NOT NULL,
`c24` text,
`c17` varchar(240) NOT NULL,
`c28` text NOT NULL,
`c33` date DEFAULT NULL,
`c26` text,
`c0` int(11) DEFAULT NULL,
`c13` varchar(240) DEFAULT NULL,
`c3` int(10) unsigned DEFAULT NULL,
`c1` int(11) DEFAULT NULL,
`pk` int(11) NOT NULL AUTO_INCREMENT,
`c34` date NOT NULL,
`c2` int(10) unsigned DEFAULT NULL,
`c4` int(11) DEFAULT NULL,
`c32` date,
`c27` text,
`c8` int(11) NOT NULL,
`c31` date DEFAULT NULL,
`c22` blob NOT NULL,
PRIMARY KEY (`pk`),
KEY `c15` (`c15`),
KEY `c19` (`c19`(255)),
KEY `c11` (`c11`),
KEY `c29` (`c29`(255)),
KEY `c23` (`c23`(255)),
KEY `c25` (`c25`(255)),
KEY `c21` (`c21`(255)),
KEY `c7` (`c7`),
KEY `c9` (`c9`),
KEY `c5` (`c5`),
KEY `c35` (`c35`),
KEY `c17` (`c17`),
KEY `c33` (`c33`),
KEY `c13` (`c13`),
KEY `c3` (`c3`),
KEY `c1` (`c1`),
KEY `c27` (`c27`(255)),
KEY `c31` (`c31`)
);
LOAD DATA INFILE 'leak172_t1.data' INTO TABLE `t1` fields terminated by ',';
LOAD DATA INFILE 'leak172_t2.data' INTO TABLE `t2`;
UPDATE t1, t2 SET t1.`c5` = 4 WHERE t1.`c6` <= 'o';
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
drop table t1,t2;
source include/have_tokudb.inc;
set default_storage_engine=tokudb;
disable_warnings;
drop table if exists t1,t2;
enable_warnings;
let $MYSQLD_DATADIR=`select @@datadir`;
copy_file std_data/leak172_t1.data $MYSQLD_DATADIR/test/leak172_t1.data;
copy_file std_data/leak172_t2.data $MYSQLD_DATADIR/test/leak172_t2.data;
CREATE TABLE `t1` (
`c4` int(11) DEFAULT NULL,
`c5` int(11) DEFAULT NULL,
`c26` text,
`c18` blob,
`c29` text NOT NULL,
`c3` int(10) unsigned DEFAULT NULL,
`c25` text,
`c17` varchar(240) NOT NULL,
`c11` int(10) unsigned NOT NULL,
`c0` int(11) DEFAULT NULL,
`c22` blob NOT NULL,
`c13` varchar(240),
`c19` blob,
`c20` blob,
`c23` blob NOT NULL,
`c27` text,
`c28` text NOT NULL,
`c2` int(10) unsigned DEFAULT NULL,
`c12` varchar(240) DEFAULT NULL,
`c34` date NOT NULL,
`c30` date DEFAULT NULL,
`c31` date DEFAULT NULL,
`c24` date NOT NULL DEFAULT '0000-00-00',
`c33` date DEFAULT NULL,
`c21` blob,
`c1` int(11),
`c15` varchar(240) DEFAULT NULL,
`c16` varchar(240) NOT NULL,
`c9` int(11) NOT NULL,
`c32` date DEFAULT NULL,
`c7` int(10) unsigned DEFAULT NULL,
`c8` int(11) NOT NULL,
`c14` varchar(240) DEFAULT NULL,
`c35` date NOT NULL,
`pk` int(11) NOT NULL AUTO_INCREMENT,
`c10` int(10) unsigned NOT NULL,
`c6` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`pk`),
KEY `c5` (`c5`),
KEY `c29` (`c29`(255)),
KEY `c3` (`c3`),
KEY `c25` (`c25`(255)),
KEY `c17` (`c17`),
KEY `c11` (`c11`),
KEY `c13` (`c13`),
KEY `c19` (`c19`(255)),
KEY `c23` (`c23`(255)),
KEY `c27` (`c27`(255)),
KEY `c31` (`c31`),
KEY `c33` (`c33`),
KEY `c21` (`c21`(255)),
KEY `c1` (`c1`),
KEY `c15` (`c15`),
KEY `c9` (`c9`),
KEY `c7` (`c7`),
KEY `c35` (`c35`)
);
CREATE TABLE `t2` (
`c12` varchar(240) DEFAULT NULL,
`c15` varchar(240) DEFAULT NULL,
`c19` blob,
`c14` varchar(240) DEFAULT NULL,
`c6` int(10) unsigned DEFAULT NULL,
`c11` int(10) unsigned NOT NULL,
`c30` date DEFAULT NULL,
`c29` text NOT NULL,
`c20` blob,
`c18` blob,
`c23` blob NOT NULL,
`c16` varchar(240) NOT NULL,
`c10` int(10) unsigned NOT NULL,
`c25` text,
`c21` blob,
`c7` int(10) unsigned DEFAULT NULL,
`c9` int(11) NOT NULL,
`c5` int(11) DEFAULT NULL,
`c35` date NOT NULL,
`c24` text,
`c17` varchar(240) NOT NULL,
`c28` text NOT NULL,
`c33` date DEFAULT NULL,
`c26` text,
`c0` int(11) DEFAULT NULL,
`c13` varchar(240) DEFAULT NULL,
`c3` int(10) unsigned DEFAULT NULL,
`c1` int(11) DEFAULT NULL,
`pk` int(11) NOT NULL AUTO_INCREMENT,
`c34` date NOT NULL,
`c2` int(10) unsigned DEFAULT NULL,
`c4` int(11) DEFAULT NULL,
`c32` date,
`c27` text,
`c8` int(11) NOT NULL,
`c31` date DEFAULT NULL,
`c22` blob NOT NULL,
PRIMARY KEY (`pk`),
KEY `c15` (`c15`),
KEY `c19` (`c19`(255)),
KEY `c11` (`c11`),
KEY `c29` (`c29`(255)),
KEY `c23` (`c23`(255)),
KEY `c25` (`c25`(255)),
KEY `c21` (`c21`(255)),
KEY `c7` (`c7`),
KEY `c9` (`c9`),
KEY `c5` (`c5`),
KEY `c35` (`c35`),
KEY `c17` (`c17`),
KEY `c33` (`c33`),
KEY `c13` (`c13`),
KEY `c3` (`c3`),
KEY `c1` (`c1`),
KEY `c27` (`c27`(255)),
KEY `c31` (`c31`)
);
LOAD DATA INFILE 'leak172_t1.data' INTO TABLE `t1` fields terminated by ',';
connect(conn1,localhost,root,,);
send LOAD DATA INFILE 'leak172_t2.data' INTO TABLE `t2`;
connection default;
sleep 1;
--error 1205
UPDATE t1, t2 SET t1.`c5` = 4 WHERE t1.`c6` <= 'o';
connection conn1;
reap;
connection default;
disconnect conn1;
drop table t1,t2;
\ No newline at end of file
......@@ -4368,6 +4368,7 @@ void ha_tokudb::column_bitmaps_signal() {
// error otherwise
//
int ha_tokudb::prepare_index_scan() {
TOKUDB_HANDLER_DBUG_ENTER("");
int error = 0;
HANDLE_INVALID_CURSOR();
error = prelock_range(NULL, NULL);
......@@ -4376,7 +4377,7 @@ int ha_tokudb::prepare_index_scan() {
range_lock_grabbed = true;
error = 0;
cleanup:
return error;
TOKUDB_HANDLER_DBUG_RETURN(error);
}
......@@ -4388,6 +4389,7 @@ cleanup:
// error otherwise
//
int ha_tokudb::prepare_index_key_scan(const uchar * key, uint key_len) {
TOKUDB_HANDLER_DBUG_ENTER("");
int error = 0;
DBT start_key, end_key;
THD* thd = ha_thd();
......@@ -4416,9 +4418,7 @@ int ha_tokudb::prepare_index_key_scan(const uchar * key, uint key_len) {
error = 0;
cleanup:
if (error) {
if (error == DB_LOCK_NOTGRANTED) {
error = HA_ERR_LOCK_WAIT_TIMEOUT;
}
error = map_to_handler_error(error);
last_cursor_error = error;
//
// cursor should be initialized here, but in case it is not,
......@@ -4431,7 +4431,7 @@ cleanup:
remove_from_trx_handler_list();
}
}
return error;
TOKUDB_HANDLER_DBUG_RETURN(error);
}
void ha_tokudb::invalidate_bulk_fetch() {
......@@ -4502,6 +4502,7 @@ int ha_tokudb::index_init(uint keynr, bool sorted) {
my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0));
}
table->status = STATUS_NOT_FOUND;
error = map_to_handler_error(error);
last_cursor_error = error;
cursor = NULL; // Safety
goto exit;
......@@ -4561,9 +4562,7 @@ int ha_tokudb::index_end() {
int ha_tokudb::handle_cursor_error(int error, int err_to_return, uint keynr) {
TOKUDB_HANDLER_DBUG_ENTER("");
if (error) {
if (error == DB_LOCK_NOTGRANTED) {
error = HA_ERR_LOCK_WAIT_TIMEOUT;
}
error = map_to_handler_error(error);
last_cursor_error = error;
table->status = STATUS_NOT_FOUND;
if (error == DB_NOTFOUND) {
......@@ -5688,7 +5687,8 @@ int ha_tokudb::prelock_range( const key_range *start_key, const key_range *end_k
true,
(cursor_flags & DB_SERIALIZABLE) != 0 ? DB_NOTFOUND : 0
);
if (error){
if (error) {
error = map_to_handler_error(error);
last_cursor_error = error;
//
// cursor should be initialized here, but in case it is not, we still check
......@@ -5721,11 +5721,12 @@ cleanup:
// Forward scans use read_range_first()/read_range_next().
//
int ha_tokudb::prepare_range_scan( const key_range *start_key, const key_range *end_key) {
TOKUDB_HANDLER_DBUG_ENTER("");
int error = prelock_range(start_key, end_key);
if (!error) {
range_lock_grabbed = true;
}
return error;
TOKUDB_HANDLER_DBUG_RETURN(error);
}
int ha_tokudb::read_range_first(
......@@ -5734,13 +5735,14 @@ int ha_tokudb::read_range_first(
bool eq_range,
bool sorted)
{
TOKUDB_HANDLER_DBUG_ENTER("");
int error = prelock_range(start_key, end_key);
if (error) { goto cleanup; }
range_lock_grabbed = true;
error = handler::read_range_first(start_key, end_key, eq_range, sorted);
cleanup:
return error;
TOKUDB_HANDLER_DBUG_RETURN(error);
}
int ha_tokudb::read_range_next()
......@@ -8002,7 +8004,7 @@ void ha_tokudb::restore_drop_indexes(TABLE *table_arg, uint *key_num, uint num_o
}
}
void ha_tokudb::print_error(int error, myf errflag) {
int ha_tokudb::map_to_handler_error(int error) {
if (error == DB_LOCK_DEADLOCK)
error = HA_ERR_LOCK_DEADLOCK;
if (error == DB_LOCK_NOTGRANTED)
......@@ -8020,9 +8022,13 @@ void ha_tokudb::print_error(int error, myf errflag) {
error = HA_ERR_UNSUPPORTED;
}
#endif
handler::print_error(error, errflag);
return error;
}
void ha_tokudb::print_error(int error, myf errflag) {
error = map_to_handler_error(error);
handler::print_error(error, errflag);
}
//
// truncate's dictionary associated with keynr index using transaction txn
......
......@@ -797,6 +797,9 @@ private:
LIST trx_handler_list;
void add_to_trx_handler_list();
void remove_from_trx_handler_list();
private:
int map_to_handler_error(int error);
};
#if defined(MARIADB_BASE_VERSION)
......
......@@ -127,7 +127,7 @@ static int analyze_progress(void *v_extra, uint64_t rows) {
}
int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) {
TOKUDB_HANDLER_DBUG_ENTER("");
TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name);
uint64_t rec_per_key[table_share->key_parts];
int result = HA_ADMIN_OK;
DB_TXN *txn = transaction;
......@@ -153,11 +153,10 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) {
} else {
// debug
if (tokudb_debug & TOKUDB_DEBUG_ANALYZE) {
fprintf(stderr, "ha_tokudb::analyze %s.%s.%s ",
table_share->db.str, table_share->table_name.str, i == primary_key ? "primary" : table_share->key_info[i].name);
TOKUDB_HANDLER_TRACE("%s.%s.%s",
table_share->db.str, table_share->table_name.str, i == primary_key ? "primary" : table_share->key_info[i].name);
for (uint j = 0; j < num_key_parts; j++)
fprintf(stderr, "%lu ", rec_per_key[next_key_part+j]);
fprintf(stderr, "\n");
TOKUDB_HANDLER_TRACE("%lu", rec_per_key[next_key_part+j]);
}
}
next_key_part += num_key_parts;
......@@ -192,7 +191,7 @@ static int hot_poll_fun(void *extra, float progress) {
// flatten all DB's in this table, to do so, peform hot optimize on each db
int ha_tokudb::optimize(THD * thd, HA_CHECK_OPT * check_opt) {
TOKUDB_HANDLER_DBUG_ENTER("");
TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name);
int error;
uint curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key);
......@@ -262,7 +261,7 @@ static void ha_tokudb_check_info(THD *thd, TABLE *table, const char *msg) {
}
int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) {
TOKUDB_HANDLER_DBUG_ENTER("");
TOKUDB_HANDLER_DBUG_ENTER("%s", share->table_name);
const char *old_proc_info = thd->proc_info;
thd_proc_info(thd, "tokudb::check");
......@@ -288,7 +287,7 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) {
ha_tokudb_check_info(thd, table, write_status_msg);
time_t now = time(0);
char timebuf[32];
fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg);
TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg);
}
for (uint i = 0; i < num_DBs; i++) {
DB *db = share->key_file[i];
......@@ -299,7 +298,7 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) {
ha_tokudb_check_info(thd, table, write_status_msg);
time_t now = time(0);
char timebuf[32];
fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg);
TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg);
}
struct check_context check_context = { thd };
r = db->verify_with_progress(db, ha_tokudb_check_progress, &check_context, (tokudb_debug & TOKUDB_DEBUG_CHECK) != 0, keep_going);
......@@ -309,7 +308,7 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) {
ha_tokudb_check_info(thd, table, write_status_msg);
time_t now = time(0);
char timebuf[32];
fprintf(stderr, "%.24s ha_tokudb::check %s\n", ctime_r(&now, timebuf), write_status_msg);
TOKUDB_HANDLER_TRACE("%.24s %s", ctime_r(&now, timebuf), write_status_msg);
}
if (result == HA_ADMIN_OK && r != 0) {
result = HA_ADMIN_CORRUPT;
......
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