I noticed that there is a tracking variable used: m_requests_in_progress which is to make sure that disabling/enabling is not done while queries are in-flight within the query cache critical section.
I see that the enabling the a disabled query cache can fail only when
a) query cache disabling is in progress or
b) global query cache is disabled but session query_cache_type is tried.
Tested with MariaDB 5.5 and works as expected.
I noticed that there is a tracking variable used: m_requests_ in_progress which is to make sure that disabling/enabling is not done while queries are in-flight within the query cache critical section.
I see that the enabling the a disabled query cache can fail only when
a) query cache disabling is in progress or
b) global query cache is disabled but session query_cache_type is tried.