summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2016-08-21 20:18:39 +0300
committerMonty <monty@mariadb.org>2016-08-21 20:18:39 +0300
commit6f31dd093a245a21a69fd990f947611a5dcfb77b (patch)
treed9210599ff8956c39f9b1bc1e247f88c3151a990 /sql
parent8d5a0d650b123e963d5fead2424783a9b52da395 (diff)
downloadmariadb-git-6f31dd093a245a21a69fd990f947611a5dcfb77b.tar.gz
Added new status variables to make it easier to debug certain problems:
- Handler_read_retry - Update_scan - Delete_scan
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc9
-rw-r--r--sql/handler.h1
-rw-r--r--sql/multi_range_read.cc2
-rw-r--r--sql/mysqld.cc3
-rw-r--r--sql/sql_class.h4
-rw-r--r--sql/sql_delete.cc3
-rw-r--r--sql/sql_update.cc8
7 files changed, 27 insertions, 3 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 1816b9aa7eb..0edff665a33 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -2757,6 +2757,15 @@ int handler::ha_index_next_same(uchar *buf, const uchar *key, uint keylen)
return result;
}
+
+bool handler::ha_was_semi_consistent_read()
+{
+ bool result= was_semi_consistent_read();
+ if (result)
+ increment_statistics(&SSV::ha_read_retry_count);
+ return result;
+}
+
/* Initialize handler for random reading, with error handling */
int handler::ha_rnd_init_with_error(bool scan)
diff --git a/sql/handler.h b/sql/handler.h
index e2176f04933..772f2e68dab 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -3090,6 +3090,7 @@ public:
If this method returns nonzero, it will also signal the storage
engine that the next read will be a locking re-read of the row.
*/
+ bool ha_was_semi_consistent_read();
virtual bool was_semi_consistent_read() { return 0; }
/**
Tell the engine whether it should avoid unnecessary lock waits.
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 3f55ff3684d..e856400466d 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -267,7 +267,7 @@ int handler::multi_range_read_next(range_id_t *range_info)
}
else
{
- if (was_semi_consistent_read())
+ if (ha_was_semi_consistent_read())
{
/*
The following assignment is redundant, but for extra safety and to
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a1c13505304..826f2af3a85 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -7887,6 +7887,7 @@ SHOW_VAR status_vars[]= {
{"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG},
{"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_NOFLUSH},
{"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
+ {"Delete_scan", (char*) offsetof(STATUS_VAR, delete_scan_count), SHOW_LONG_STATUS},
{"Empty_queries", (char*) offsetof(STATUS_VAR, empty_queries), SHOW_LONG_STATUS},
{"Executed_events", (char*) &executed_events, SHOW_LONG_NOFLUSH },
{"Executed_triggers", (char*) offsetof(STATUS_VAR, executed_triggers), SHOW_LONG_STATUS},
@@ -7915,6 +7916,7 @@ SHOW_VAR status_vars[]= {
{"Handler_read_last", (char*) offsetof(STATUS_VAR, ha_read_last_count), SHOW_LONG_STATUS},
{"Handler_read_next", (char*) offsetof(STATUS_VAR, ha_read_next_count), SHOW_LONG_STATUS},
{"Handler_read_prev", (char*) offsetof(STATUS_VAR, ha_read_prev_count), SHOW_LONG_STATUS},
+ {"Handler_read_retry", (char*) offsetof(STATUS_VAR, ha_read_retry_count), SHOW_LONG_STATUS},
{"Handler_read_rnd", (char*) offsetof(STATUS_VAR, ha_read_rnd_count), SHOW_LONG_STATUS},
{"Handler_read_rnd_deleted", (char*) offsetof(STATUS_VAR, ha_read_rnd_deleted_count), SHOW_LONG_STATUS},
{"Handler_read_rnd_next", (char*) offsetof(STATUS_VAR, ha_read_rnd_next_count), SHOW_LONG_STATUS},
@@ -8031,6 +8033,7 @@ SHOW_VAR status_vars[]= {
{"Threads_connected", (char*) &connection_count, SHOW_INT},
{"Threads_created", (char*) &thread_created, SHOW_LONG_NOFLUSH},
{"Threads_running", (char*) &thread_running, SHOW_INT},
+ {"Update_scan", (char*) offsetof(STATUS_VAR, update_scan_count), SHOW_LONG_STATUS},
{"Uptime", (char*) &show_starttime, SHOW_SIMPLE_FUNC},
#ifdef ENABLED_PROFILING
{"Uptime_since_flush_status",(char*) &show_flushstatustime, SHOW_SIMPLE_FUNC},
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 8820205e8a2..f56ffbc1cc3 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -666,9 +666,11 @@ typedef struct system_status_var
ulong ha_read_key_count;
ulong ha_read_next_count;
ulong ha_read_prev_count;
+ ulong ha_read_retry_count;
ulong ha_read_rnd_count;
ulong ha_read_rnd_next_count;
ulong ha_read_rnd_deleted_count;
+
/*
This number doesn't include calls to the default implementation and
calls made by range access. The intent is to count only calls made by
@@ -702,6 +704,8 @@ typedef struct system_status_var
ulong select_range_count_;
ulong select_range_check_count_;
ulong select_scan_count_;
+ ulong update_scan_count;
+ ulong delete_scan_count;
ulong executed_triggers;
ulong long_query_count;
ulong filesort_merge_passes_;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 64f5c85ef22..ce7da3cd33a 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -466,6 +466,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_EXECUTE_IF("show_explain_probe_delete_exec_start",
dbug_serve_apcs(thd, 1););
+ if (!(select && select->quick))
+ status_var_increment(thd->status_var.delete_scan_count);
+
if (query_plan.using_filesort)
{
ha_rows examined_rows;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index b2af075e2f4..55dc26ef043 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -528,6 +528,9 @@ int mysql_update(THD *thd,
DBUG_EXECUTE_IF("show_explain_probe_update_exec_start",
dbug_serve_apcs(thd, 1););
+ if (!(select && select->quick))
+ status_var_increment(thd->status_var.update_scan_count);
+
if (query_plan.using_filesort || query_plan.using_io_buffer)
{
/*
@@ -594,6 +597,7 @@ int mysql_update(THD *thd,
close_cached_file(&tempfile);
goto err;
}
+
table->file->try_semi_consistent_read(1);
/*
@@ -631,7 +635,7 @@ int mysql_update(THD *thd,
thd->inc_examined_row_count(1);
if (!select || (error= select->skip_record(thd)) > 0)
{
- if (table->file->was_semi_consistent_read())
+ if (table->file->ha_was_semi_consistent_read())
continue; /* repeat the read of the same row if it still exists */
table->file->position(table->record[0]);
@@ -746,7 +750,7 @@ int mysql_update(THD *thd,
thd->inc_examined_row_count(1);
if (!select || select->skip_record(thd) > 0)
{
- if (table->file->was_semi_consistent_read())
+ if (table->file->ha_was_semi_consistent_read())
continue; /* repeat the read of the same row if it still exists */
store_record(table,record[1]);