Removed tdc_increment_refresh_version()

It is never called after 7fb9d64, which makes the whole refresh version
infrastructure useless.

Removed:
- tdc_version_t
- TDC_VERSION_MAX
- tdc_version
- TDC_element::version
- tdc_increment_refresh_version()
- tdc_refresh_version()
- refresh_version argument of tdc_wait_for_old_version()
- Flush_commands status variable
- refresh version from COM_STATISTICS
- refresh version from dbug printouts

Part of MDEV-17882 - Cleanup refresh version
This commit is contained in:
Sergey Vojtovich 2019-06-19 14:59:36 +04:00
parent 0c05a2ed71
commit 0aa807d100
6 changed files with 8 additions and 47 deletions

View File

@ -7050,16 +7050,6 @@ static int show_table_definitions(THD *thd, SHOW_VAR *var, char *buff,
} }
static int show_flush_commands(THD *thd, SHOW_VAR *var, char *buff,
enum enum_var_type scope)
{
var->type= SHOW_LONGLONG;
var->value= buff;
*((longlong *) buff)= (longlong)tdc_refresh_version();
return 0;
}
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY)
/* /*
@ -7439,7 +7429,6 @@ SHOW_VAR status_vars[]= {
{"Feature_trigger", (char*) offsetof(STATUS_VAR, feature_trigger), SHOW_LONG_STATUS}, {"Feature_trigger", (char*) offsetof(STATUS_VAR, feature_trigger), SHOW_LONG_STATUS},
{"Feature_window_functions", (char*) offsetof(STATUS_VAR, feature_window_functions), SHOW_LONG_STATUS}, {"Feature_window_functions", (char*) offsetof(STATUS_VAR, feature_window_functions), SHOW_LONG_STATUS},
{"Feature_xml", (char*) offsetof(STATUS_VAR, feature_xml), SHOW_LONG_STATUS}, {"Feature_xml", (char*) offsetof(STATUS_VAR, feature_xml), SHOW_LONG_STATUS},
{"Flush_commands", (char*) &show_flush_commands, SHOW_SIMPLE_FUNC},
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS}, {"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
{"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS}, {"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
{"Handler_discover", (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONG_STATUS}, {"Handler_discover", (char*) offsetof(STATUS_VAR, ha_discover_count), SHOW_LONG_STATUS},

View File

@ -1404,9 +1404,9 @@ bool wait_while_table_is_used(THD *thd, TABLE *table,
{ {
DBUG_ENTER("wait_while_table_is_used"); DBUG_ENTER("wait_while_table_is_used");
DBUG_ASSERT(!table->s->tmp_table); DBUG_ASSERT(!table->s->tmp_table);
DBUG_PRINT("enter", ("table: '%s' share: %p db_stat: %u version: %lld", DBUG_PRINT("enter", ("table: '%s' share: %p db_stat: %u",
table->s->table_name.str, table->s, table->s->table_name.str, table->s,
table->db_stat, table->s->tdc->version)); table->db_stat));
if (thd->mdl_context.upgrade_shared_lock( if (thd->mdl_context.upgrade_shared_lock(
table->mdl_ticket, MDL_EXCLUSIVE, table->mdl_ticket, MDL_EXCLUSIVE,
@ -2013,8 +2013,6 @@ retry_share:
{ {
if (share->tdc->flushed) if (share->tdc->flushed)
{ {
DBUG_PRINT("info", ("Found old share version: %lld current: %lld",
share->tdc->version, tdc_refresh_version()));
/* /*
We already have an MDL lock. But we have encountered an old We already have an MDL lock. But we have encountered an old
version of table in the table definition cache which is possible version of table in the table definition cache which is possible

View File

@ -2223,13 +2223,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
#endif #endif
my_snprintf(buff, buff_len - 1, my_snprintf(buff, buff_len - 1,
"Uptime: %lu Threads: %d Questions: %lu " "Uptime: %lu Threads: %d Questions: %lu "
"Slow queries: %lu Opens: %lu Flush tables: %lld " "Slow queries: %lu Opens: %lu "
"Open tables: %u Queries per second avg: %u.%03u", "Open tables: %u Queries per second avg: %u.%03u",
uptime, uptime,
(int) thread_count, (ulong) thd->query_id, (int) thread_count, (ulong) thd->query_id,
current_global_status_var->long_query_count, current_global_status_var->long_query_count,
current_global_status_var->opened_tables, current_global_status_var->opened_tables,
tdc_refresh_version(),
tc_records(), tc_records(),
(uint) (queries_per_second1000 / 1000), (uint) (queries_per_second1000 / 1000),
(uint) (queries_per_second1000 % 1000)); (uint) (queries_per_second1000 % 1000));

View File

@ -110,8 +110,6 @@ static void print_cached_tables(void)
tdc_iterate(0, (my_hash_walk_action) print_cached_tables_callback, NULL, true); tdc_iterate(0, (my_hash_walk_action) print_cached_tables_callback, NULL, true);
printf("\nCurrent refresh version: %ld\n",
(long) tdc_refresh_version());
fflush(stdout); fflush(stdout);
/* purecov: end */ /* purecov: end */
return; return;

