summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Vojtovich <svoj@mariadb.org>2020-05-07 23:07:03 +0400
committerSergey Vojtovich <svoj@mariadb.org>2020-05-07 23:07:03 +0400
commit5e52d897ecc4c2f3d0e85d0b486d78f9b3cfd94d (patch)
treed2aab296e805b8139bdadeb887d6d54d5f68a02a
parent6c7eb74295aa9b09f0556ed7036a1a55da1d8b9c (diff)
downloadmariadb-git-5e52d897ecc4c2f3d0e85d0b486d78f9b3cfd94d.tar.gz
Wait for stats in the LOADING statebb-10.5-svoj-MDEV-19061
Fixes both stats and histograms. To be fixed up into "ae6a37e Thread safe statistics loading".
-rw-r--r--sql/table.h25
1 files changed, 20 insertions, 5 deletions
diff --git a/sql/table.h b/sql/table.h
index d7a7d97180b..9b12c556829 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -629,13 +629,28 @@ class TABLE_STATISTICS_CB
return state.load(std::memory_order_acquire) == READY;
}
- /** Sets mutual exclusion for data loading */
+ /**
+ Sets mutual exclusion for data loading
+
+ If stats are in LOADING state, waits until state change.
+
+ @return
+ @retval true atomic EMPTY -> LOADING transfer completed, ok to load
+ @retval false stats are in READY state, no need to load
+ */
bool start_load()
{
- state_codes expected= EMPTY;
- return state.compare_exchange_weak(expected, LOADING,
- std::memory_order_relaxed,
- std::memory_order_relaxed);
+ for (;;)
+ {
+ state_codes expected= EMPTY;
+ if (state.compare_exchange_weak(expected, LOADING,
+ std::memory_order_relaxed,
+ std::memory_order_relaxed))
+ return true;
+ if (expected == READY)
+ return false;
+ ut_delay(1);
+ }
}
/** Marks data available for subsequent use */