Commit 95497dcc authored by unknown's avatar unknown

Bug #28989 hpux11 ps_row warnings

- do not print 701 dictionary busy error


sql/ha_ndbcluster.cc:
  save the ndb error such that it can be traced
sql/ha_ndbcluster.h:
  save the ndb error such that it can be traced
sql/ha_ndbcluster_binlog.cc:
  use the traced ndb error to determine if it is an error that should be printed
parent 7bbf3901
...@@ -121,14 +121,14 @@ static uint ndbcluster_alter_table_flags(uint flags) ...@@ -121,14 +121,14 @@ static uint ndbcluster_alter_table_flags(uint flags)
#define ERR_RETURN(err) \ #define ERR_RETURN(err) \
{ \ { \
const NdbError& tmp= err; \ const NdbError& tmp= err; \
ERR_PRINT(tmp); \ set_ndb_err(current_thd, tmp); \
DBUG_RETURN(ndb_to_mysql_error(&tmp)); \ DBUG_RETURN(ndb_to_mysql_error(&tmp)); \
} }
#define ERR_BREAK(err, code) \ #define ERR_BREAK(err, code) \
{ \ { \
const NdbError& tmp= err; \ const NdbError& tmp= err; \
ERR_PRINT(tmp); \ set_ndb_err(current_thd, tmp); \
code= ndb_to_mysql_error(&tmp); \ code= ndb_to_mysql_error(&tmp); \
break; \ break; \
} }
...@@ -516,13 +516,51 @@ void ha_ndbcluster::no_uncommitted_rows_reset(THD *thd) ...@@ -516,13 +516,51 @@ void ha_ndbcluster::no_uncommitted_rows_reset(THD *thd)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/*
Sets the latest ndb error code on the thd_ndb object such that it
can be retrieved later to know which ndb error caused the handler
error.
*/
static void set_ndb_err(THD *thd, const NdbError &err)
{
DBUG_ENTER("set_ndb_err");
ERR_PRINT(err);
Thd_ndb *thd_ndb= get_thd_ndb(thd);
if (thd_ndb == NULL)
DBUG_VOID_RETURN;
#ifdef NOT_YET
/*
Check if error code is overwritten, in this case the original
failure cause will be lost. E.g. if 4350 error is given. So
push a warning so that it can be detected which is the root
error cause.
*/
if (thd_ndb->m_query_id == thd->query_id &&
thd_ndb->m_error_code != 0 &&
thd_ndb->m_error_code != err.code)
{
char buf[FN_REFLEN];
ndb_error_string(thd_ndb->m_error_code, buf, sizeof(buf));
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_ERROR,
ER_GET_ERRMSG, ER(ER_GET_ERRMSG),
thd_ndb->m_error_code, buf, "NDB");
}
#endif
thd_ndb->m_query_id= thd->query_id;
thd_ndb->m_error_code= err.code;
DBUG_VOID_RETURN;
}
int ha_ndbcluster::ndb_err(NdbTransaction *trans) int ha_ndbcluster::ndb_err(NdbTransaction *trans)
{ {
THD *thd= current_thd;
int res; int res;
NdbError err= trans->getNdbError(); NdbError err= trans->getNdbError();
DBUG_ENTER("ndb_err"); DBUG_ENTER("ndb_err");
ERR_PRINT(err); set_ndb_err(thd, err);
switch (err.classification) { switch (err.classification) {
case NdbError::SchemaError: case NdbError::SchemaError:
{ {
...@@ -533,7 +571,7 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans) ...@@ -533,7 +571,7 @@ int ha_ndbcluster::ndb_err(NdbTransaction *trans)
bzero((char*) &table_list,sizeof(table_list)); bzero((char*) &table_list,sizeof(table_list));
table_list.db= m_dbname; table_list.db= m_dbname;
table_list.alias= table_list.table_name= m_tabname; table_list.alias= table_list.table_name= m_tabname;
close_cached_tables(current_thd, 0, &table_list); close_cached_tables(thd, 0, &table_list);
break; break;
} }
default: default:
...@@ -4576,7 +4614,7 @@ static int ndbcluster_commit(handlerton *hton, THD *thd, bool all) ...@@ -4576,7 +4614,7 @@ static int ndbcluster_commit(handlerton *hton, THD *thd, bool all)
{ {
const NdbError err= trans->getNdbError(); const NdbError err= trans->getNdbError();
const NdbOperation *error_op= trans->getNdbErrorOperation(); const NdbOperation *error_op= trans->getNdbErrorOperation();
ERR_PRINT(err); set_ndb_err(thd, err);
res= ndb_to_mysql_error(&err); res= ndb_to_mysql_error(&err);
if (res != -1) if (res != -1)
ndbcluster_print_error(res, error_op); ndbcluster_print_error(res, error_op);
...@@ -4627,7 +4665,7 @@ static int ndbcluster_rollback(handlerton *hton, THD *thd, bool all) ...@@ -4627,7 +4665,7 @@ static int ndbcluster_rollback(handlerton *hton, THD *thd, bool all)
{ {
const NdbError err= trans->getNdbError(); const NdbError err= trans->getNdbError();
const NdbOperation *error_op= trans->getNdbErrorOperation(); const NdbOperation *error_op= trans->getNdbErrorOperation();
ERR_PRINT(err); set_ndb_err(thd, err);
res= ndb_to_mysql_error(&err); res= ndb_to_mysql_error(&err);
if (res != -1) if (res != -1)
ndbcluster_print_error(res, error_op); ndbcluster_print_error(res, error_op);
...@@ -5209,7 +5247,7 @@ int ha_ndbcluster::create(const char *name, ...@@ -5209,7 +5247,7 @@ int ha_ndbcluster::create(const char *name,
if (dict->createTable(tab) != 0) if (dict->createTable(tab) != 0)
{ {
const NdbError err= dict->getNdbError(); const NdbError err= dict->getNdbError();
ERR_PRINT(err); set_ndb_err(thd, err);
my_errno= ndb_to_mysql_error(&err); my_errno= ndb_to_mysql_error(&err);
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
} }
...@@ -5223,7 +5261,7 @@ int ha_ndbcluster::create(const char *name, ...@@ -5223,7 +5261,7 @@ int ha_ndbcluster::create(const char *name,
{ {
/* purecov: begin deadcode */ /* purecov: begin deadcode */
const NdbError err= dict->getNdbError(); const NdbError err= dict->getNdbError();
ERR_PRINT(err); set_ndb_err(thd, err);
my_errno= ndb_to_mysql_error(&err); my_errno= ndb_to_mysql_error(&err);
DBUG_RETURN(my_errno); DBUG_RETURN(my_errno);
/* purecov: end */ /* purecov: end */
...@@ -5395,6 +5433,7 @@ int ha_ndbcluster::create_handler_files(const char *file, ...@@ -5395,6 +5433,7 @@ int ha_ndbcluster::create_handler_files(const char *file,
new_tab.setFrm(pack_data, pack_length); new_tab.setFrm(pack_data, pack_length);
if (dict->alterTableGlobal(*tab, new_tab)) if (dict->alterTableGlobal(*tab, new_tab))
{ {
set_ndb_err(current_thd, dict->getNdbError());
error= ndb_to_mysql_error(&dict->getNdbError()); error= ndb_to_mysql_error(&dict->getNdbError());
} }
my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR)); my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR));
...@@ -5870,6 +5909,7 @@ ha_ndbcluster::delete_table(ha_ndbcluster *h, Ndb *ndb, ...@@ -5870,6 +5909,7 @@ ha_ndbcluster::delete_table(ha_ndbcluster *h, Ndb *ndb,
default: default:
break; break;
} }
set_ndb_err(thd, dict->getNdbError());
res= ndb_to_mysql_error(&dict->getNdbError()); res= ndb_to_mysql_error(&dict->getNdbError());
DBUG_PRINT("info", ("error(1) %u", res)); DBUG_PRINT("info", ("error(1) %u", res));
} }
...@@ -5909,6 +5949,7 @@ ha_ndbcluster::delete_table(ha_ndbcluster *h, Ndb *ndb, ...@@ -5909,6 +5949,7 @@ ha_ndbcluster::delete_table(ha_ndbcluster *h, Ndb *ndb,
} }
} }
} }
set_ndb_err(thd, dict->getNdbError());
res= ndb_to_mysql_error(&dict->getNdbError()); res= ndb_to_mysql_error(&dict->getNdbError());
DBUG_PRINT("info", ("error(2) %u", res)); DBUG_PRINT("info", ("error(2) %u", res));
break; break;
...@@ -6268,6 +6309,7 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked) ...@@ -6268,6 +6309,7 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked)
Ndb *ndb= get_ndb(); Ndb *ndb= get_ndb();
if (ndb->setDatabaseName(m_dbname)) if (ndb->setDatabaseName(m_dbname))
{ {
set_ndb_err(current_thd, ndb->getNdbError());
res= ndb_to_mysql_error(&ndb->getNdbError()); res= ndb_to_mysql_error(&ndb->getNdbError());
break; break;
} }
...@@ -6628,7 +6670,7 @@ int ndbcluster_drop_database_impl(const char *path) ...@@ -6628,7 +6670,7 @@ int ndbcluster_drop_database_impl(const char *path)
const NdbError err= dict->getNdbError(); const NdbError err= dict->getNdbError();
if (err.code != 709 && err.code != 723) if (err.code != 709 && err.code != 723)
{ {
ERR_PRINT(err); set_ndb_err(thd, err);
ret= ndb_to_mysql_error(&err); ret= ndb_to_mysql_error(&err);
} }
} }
...@@ -8348,6 +8390,7 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, const ...@@ -8348,6 +8390,7 @@ ndb_get_table_statistics(ha_ndbcluster* file, bool report_error, Ndb* ndb, const
my_sleep(retry_sleep); my_sleep(retry_sleep);
continue; continue;
} }
set_ndb_err(current_thd, error);
break; break;
} while(1); } while(1);
DBUG_PRINT("exit", ("failed, reterr: %u, NdbError %u(%s)", reterr, DBUG_PRINT("exit", ("failed, reterr: %u, NdbError %u(%s)", reterr,
...@@ -9988,7 +10031,7 @@ int ndbcluster_alter_tablespace(handlerton *hton, ...@@ -9988,7 +10031,7 @@ int ndbcluster_alter_tablespace(handlerton *hton,
ndberror: ndberror:
err= dict->getNdbError(); err= dict->getNdbError();
ndberror2: ndberror2:
ERR_PRINT(err); set_ndb_err(thd, err);
ndb_to_mysql_error(&err); ndb_to_mysql_error(&err);
my_error(error, MYF(0), errmsg); my_error(error, MYF(0), errmsg);
......
...@@ -207,6 +207,8 @@ class Thd_ndb ...@@ -207,6 +207,8 @@ class Thd_ndb
NdbTransaction *stmt; NdbTransaction *stmt;
bool m_error; bool m_error;
bool m_slow_path; bool m_slow_path;
int m_error_code;
uint32 m_query_id; /* query id whn m_error_code was set */
uint32 options; uint32 options;
uint32 trans_options; uint32 trans_options;
List<NDB_SHARE> changed_tables; List<NDB_SHARE> changed_tables;
......
...@@ -81,6 +81,20 @@ static Ndb *injector_ndb= 0; ...@@ -81,6 +81,20 @@ static Ndb *injector_ndb= 0;
static Ndb *schema_ndb= 0; static Ndb *schema_ndb= 0;
static int ndbcluster_binlog_inited= 0; static int ndbcluster_binlog_inited= 0;
/*
Flag "ndbcluster_binlog_terminating" set when shutting down mysqld.
Server main loop should call handlerton function:
ndbcluster_hton->binlog_func ==
ndbcluster_binlog_func(...,BFN_BINLOG_END,...) ==
ndbcluster_binlog_end
at shutdown, which sets the flag. And then server needs to wait for it
to complete. Otherwise binlog will not be complete.
ndbcluster_hton->panic == ndbcluster_end() will not return until
ndb binlog is completed
*/
static int ndbcluster_binlog_terminating= 0; static int ndbcluster_binlog_terminating= 0;
/* /*
...@@ -222,7 +236,7 @@ static void dbug_print_table(const char *info, TABLE *table) ...@@ -222,7 +236,7 @@ static void dbug_print_table(const char *info, TABLE *table)
- creating the ndb_apply_status table - creating the ndb_apply_status table
*/ */
static void run_query(THD *thd, char *buf, char *end, static void run_query(THD *thd, char *buf, char *end,
my_bool print_error, my_bool disable_binlog) const int *no_print_error, my_bool disable_binlog)
{ {
ulong save_query_length= thd->query_length; ulong save_query_length= thd->query_length;
char *save_query= thd->query; char *save_query= thd->query;
...@@ -242,11 +256,18 @@ static void run_query(THD *thd, char *buf, char *end, ...@@ -242,11 +256,18 @@ static void run_query(THD *thd, char *buf, char *end,
DBUG_PRINT("query", ("%s", thd->query)); DBUG_PRINT("query", ("%s", thd->query));
mysql_parse(thd, thd->query, thd->query_length, &found_semicolon); mysql_parse(thd, thd->query, thd->query_length, &found_semicolon);
if (print_error && thd->query_error) if (no_print_error && thd->query_error)
{ {
sql_print_error("NDB: %s: error %s %d %d %d", int i;
buf, thd->net.last_error, thd->net.last_errno, Thd_ndb *thd_ndb= get_thd_ndb(thd);
thd->net.report_error, thd->query_error); for (i= 0; no_print_error[i]; i++)
if (thd_ndb->m_error == no_print_error[i])
break;
if (!no_print_error[i])
sql_print_error("NDB: %s: error %s %d(ndb: %d) %d %d",
buf, thd->net.last_error, thd->net.last_errno,
thd_ndb->m_error,
thd->net.report_error, thd->query_error);
} }
thd->options= save_thd_options; thd->options= save_thd_options;
...@@ -488,7 +509,7 @@ static int ndbcluster_reset_logs(THD *thd) ...@@ -488,7 +509,7 @@ static int ndbcluster_reset_logs(THD *thd)
char buf[1024]; char buf[1024];
char *end= strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_REP_TABLE); char *end= strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_REP_TABLE);
run_query(thd, buf, end, FALSE, TRUE); run_query(thd, buf, end, NULL, TRUE);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -513,7 +534,7 @@ ndbcluster_binlog_index_purge_file(THD *thd, const char *file) ...@@ -513,7 +534,7 @@ ndbcluster_binlog_index_purge_file(THD *thd, const char *file)
NDB_REP_DB "." NDB_REP_TABLE NDB_REP_DB "." NDB_REP_TABLE
" WHERE File='"), file), "'"); " WHERE File='"), file), "'");
run_query(thd, buf, end, FALSE, TRUE); run_query(thd, buf, end, NULL, TRUE);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -630,7 +651,7 @@ static void ndbcluster_reset_slave(THD *thd) ...@@ -630,7 +651,7 @@ static void ndbcluster_reset_slave(THD *thd)
DBUG_ENTER("ndbcluster_reset_slave"); DBUG_ENTER("ndbcluster_reset_slave");
char buf[1024]; char buf[1024];
char *end= strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_APPLY_TABLE); char *end= strmov(buf, "DELETE FROM " NDB_REP_DB "." NDB_APPLY_TABLE);
run_query(thd, buf, end, FALSE, TRUE); run_query(thd, buf, end, NULL, TRUE);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -755,7 +776,8 @@ static int ndbcluster_create_ndb_apply_status_table(THD *thd) ...@@ -755,7 +776,8 @@ static int ndbcluster_create_ndb_apply_status_table(THD *thd)
" end_pos BIGINT UNSIGNED NOT NULL, " " end_pos BIGINT UNSIGNED NOT NULL, "
" PRIMARY KEY USING HASH (server_id) ) ENGINE=NDB"); " PRIMARY KEY USING HASH (server_id) ) ENGINE=NDB");
run_query(thd, buf, end, TRUE, TRUE); const int no_print_error[2]= {701, 0}; // do not print error 701
run_query(thd, buf, end, no_print_error, TRUE);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -811,7 +833,8 @@ static int ndbcluster_create_schema_table(THD *thd) ...@@ -811,7 +833,8 @@ static int ndbcluster_create_schema_table(THD *thd)
" type INT UNSIGNED NOT NULL," " type INT UNSIGNED NOT NULL,"
" PRIMARY KEY USING HASH (db,name) ) ENGINE=NDB"); " PRIMARY KEY USING HASH (db,name) ) ENGINE=NDB");
run_query(thd, buf, end, TRUE, TRUE); const int no_print_error[2]= {701, 0}; // do not print error 701
run_query(thd, buf, end, no_print_error, TRUE);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -1920,9 +1943,10 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, ...@@ -1920,9 +1943,10 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
/* Drop the database locally if it only contains ndb tables */ /* Drop the database locally if it only contains ndb tables */
if (! ndbcluster_check_if_local_tables_in_db(thd, schema->db)) if (! ndbcluster_check_if_local_tables_in_db(thd, schema->db))
{ {
const int no_print_error[1]= {0};
run_query(thd, schema->query, run_query(thd, schema->query,
schema->query + schema->query_length, schema->query + schema->query_length,
TRUE, /* print error */ no_print_error, /* print error */
TRUE); /* don't binlog the query */ TRUE); /* don't binlog the query */
/* binlog dropping database after any table operations */ /* binlog dropping database after any table operations */
post_epoch_log_list->push_back(schema, mem_root); post_epoch_log_list->push_back(schema, mem_root);
...@@ -1942,12 +1966,15 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, ...@@ -1942,12 +1966,15 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb,
case SOT_CREATE_DB: case SOT_CREATE_DB:
/* fall through */ /* fall through */
case SOT_ALTER_DB: case SOT_ALTER_DB:
{
const int no_print_error[1]= {0};
run_query(thd, schema->query, run_query(thd, schema->query,
schema->query + schema->query_length, schema->query + schema->query_length,
TRUE, /* print error */ no_print_error, /* print error */
TRUE); /* don't binlog the query */ TRUE); /* don't binlog the query */
log_query= 1; log_query= 1;
break; break;
}
case SOT_TABLESPACE: case SOT_TABLESPACE:
case SOT_LOGFILE_GROUP: case SOT_LOGFILE_GROUP:
log_query= 1; log_query= 1;
......
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