View File

@ -68,7 +68,6 @@ I_P_List <TDC_element,
I_P_List_null_counter, I_P_List_null_counter,
I_P_List_fast_push_back<TDC_element> > unused_shares; I_P_List_fast_push_back<TDC_element> > unused_shares;
static tdc_version_t tdc_version; /* Increments on each reload */
static bool tdc_inited; static bool tdc_inited;
@ -624,7 +623,6 @@ bool tdc_init(void)
tdc_inited= true; tdc_inited= true;
mysql_mutex_init(key_LOCK_unused_shares, &LOCK_unused_shares, mysql_mutex_init(key_LOCK_unused_shares, &LOCK_unused_shares,
MY_MUTEX_INIT_FAST); MY_MUTEX_INIT_FAST);
tdc_version= 1L; /* Increments on each reload */
lf_hash_init(&tdc_hash, sizeof(TDC_element) + lf_hash_init(&tdc_hash, sizeof(TDC_element) +
sizeof(Share_free_tables) * (tc_instances - 1), sizeof(Share_free_tables) * (tc_instances - 1),
LF_HASH_UNIQUE, 0, 0, LF_HASH_UNIQUE, 0, 0,
@ -850,7 +848,6 @@ retry:
element->share= share; element->share= share;
share->tdc= element; share->tdc= element;
element->ref_count++; element->ref_count++;
element->version= tdc_refresh_version();
element->flushed= false; element->flushed= false;
mysql_mutex_unlock(&element->LOCK_table_share); mysql_mutex_unlock(&element->LOCK_table_share);
@ -965,9 +962,9 @@ void tdc_release_share(TABLE_SHARE *share)
mysql_mutex_lock(&share->tdc->LOCK_table_share); mysql_mutex_lock(&share->tdc->LOCK_table_share);
DBUG_PRINT("enter", DBUG_PRINT("enter",
("share: %p table: %s.%s ref_count: %u version: %lld", ("share: %p table: %s.%s ref_count: %u",
share, share->db.str, share->table_name.str, share, share->db.str, share->table_name.str,
share->tdc->ref_count, share->tdc->version)); share->tdc->ref_count));
DBUG_ASSERT(share->tdc->ref_count); DBUG_ASSERT(share->tdc->ref_count);
if (share->tdc->ref_count > 1) if (share->tdc->ref_count > 1)
@ -1217,7 +1214,7 @@ bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
*/ */
int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name, int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name,
ulong wait_timeout, uint deadlock_weight, tdc_version_t refresh_version) ulong wait_timeout, uint deadlock_weight)
{ {
TDC_element *element; TDC_element *element;
@ -1225,7 +1222,7 @@ int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name,
return FALSE; return FALSE;
else if (element == MY_ERRPTR) else if (element == MY_ERRPTR)
return TRUE; return TRUE;
else if (element->flushed && refresh_version > element->version) else if (element->flushed)
{ {
struct timespec abstime; struct timespec abstime;
set_timespec(abstime, wait_timeout); set_timespec(abstime, wait_timeout);
@ -1236,20 +1233,6 @@ int tdc_wait_for_old_version(THD *thd, const char *db, const char *table_name,
} }
tdc_version_t tdc_refresh_version(void)
{
return (tdc_version_t)my_atomic_load64_explicit(&tdc_version, MY_MEMORY_ORDER_RELAXED);
}
tdc_version_t tdc_increment_refresh_version(void)
{
tdc_version_t v= (tdc_version_t)my_atomic_add64_explicit(&tdc_version, 1, MY_MEMORY_ORDER_RELAXED);
DBUG_PRINT("tcache", ("incremented global refresh_version to: %lld", v));
return v + 1;
}
/** /**
Iterate table definition cache. Iterate table definition cache.

View File

@ -26,14 +26,11 @@ struct Share_free_tables
char pad[CPU_LEVEL1_DCACHE_LINESIZE]; char pad[CPU_LEVEL1_DCACHE_LINESIZE];
}; };
typedef int64 tdc_version_t;
#define TDC_VERSION_MAX INT_MAX64
struct TDC_element struct TDC_element
{ {
uchar m_key[NAME_LEN + 1 + NAME_LEN + 1]; uchar m_key[NAME_LEN + 1 + NAME_LEN + 1];
uint m_key_length; uint m_key_length;
tdc_version_t version;
bool flushed; bool flushed;
TABLE_SHARE *share; TABLE_SHARE *share;
@ -90,10 +87,7 @@ extern bool tdc_remove_table(THD *thd, enum_tdc_remove_table_type remove_type,
extern int tdc_wait_for_old_version(THD *thd, const char *db, extern int tdc_wait_for_old_version(THD *thd, const char *db,
const char *table_name, const char *table_name,
ulong wait_timeout, uint deadlock_weight, ulong wait_timeout, uint deadlock_weight);
tdc_version_t refresh_version= TDC_VERSION_MAX);
extern tdc_version_t tdc_refresh_version(void);
extern tdc_version_t tdc_increment_refresh_version(void);
extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument, extern int tdc_iterate(THD *thd, my_hash_walk_action action, void *argument,
bool no_dups= false); bool no_dups= false);