Bug #44158 Double mutex locking can occur in Query Cache code, under certain conditions
Submitted: 8 Apr 2009 16:46 Modified: 15 Apr 2009 14:38
Reporter: SINISA MILIVOJEVIC Email Updates:
Status: Not a Bug Impact on me:
Category:MySQL Server: Query Cache Severity:S3 (Non-critical)
Version:5.1, 6.0-bk OS:Any
Assigned to: Kristofer Pettersson CPU Architecture:Any
Tags: qc

[8 Apr 2009 16:46] SINISA MILIVOJEVIC
In the method append_result_data, mutex `structure_guard_mutex` has to be unlocked, if the operation is successful. Under certain conditions, that are presented in the code mutex can be left locked and success (TRUE) would be returned to the calling function, being query_cache_insert().

How to repeat:
Read the code.
[15 Apr 2009 13:51] Kristofer Pettersson
Sinisa: My comment was a bit generic in nature perhaps and I was mostly thinking of the embedded library.

I think we spoke about this issue before and I still don't see the bug. If you look inside write_result_data you'll see that it has the same principles as append_result_data:

<snip snip>
  my_bool success = allocate_data_chain(result_block, data_len, query_block,
					type == Query_cache_block::RES_BEG);
  if (success)
    // It is success (nobody can prevent us write data)
<snip snip>

<snip snip>

As you can see the mutex is unlocked. A failure to unlock the mutex would most likely lead to a server crash when we try to lock the same mutex twice or possibly a dead lock. Did you see any evidence of this?