handler::rebind()

- rename PFS specific rebind_psi() to generic rebind()
- call rebind independently of PFS compilation status
- allow rebind() return an error
This commit is contained in:
Sergey Vojtovich 2020-01-24 00:44:48 +04:00 committed by Monty
parent bff79492c5
commit da82e75901
9 changed files with 42 additions and 25 deletions

View File

@ -43,7 +43,6 @@
#ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_UNBIND_TABLE(handler) (handler)->unbind_psi()
#define MYSQL_REBIND_TABLE(handler) (handler)->rebind_psi()
#define PSI_CALL_unbind_table PSI_TABLE_CALL(unbind_table)
#define PSI_CALL_rebind_table PSI_TABLE_CALL(rebind_table)
@ -54,7 +53,6 @@
#define PSI_CALL_drop_table_share PSI_TABLE_CALL(drop_table_share)
#else
#define MYSQL_UNBIND_TABLE(handler) do { } while(0)
#define MYSQL_REBIND_TABLE(handler) do { } while(0)
#define PSI_CALL_unbind_table(A1) do { } while(0)
#define PSI_CALL_rebind_table(A1,A2,A3) NULL

View File

@ -3715,18 +3715,25 @@ void ha_partition::unbind_psi()
DBUG_VOID_RETURN;
}
void ha_partition::rebind_psi()
int ha_partition::rebind()
{
uint i;
DBUG_ENTER("ha_partition::rebind_psi");
handler::rebind_psi();
DBUG_ENTER("ha_partition::rebind");
if (int error= handler::rebind())
DBUG_RETURN(error);
for (i= 0; i < m_tot_parts; i++)
{
DBUG_ASSERT(m_file[i] != NULL);
m_file[i]->rebind_psi();
if (int error= m_file[i]->rebind())
{
while (i)
m_file[--i]->unbind_psi();
handler::unbind_psi();
DBUG_RETURN(error);
}
}
DBUG_VOID_RETURN;
DBUG_RETURN(0);
}
#endif /* HAVE_M_PSI_PER_PARTITION */

View File

@ -685,7 +685,7 @@ public:
Bind the table/handler thread to track table i/o.
*/
virtual void unbind_psi();
virtual void rebind_psi();
virtual int rebind();
#endif
/*
-------------------------------------------------------------------------

View File

@ -141,8 +141,8 @@ public:
{ return file->rename_table(from, to); }
void unbind_psi()
{ return file->unbind_psi(); }
void rebind_psi()
{ return file->rebind_psi(); }
int rebind()
{ return file->rebind(); }
bool auto_repair(int error) const
{ return file->auto_repair(error); }

View File

@ -2806,13 +2806,14 @@ void handler::unbind_psi()
PSI_CALL_unbind_table(m_psi);
}
void handler::rebind_psi()
int handler::rebind()
{
/*
Notify the instrumentation that this table is now owned
by this thread.
*/
m_psi= PSI_CALL_rebind_table(ha_table_share_psi(), this, m_psi);
return 0;
}

View File

@ -3160,7 +3160,7 @@ private:
public:
virtual void unbind_psi();
virtual void rebind_psi();
virtual int rebind();
/**
Put the handler in 'batch' mode when collecting
table io instrumented events.

View File

@ -2052,7 +2052,13 @@ retry_share:
if (table)
{
DBUG_ASSERT(table->file != NULL);
MYSQL_REBIND_TABLE(table->file);
if (table->file->rebind() == HA_ERR_TABLE_DEF_CHANGED)
{
tc_release_table(table);
(void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER,
table_list);
DBUG_RETURN(TRUE);
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
part_names_error= set_partitions_as_used(table_list, table);
#endif

View File

@ -17023,34 +17023,39 @@ void ha_mroonga::unbind_psi()
DBUG_VOID_RETURN;
}
void ha_mroonga::wrapper_rebind_psi()
int ha_mroonga::wrapper_rebind()
{
MRN_DBUG_ENTER_METHOD();
MRN_SET_WRAP_SHARE_KEY(share, table->s);
MRN_SET_WRAP_TABLE_KEY(this, table);
wrap_handler->rebind_psi();
int error= wrap_handler->rebind();
MRN_SET_BASE_SHARE_KEY(share, table->s);
MRN_SET_BASE_TABLE_KEY(this, table);
DBUG_VOID_RETURN;
DBUG_RETURN(error);
}
void ha_mroonga::storage_rebind_psi()
void ha_mroonga::storage_rebind()
{
MRN_DBUG_ENTER_METHOD();
DBUG_VOID_RETURN;
}
void ha_mroonga::rebind_psi()
int ha_mroonga::rebind()
{
MRN_DBUG_ENTER_METHOD();
handler::rebind_psi();
if (int error= handler::rebind())
DBUG_RETURN(error);
if (share->wrapper_mode)
{
wrapper_rebind_psi();
if (int error= wrapper_rebind())
{
handler::unbind_psi();
DBUG_RETURN(error);
}
} else {
storage_rebind_psi();
storage_rebind();
}
DBUG_VOID_RETURN;
DBUG_RETURN(0);
}
#endif

View File

@ -631,7 +631,7 @@ protected:
void free_foreign_key_create_info(char* str) mrn_override;
#ifdef MRN_HAVE_HA_REBIND_PSI
void unbind_psi() mrn_override;
void rebind_psi() mrn_override;
int rebind() mrn_override;
#endif
my_bool register_query_cache_table(THD *thd,
const char *table_key,
@ -1290,8 +1290,8 @@ private:
#ifdef MRN_HAVE_HA_REBIND_PSI
void wrapper_unbind_psi();
void storage_unbind_psi();
void wrapper_rebind_psi();
void storage_rebind_psi();
int wrapper_rebind();
void storage_rebind();
#endif
my_bool wrapper_register_query_cache_table(THD *thd,
const char *table_key,