Merge lp:~percona-dev/percona-server/bug677407 into lp:~percona-dev/percona-server/release-5.1.53

Proposed by Alexey Kopytov
Status: Merged
Approved by: Vadim Tkachenko
Approved revision: no longer in the source branch.
Merged at revision: 154
Proposed branch: lp:~percona-dev/percona-server/bug677407
Merge into: lp:~percona-dev/percona-server/release-5.1.53
Diff against target: 151 lines (+139/-0)
2 files modified
bug677407.patch (+138/-0)
series (+1/-0)
To merge this branch: bzr merge lp:~percona-dev/percona-server/bug677407
Reviewer Review Type Date Requested Status
Vadim Tkachenko Approve
Fred Linhoss (community) documentation Approve
Review via email: mp+42257@code.launchpad.net

Description of the change

Fix for LP bug #677407.

To post a comment you must log in.
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

looks good, but requires docs entry

review: Needs Fixing
Revision history for this message
Fred Linhoss (fred-linhoss) wrote :

Will be in release notes for 5.1.53-11.7.

review: Approve (documentation)
Revision history for this message
Vadim Tkachenko (vadim-tk) wrote :

good

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'bug677407.patch'
2--- bug677407.patch 1970-01-01 00:00:00 +0000
3+++ bug677407.patch 2010-11-30 16:59:10 +0000
4@@ -0,0 +1,138 @@
5+# name : bug677407
6+# introduced : 13
7+# maintainer : Alexey
8+
9+LP bug#677407 / MySQL Bug#48883: Stale data from INNODB_LOCKS table.
10+
11+The innodb.innodb_information_schema test could fail sporadically due to
12+the flawed logic in the INFORMATION_SCHEMA.INNODB_LOCKS caching
13+mechanism.
14+
15+The logic for how to check when to update the table cache for
16+INNODB_LOCKS with real data was flawed. This could result in both not
17+updating the cache often enough (when the table is queried repeatedly
18+with less than 100 milliseconds in-between) resulting in stale data; as
19+well as updating too often (when multiple queries against the table
20+start at around the same time).
21+
22+Fixed by updating the "last updated" timestamp in the right place, when
23+the cache is updated, not when it is read.
24+
25+I hereby grant Percona the following BSD license to this patch for
26+inclusion in Percona Server:
27+
28+Copyright (c) 2010, Kristian Nielsen All rights reserved.
29+
30+Redistribution and use in source and binary forms, with or without
31+modification, are permitted provided that the following conditions are
32+met:
33+
34+ * Redistributions of source code must retain the above copyright
35+ notice, this list of conditions and the following disclaimer.
36+ * Redistributions in binary form must reproduce the above copyright
37+ notice, this list of conditions and the following disclaimer in
38+ the documentation and/or other materials provided with the
39+ distribution.
40+ * Neither the name of the author nor the names of its contributors
41+ may be used to endorse or promote products derived from this
42+ software without specific prior written permission.
43+
44+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
45+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
46+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
47+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
48+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
49+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
50+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
51+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
52+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
53+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
54+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55+
56+--- a/storage/innodb_plugin/trx/trx0i_s.c 2010-11-03 16:39:54.000000000 +0300
57++++ b/storage/innodb_plugin/trx/trx0i_s.c 2010-11-30 13:57:03.000000000 +0300
58+@@ -157,10 +157,6 @@
59+ ullint last_read; /*!< last time the cache was read;
60+ measured in microseconds since
61+ epoch */
62+- mutex_t last_read_mutex;/*!< mutex protecting the
63+- last_read member - it is updated
64+- inside a shared lock of the
65+- rw_lock member */
66+ i_s_table_cache_t innodb_trx; /*!< innodb_trx table */
67+ i_s_table_cache_t innodb_locks; /*!< innodb_locks table */
68+ i_s_table_cache_t innodb_lock_waits;/*!< innodb_lock_waits table */
69+@@ -1101,13 +1097,6 @@
70+ {
71+ ullint now;
72+
73+- /* Here we read cache->last_read without acquiring its mutex
74+- because last_read is only updated when a shared rw lock on the
75+- whole cache is being held (see trx_i_s_cache_end_read()) and
76+- we are currently holding an exclusive rw lock on the cache.
77+- So it is not possible for last_read to be updated while we are
78+- reading it. */
79+-
80+ #ifdef UNIV_SYNC_DEBUG
81+ ut_a(rw_lock_own(&cache->rw_lock, RW_LOCK_EX));
82+ #endif
83+@@ -1205,6 +1194,12 @@
84+ /*===================================*/
85+ trx_i_s_cache_t* cache) /*!< in/out: cache */
86+ {
87++ ullint now;
88++
89++#ifdef UNIV_SYNC_DEBUG
90++ ut_a(rw_lock_own(&cache->rw_lock, RW_LOCK_EX));
91++#endif
92++
93+ if (!can_cache_be_updated(cache)) {
94+
95+ return(1);
96+@@ -1217,6 +1212,10 @@
97+
98+ mutex_exit(&kernel_mutex);
99+
100++ /* update cache last read time */
101++ now = ut_time_us(NULL);
102++ cache->last_read = now;
103++
104+ return(0);
105+ }
106+
107+@@ -1247,16 +1246,12 @@
108+ release kernel_mutex
109+ release trx_i_s_cache_t::rw_lock
110+ acquire trx_i_s_cache_t::rw_lock, S
111+- acquire trx_i_s_cache_t::last_read_mutex
112+- release trx_i_s_cache_t::last_read_mutex
113+ release trx_i_s_cache_t::rw_lock */
114+
115+ rw_lock_create(&cache->rw_lock, SYNC_TRX_I_S_RWLOCK);
116+
117+ cache->last_read = 0;
118+
119+- mutex_create(&cache->last_read_mutex, SYNC_TRX_I_S_LAST_READ);
120+-
121+ table_cache_init(&cache->innodb_trx, sizeof(i_s_trx_row_t));
122+ table_cache_init(&cache->innodb_locks, sizeof(i_s_locks_row_t));
123+ table_cache_init(&cache->innodb_lock_waits,
124+@@ -1307,18 +1302,10 @@
125+ /*===================*/
126+ trx_i_s_cache_t* cache) /*!< in: cache */
127+ {
128+- ullint now;
129+-
130+ #ifdef UNIV_SYNC_DEBUG
131+ ut_a(rw_lock_own(&cache->rw_lock, RW_LOCK_SHARED));
132+ #endif
133+
134+- /* update cache last read time */
135+- now = ut_time_us(NULL);
136+- mutex_enter(&cache->last_read_mutex);
137+- cache->last_read = now;
138+- mutex_exit(&cache->last_read_mutex);
139+-
140+ rw_lock_s_unlock(&cache->rw_lock);
141+ }
142+
143
144=== modified file 'series'
145--- series 2010-11-17 15:52:39 +0000
146+++ series 2010-11-30 16:59:10 +0000
147@@ -50,3 +50,4 @@
148 sql_no_fcache.patch
149 show_slave_status_nolock.patch
150 innodb_fast_shutdown.patch
151+bug677407.patch

Subscribers

People subscribed via source and target branches

to all changes: