Commit graph

9 commits

Author SHA1 Message Date
Davi Arnaut
657b157511 Bug#56822: Add a thread state for sessions waiting on the query cache lock
Only wait for a single debug signal at a time as the signal state
is global. Also, do not activate the query cache debug sync points
if the thread has no associated THD session.
2010-10-08 09:16:20 -03:00
Davi Arnaut
76643a469a Bug#56822: Add a thread state for sessions waiting on the query cache lock
The problem was that threads waiting on the query cache lock
are not easily seen due to the lack of a state indicating that
the thread is waiting on the said lock. This made it difficult
for users to quickly spot (for example, via SHOW PROCESSLIST)
a query cache contention problem.

The solution is to update the thread state when the query cache
lock needs to be acquired. Whenever the lock is to be acquired,
the thread state is updated to "Waiting for query cache lock"
and is reset once the lock is granted or the wait is interrupted.
The intention is to make query cache related hangs more evident.

To further investigate query cache related locking problems, one
may use PERFORMANCE_SCHEMA to track the overhead associated with
the locking bits and determine which particular lock is being a
contention point.
2010-10-07 19:51:37 -03:00
Alexander Nozdrin
c784ee2782 Patch for Bug#52356: query_cache_debug fails on Linux.
There were two problems here:
  1. misleading error message
  2. abusing KILL QUERY in the test case

1. The server reported "'DELETE FROM t1' failed: 1689: Wait on a lock was
aborted due to a pending exclusive lock", while the proper error message
should be "'DELETE FROM t1' failed: 1317: Query execution was interrupted".

The problem is that the server has two different flags for
signalling that a query is being killed: THD::killed and
mysys_var::abort. The test case triggers a race: sometimes
mysys_var::abort is set earlier than THD::killed. That leads
to the following situation:

  - thr_lock() checks mysys_var::abort and returns error status,
    since mysys_var::abort is set;

  - the caller (mysql_lock_tables()) gets an error from thr_lock(),
    but THD::killed is not set, so it decides that thr_lock() couldn't
    get a lock due to a pending exclusive lock.

This is a known issue with the server and it's not going to be fixed soon.

5.5 differs from 5.1 here as follows: when thr_lock() returns an error:
  - 5.1 continues trying thr_lock() until success;
  - 5.5 propagates the error

2. The test case uses KILL QUERY is a highly concurent environment.

The fix is to wait for the dying statement to rest in peace before
executing another DELETE FROM t1.
2010-04-30 16:12:41 +04:00
Kristofer Pettersson
be07cbe230 Bug#43758 Query cache can lock up threads in 'freeing items' state
This patch corrects a misstake in the test case for bug patch 43658.

There was a race in the test case when the thread id was retrieved from the processlist.
The result was that the same thread id was signalled twice and one thread id wasn't
signalled at all.

The affected platforms appears to be limited to linux.
2009-06-17 16:28:11 +02:00
Kristofer Pettersson
b22d02ad42 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?

This patch is a refactoring of this lock system. It introduces four new methods:
   Query_cache::try_lock()
   Query_cache::lock()
   Query_cache::lock_and_suspend()
   Query_cache::unlock()

This change also deprecates wait_while_table_flush_is_in_progress(). All threads are
queued and put on a conditional wait. On each unlock the queue is signalled. This resolve
the issues with left over threads. To assure that no threads are spending unnecessary
time waiting a signal broadcast is issued every time a lock is taken before a full
cache flush.
2009-06-16 10:34:47 +02:00
Davi Arnaut
a2e4449bfc Bug#41098: Query Cache returns wrong result with concurrent insert
The problem is that select queries executed concurrently with
a concurrent insert on a MyISAM table could be cached if the
select started after the query cache invalidation but before
the unlock of tables performed by the concurrent insert. This
race could happen because the concurrent insert was failing
to prevent cache of select queries happening at the same time.

The solution is to add a 'uncacheable' status flag to signal
that a concurrent insert is being performed on the table and
that queries executing at the same time shouldn't cache the
results.
2009-02-19 18:09:35 -03:00
kent/mysqldev@mysql.com/production.mysql.com
fd1bd7547a mysqld.cc:
Corrects build problems embedded on Windows
Makefile.am:
  Install .sym or mysqld-debug if exists
query_cache_debug.test, query_cache_debug.result:
  Set more resonable query cache size (bug#35749)
CMakeLists.txt:
  Added missing stacktrace.c
2008-04-02 00:43:17 +02:00
thek@adventure.(none)
77569d6708 Fixed faulty test case caused by race condition. 2008-01-11 14:16:46 +01:00
thek@adventure.(none)
3cd3a40d4d Fixed test layout error. 2008-01-07 21:06:18 +01:00