List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:May 4 2011 11:52am
Subject:Re: Use of thread specific data with mysqld
View as plain text  
Hi!

>>>>> "Mats" == Mats Kindahl <mats.kindahl@stripped> writes:

Mats> On 04/28/2011 02:41 AM, Hiromichi Watari wrote:
>> Hi Marc,
>> Thank you very much for your pointer, I believe I'm OK with my data residing in
> struct st_my_thread_var with the common key THR_KEY_mysys for now.  However if the need
> changes in the future I will definitely take a look at what you have done.  I appreciate
> you taking time to answer my question.
>> Hiromichi

Mats> Hi Hiromichi,

Mats> A general note on storing data for a thread using pthread_setspecific
Mats> in MySQL: it only works if there is a single THD associated with each
Mats> thread. There were, for example, an experimental thread pool
Mats> implementation in an 6.0 of the server trees where each POSIX thread
Mats> managed several THD "session threads". If this architecture is used,
Mats> it means that thread-specific data set using pthread_setspecific can
Mats> "leak" to a different session if the same thread switches to use a
Mats> different THD structure.

Mats> This is not the case unless you use 6.0, but since that never GA:ed,
Mats> it should not be a problem in production environments since the 5.1
Mats> server has one THD structure for each POSIX thread.

In MariaDB there is the option to run with thread pool and as far as I
know, there is also in the plans to release a tread pool for MySQL
enterprise (but not for the community server).

With the thread pool, you can however be sure that the thread may only
change between two queries, not during a query.
(This may change when we start to add parallel execution of queries).

In addition, the following thread objects will on thread switch be
copied to point to the relevant objects:

THR_THD
THR_MALLOC

If you want to store connection specific information, you should store
them in THD, not in THR_KEY_mysys !

Regards,
Monty
Thread
Use of thread specific data with mysqldHiromichi Watari24 Apr
  • Re: Use of thread specific data with mysqldSergei Golubchik24 Apr
    • Re: Use of thread specific data with mysqldHiromichi Watari26 Apr
      • Re: Use of thread specific data with mysqldMarc Alff27 Apr
        • Re: Use of thread specific data with mysqldHiromichi Watari28 Apr
          • Re: Use of thread specific data with mysqldMats Kindahl3 May
            • Re: Use of thread specific data with mysqldHiromichi Watari4 May
            • Re: Use of thread specific data with mysqldMichael Widenius4 May
              • Regression test returning different result each time it's runHiromichi Watari15 Jun
                • Re: Regression test returning different result each time it's runØystein Grøvlen16 Jun
                  • Re: Regression test returning different result each time it's runHiromichi Watari16 Jun
                    • Re: Regression test returning different result each time it's runØystein Grøvlen16 Jun
                      • Re: Regression test returning different result each time it's runRick James16 Jun
                        • Re: Regression test returning different result each time it's runHiromichi Watari18 Jun
                      • Re: Regression test returning different result each time it's runHiromichi Watari18 Jun
                        • Name of function to execute mysql commandHiromichi Watari21 Jan