maria-developers team mailing list archive
-
maria-developers team
-
Mailing list archive
-
Message #02081
Re: SHOW PROFILE enhancements for Windows
Hi!
>>>>> "Alex" == Alex Budovski <abudovski@xxxxxxxxx> writes:
Alex> Re: my_thread_init
Alex> I tried reverting my change and looking at the code again -- perhaps
Alex> we have a different bug.
Alex> The function does indeed set 'id' to a non-zero value (tmp->id =
Alex> ++thread_count), but then it is reset to 0 by someone else.
Alex> Let me show you:
Alex> First of all, we hit a verifier stop telling us a CS was already initialized:
<cut>
Alex> So it was reset by someone else, after being initialized, causing the
Alex> "if (THR_KEY_mysys.id)" to fail and re-initialize the CSs (there's
Alex> more than one).
Alex> So let's see who is writing to it: (by setting a data breakpoint on
Alex> 0x03338f70+0x054)
Alex> ChildEBP RetAddr
Alex> 0012f608 008967fa mysqld!THD::store_globals+0xa4 <-- here
Alex> 0012f624 008745f9 mysqld!myxt_create_thread+0x10a
Alex> 0012f648 004d46f5 mysqld!pbxt_init+0x3f9
Alex> 0012f6a0 00471f97 mysqld!ha_initialize_handlerton+0xa5
Alex> 0012f6e4 00471cf1 mysqld!plugin_initialize+0x67
Alex> 0012f86c 00447d44 mysqld!plugin_init+0x541
Alex> 0012fb7c 0044595c mysqld!init_server_components+0x5c4
Alex> 0012fd30 00448a08 mysqld!win_main+0x1cc
Alex> 0012fd40 00448d7a mysqld!mysql_service+0x38
Alex> 0012ff6c 00401137 mysqld!main+0x35a
Alex> 0012ffb8 0040100f mysqld!__tmainCRTStartup+0x117
Alex> 0012ffc0 7c817077 mysqld!mainCRTStartup+0xf
Alex> 0012fff0 00000000 kernel32!BaseProcessStart+0x23
Alex> THD::store_globals() does the following:
Alex> mysys_var=my_thread_var;
Alex> mysys_var->id= thread_id; // Let's see what this->thread_id is.
Alex> 2:005> ?? this->thread_id
Alex> unsigned long 0
Alex> So here it gets set to 0, and hence our code fails.
Alex> Do you know why this might be?
Yes, this explain it.
We set the mysys_var->id to thread_id in store_globals() to allow
MySQL to bind a user connection to different threads during execution
of one query. We need to change mysys->thread_id so that all reports
(like dbug_print) are printed with the same logical thread id.
The bug in question after this change was that thread_id was not
initialized to 1 and the above call to store_global() was done before
any creating of a user connection.
Thanks to sort this out. This makes it clear that it was a correct
change to check for 'init'.
Regards,
Monty
Follow ups
References