From: Kristofer Pettersson Date: April 1 2009 3:41pm Subject: bzr commit into mysql-5.1-bugteam branch (kristofer.pettersson:2823) Bug#43758 List-Archive: http://lists.mysql.com/commits/71099 X-Bug: 43758 Message-Id: <0KHF001E2I603730@fe-emea-09.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_dLDEl4Xo/aH0+xx2hEbKvQ)" --Boundary_(ID_dLDEl4Xo/aH0+xx2hEbKvQ) MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline #At file:///home/thek/Development/cpp/mysqlbzr/51-bug43748/ based on revid:kristofer.pettersson@stripped 2823 Kristofer Pettersson 2009-04-01 Bug#43758 Query cache can lock up threads in 'freeing items' state Early patch submitted for discussion. It is possible for more than one thread to enter the condition in query_cache_insert(), but the condition predicate is to signal one thread each time the cache status changes between the following states: {NO_FLUSH_IN_PROGRESS,FLUSH_IN_PROGRESS, TABLE_FLUSH_IN_PROGRESS} Consider three threads THD1, THD2, THD3 THD2: select ... => Got a writer in ::store_query THD3: select ... => Got a writer in ::store_query THD1: flush tables => qc status= FLUSH_IN_PROGRESS; new writers are blocked. THD2: select ... => Still got a writer and enters cond in query_cache_insert THD3: select ... => Still got a writer and enters cond in query_cache_insert THD1: flush tables => finished and signal status change. THD2: select ... => Wakes up and completes the insert. THD3: select ... => Happily waiting for better times. Why hurry? A solution to this situation is to use a broadcast on the thread group which contain result set writers. Note about the test case: * If the thread policy in Query_cache::wait_while_flush_is_in_progress is set to RELEASE_ONE_ON_EACH_SIGNAL then the test case will hang. This should show the existence of a problem before the patch. * Two thread groups used to avoid using broadcast where it isn't needed. If it worth having two groups? Is substituting signal for broadcast enough? --Boundary_(ID_dLDEl4Xo/aH0+xx2hEbKvQ) MIME-version: 1.0 Content-type: text/bzr-bundle; name="bzr/kristofer.pettersson@stripped"; charset=us-ascii Content-transfer-encoding: 7BIT Content-disposition: inline; filename="bzr/kristofer.pettersson@stripped" # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: kristofer.pettersson@stripped\ # e18uoze6kgubwfxs # target_branch: file:///home/thek/Development/cpp/mysqlbzr/51-\ # bug43748/ # testament_sha1: 49e556ac2b57c22ee72079e0385bb3e0f80a21ae # timestamp: 2009-04-01 17:41:58 +0200 # base_revision_id: kristofer.pettersson@stripped\ # ruy960z1to0gw5f3 # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWQExnZsAAaJ/gEAQUABZ9/// /+3+gL/v//pQBUWs9V2tjLrrumOmlYJKE0T1PQTE0mp+k9U2KY1BkaGjNQ0aGCaaGg0QRjU0ySA9 TJoAAADIAGmjQAJQQmgIamao08U/VB7VAaaDT1A0ZAD1ABxkyaGIxNGARgJhAGAmmjTI0AwkRTTS aYUwlPaaJoxpJ6npNBoepk9EAAZPUZLd7x+dpJq6u43usqmJNTZloYqmMwztcxX/r+uxDWOcHSyj Vvz1yZFwMQTCcPgLR0ydUl8pIUiuPROp/Nu99cK5iFwe9iXvSYCskRnJVkYuhWLHK60IKRYigwe0 GUVKDXT0w9nCT8NpAhS1lUC1bR6Z24PmdtN0JzlJbIxjGquN+hhIiwFRUbomrn32SjpXKTCwLIfb WSYcvDMaDMrXwO4IQrIuqZuRa/NNGduYMjbvPubODlZRp1g3fsclawDTvSszVNhybDr2cvqdiik/ VKFulqopwre3RHYKVgrBQuxgagLI8veiljbtb4u+Eo4kvmGoKSk5Glpi0pQyPTwT1jgxfLy4tuBd Mlrl2M108KhWFaTyzGP3MQSuqJIbP8rMAyV2HrAiiaoajXZ5a5rAuNRuqqFS70SBpWkg0NPM6jLK eF+c5Y8UAuGIMfGq4+wsWiwwJqwiYjN6HHNRjMJ8dVme8kMaCtT9DtBpqFl5NE1EKo7lSzWzDmYz zzqKW3XwPIjHQuQtfd2iO/0lGjnZnwkXZLowC8DZz4VPQx4XZ4NyRAt4dP0V5ovqe9n+SIeG13eh vkxyfSW1nZ3A4qSMQd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