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 #ifdef HAVE_PSI_TABLE_INTERFACE
#define MYSQL_UNBIND_TABLE(handler) (handler)->unbind_psi() #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_unbind_table PSI_TABLE_CALL(unbind_table)
#define PSI_CALL_rebind_table PSI_TABLE_CALL(rebind_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) #define PSI_CALL_drop_table_share PSI_TABLE_CALL(drop_table_share)
#else #else
#define MYSQL_UNBIND_TABLE(handler) do { } while(0) #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_unbind_table(A1) do { } while(0)
#define PSI_CALL_rebind_table(A1,A2,A3) NULL #define PSI_CALL_rebind_table(A1,A2,A3) NULL

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2052,7 +2052,13 @@ retry_share:
if (table) if (table)
{ {
DBUG_ASSERT(table->file != NULL); 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 #ifdef WITH_PARTITION_STORAGE_ENGINE
part_names_error= set_partitions_as_used(table_list, table); part_names_error= set_partitions_as_used(table_list, table);
#endif #endif

View File

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

View File

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