From 917715cb7f97677336cf1c6f2cc2788d31a9c7ce Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Thu, 16 Mar 2017 00:35:10 +0300 Subject: [PATCH 2/2] Initialize thread-local PRNG with OS thread ID. --- storage/innobase/include/ut0rnd.ic | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storage/innobase/include/ut0rnd.ic b/storage/innobase/include/ut0rnd.ic index 834e992..42e64e5 100644 --- a/storage/innobase/include/ut0rnd.ic +++ b/storage/innobase/include/ut0rnd.ic @@ -39,6 +39,7 @@ Created 5/30/1994 Heikki Tuuri #define UT_XOR_RND2 143537923 #include +#include extern thread_local_key_t ut_rnd_ulint_counter_key; /********************************************************//** @@ -95,10 +96,15 @@ ut_rnd_gen_ulint(void) rnd_count_value = my_get_thread_local(ut_rnd_ulint_counter_key); - if(!rnd_count_value) { + if(UNIV_UNLIKELY(!rnd_count_value)) { /* Reset the value if we recieve NULL rnd value i.e. coming from new thread */ - rnd = 65654363; + rnd = static_cast(my_thread_os_id()); + + if (UNIV_UNLIKELY(!rnd)) { + + rnd = 65654363; + } } else { /* Set otherwise rnd to non null recieved from the existing thread */