diff options
author | Daniele Sciascia <daniele.sciascia@galeracluster.com> | 2015-10-20 17:54:14 +0200 |
---|---|---|
committer | Nirbhay Choubey <nirbhay@mariadb.com> | 2016-02-22 17:46:22 -0500 |
commit | ace86a2375c3f47badf49796eda14959b0487269 (patch) | |
tree | 2287be909e31bbdd9ed914f3065d646b3ace6122 /sql/sql_cache.cc | |
parent | c1ea0570af88ed12f55fc20c54262b3688b9981d (diff) | |
download | mariadb-git-ace86a2375c3f47badf49796eda14959b0487269.tar.gz |
refs codership/mysql-wsrep#201
- Fixes query cache so that it is aware of wsrep_sync_wait.
Query cache would return (possibly stale) results to the
client, regardless of the value of wsrep_sync_wait.
- Includes the test case that reproduced the issue.
Diffstat (limited to 'sql/sql_cache.cc')
-rw-r--r-- | sql/sql_cache.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index e1efb1e85d6..0d3497ad964 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1846,6 +1846,7 @@ Query_cache::send_result_to_client(THD *thd, char *org_sql, uint query_length) goto err; } } + /* Try to obtain an exclusive lock on the query cache. If the cache is disabled or if a full cache flush is in progress, the attempt to @@ -1957,6 +1958,25 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d", } DBUG_PRINT("qcache", ("Query in query hash 0x%lx", (ulong)query_block)); +#ifdef WITH_WSREP + if (WSREP_CLIENT(thd) && wsrep_must_sync_wait(thd)) { + unlock(); + if (wsrep_sync_wait(thd)) + goto err; + if (try_lock(TRUE)) + goto err; + query_block = (Query_cache_block *) my_hash_search(&queries, + (uchar*) sql, + tot_length); + if (query_block == 0 || + query_block->query()->result() == 0 || + query_block->query()->result()->type != Query_cache_block::RESULT) + { + goto err_unlock; + } + } +#endif /* WITH_WSREP */ + /* Now lock and test that nothing changed while blocks was unlocked */ BLOCK_LOCK_RD(query_block); |