MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Marc Alff Date:July 28 2009 2:27am
Subject:Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)
View as plain text  
Guilhem,

Guilhem Bichot wrote:
> Hello Marc,
> 
> Marc Alff a écrit, Le 10.07.2009 19:07:
>> Please note that the explanation I am offering here:
>> - is not implemented
>> - is not documented in WL
>> - has not been fully discussed and approved yet,
>> since work on the THREADS table was stalled.
>> This is only where I would like personally the performance schema to go,
>> so having a picture of the long term goal helps understanding, but you
>> may *not* use that information to claim that the current code is
>> incomplete, because this is not supposed to be in the code yet.
>> I am sure that by the time THREADS is fully discussed, some details will
>> change.
>>
>> performance_schema.THREADS will show "jobs" running in the server.
>> A job is either real or virtual.
>> A real job is an OS thread (pthread_t)
>> A virtual job is a THD like object, picked up by real threads in a
>> thread pool.
>> A job is either a bound to a connection or connectionless
>> A job bound to a connection is a THD
>> A connectionless job is typically a background job
> <cut lots of explanations>
>> So, to summarize, in case of thread pools:
>>
>> The THD::ID <==> PSI_thread::thread_id association never changes,
>> a given PSI_thread is bound to a given THD for the life of THD.
>> Note the '<==>' notation.
>>
>> The PSI_thread::thread_id <--> pthread_t association always changes,
>> each time a job is picked from or returned to the pool.
>> Note the '<-->' notation.
>>
>> THD::ID <=(permanent)=> PSI_thread::thread_id <-(temporary)->
> pthread_t
> 
> I think I followed so far. It was really detailed, thanks.
> 
>> That is why THD::store_global() does not call mysql_thread_set_psi_id().
> 
> Uh, here I don't understand.
> Given that "The THD::ID <==> PSI_thread::thread_id association never
> changes", I would expect that PSI_thread::thread_id is set once for all
> shortly after when the THD is built, so for example in THD's
> constructor, or in THD::store_globals... ?

When THD is a real connection, and not a fake temporary object created
to spoof some code, PSI_thread::thread_id is indeed set once for all,
when a thread is created to run THD.

in mysqld.cc:
void create_thread_to_handle_connection(THD *thd)
{
 ...

  mysql_thread_create(key_thread_one_connection,
                      &thd->real_id, &connection_attrib,
                      handle_one_connection, (void*) thd)));
 ...
}

in sql_connect.cc:
pthread_handler_t handle_one_connection(void *arg)
{
  THD *thd= (THD*) arg;

  mysql_thread_set_psi_id(thd->thread_id);

  do_handle_one_connection(thd);
  return 0;
}

> What am I missing?
> 

(a) code executing THD::THD() has nothing to do with a new user connection.

(b) THD::store_globals() is called many times over the life of THD, in
case of pool-of-thread.

Because of this, both of your suggestions
"so for example in THD's constructor, or in THD::store_globals..."
do not work.


Thread
bzr commit into mysql-6.0-perfschema branch (marc.alff:3150) Marc Alff21 May
  • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Guilhem Bichot26 May
    • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Marc Alff26 May
      • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Guilhem Bichot28 May
        • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Marc Alff1 Jul
          • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Guilhem Bichot10 Jul
            • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Marc Alff10 Jul
              • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Guilhem Bichot27 Jul
                • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Marc Alff28 Jul
                  • Re: bzr commit into mysql-6.0-perfschema branch (marc.alff:3150)Guilhem Bichot28 Jul