summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2019-10-16 19:00:43 +0400
committerSergey Vojtovich <svoj@mariadb.org>2020-05-29 21:53:54 +0400
commitc2798784931a59f996275e14220b74f450828b4b (patch)
tree09a17f66e2c1d4d46cea518692e70272d2cd4015 /sql/table.cc
parent609a0d3db3fecc12c2d63b52bec3e3a305e6c702 (diff)
downloadmariadb-git-c2798784931a59f996275e14220b74f450828b4b.tar.gz
Thread safe histograms loading
Previously multiple threads were allowed to load histograms concurrently. There were no known problems caused by this. But given amount of data races in this code, it'd happen sooner or later. To avoid scalability bottleneck, histograms loading is protected by per-TABLE_SHARE atomic variable. Whenever histograms were loaded by preceding statement (hot-path), a scalable load-acquire check is performed. Whenever histograms have to be loaded anew, mutual exclusion for loaders is established by atomic variable. If histograms are being loaded concurrently, statement waits until load is completed. - Table_statistics::total_hist_size moved to TABLE_STATISTICS_CB: only meaningful within TABLE_SHARE (not used for collected stats). - TABLE_STATISTICS_CB::histograms_can_be_read and TABLE_STATISTICS_CB::histograms_are_read are replaced with a tri state atomic variable. - Simplified away alloc_histograms_for_table_share(). Note: there's still likely a data race if a thread attempts accessing histograms data after it failed to load it (because of concurrent load). It was there previously and goes out of the scope of this effort. One way of fixing it could be reviving TABLE::histograms_are_read and adding appropriate checks whenever it is needed. Part of MDEV-19061 - table_share used for reading statistical tables is not protected
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc2
1 files changed, 0 insertions, 2 deletions
diff --git a/sql/table.cc b/sql/table.cc
index 1d3bebcc5d5..20fc86e35f0 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -416,8 +416,6 @@ void TABLE_SHARE::destroy()
delete_stat_values_for_table_share(this);
free_root(&stats_cb.mem_root, MYF(0));
- stats_cb.histograms_can_be_read= FALSE;
- stats_cb.histograms_are_read= FALSE;
/* The mutexes are initialized only for shares that are part of the TDC */
if (tmp_table == NO_TMP_TABLE)