Merge lp:~laurynas-biveinis/percona-server/bug1295523 into lp:percona-server/5.6

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 566
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1295523
Merge into: lp:percona-server/5.6
Diff against target: 75 lines (+21/-2)
2 files modified
storage/innobase/include/sync0sync.h (+1/-0)
storage/innobase/sync/sync0sync.cc (+20/-2)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1295523
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+212158@code.launchpad.net

This proposal supersedes a proposal from 2014-03-21.

Description of the change

2nd MP:

Introduce a separate priority mutex list, free both lists in sync_close.
http://jenkins.percona.com/job/percona-server-5.6-param/560/

1st MP:

Fix bug 1295523 (sync_close destroys priority mutexes as regular
ones).

First, assert that sync_close never sees any priority mutexes. For
that introduce debug-only priority mutex counter
sync_priority_mutex_count, maintain it in mutex_create_func and
mutex_free_func.

Then, introduce new function buf_pool_free_prio_mutexes, called on
server shutdown just before sync_close, that frees the priority
mutexes. The option of releasing the mutexes in buf_free does not
work, because its call cannot go before sync_close.

http://jenkins.percona.com/job/percona-server-5.6-param/559/

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal

One has to maintain a list of exceptions from sync_close() in buf_pool_free_prio_mutexes() whenever a new prio mutex is added to buf_pool_t. The new assertion helps, but is still ugly. Introducing a prio mutex outside of buf_pool_t will require even less trivial changes.

How about making it transparent to callers? E.g. introduce prio_mutex_list where prio mutexes will be added in addition to mutex_list. In sync_close() walk prio_mutex_list first and use the correct mutex_free_func() overload. In the overload, remove it from prio_mutex_list before calling mutex_free_func() for non-prio mutexes.

review: Needs Fixing
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : Posted in a previous version of this proposal

Good idea. Priority mutex struct will have to get the list node fields, but that should be fine, there are few of those mutexes.

Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storage/innobase/include/sync0sync.h'
2--- storage/innobase/include/sync0sync.h 2014-01-27 10:35:37 +0000
3+++ storage/innobase/include/sync0sync.h 2014-03-21 13:23:05 +0000
4@@ -984,6 +984,7 @@
5 priority in the global wait array
6 waiting for this mutex to be
7 released. */
8+ UT_LIST_NODE_T(ib_prio_mutex_t) list;
9 };
10
11 /** Constant determining how long spin wait is continued before suspending
12
13=== modified file 'storage/innobase/sync/sync0sync.cc'
14--- storage/innobase/sync/sync0sync.cc 2014-02-17 11:12:40 +0000
15+++ storage/innobase/sync/sync0sync.cc 2014-03-21 13:23:05 +0000
16@@ -209,7 +209,10 @@
17 /** Global list of database mutexes (not OS mutexes) created. */
18 UNIV_INTERN ut_list_base_node_t mutex_list;
19
20-/** Mutex protecting the mutex_list variable */
21+/** Global list of priority mutexes. A subset of mutex_list */
22+UNIV_INTERN UT_LIST_BASE_NODE_T(ib_prio_mutex_t) prio_mutex_list;
23+
24+/** Mutex protecting the mutex_list and prio_mutex_list variables */
25 UNIV_INTERN ib_mutex_t mutex_list_mutex;
26
27 #ifdef UNIV_PFS_MUTEX
28@@ -353,6 +356,10 @@
29 cmutex_name);
30 mutex->high_priority_waiters = 0;
31 mutex->high_priority_event = os_event_create();
32+
33+ mutex_enter(&mutex_list_mutex);
34+ UT_LIST_ADD_FIRST(list, prio_mutex_list, mutex);
35+ mutex_exit(&mutex_list_mutex);
36 }
37
38 /******************************************************************//**
39@@ -426,6 +433,10 @@
40 /*============*/
41 ib_prio_mutex_t* mutex) /*!< in: mutex */
42 {
43+ mutex_enter(&mutex_list_mutex);
44+ UT_LIST_REMOVE(list, prio_mutex_list, mutex);
45+ mutex_exit(&mutex_list_mutex);
46+
47 ut_a(mutex->high_priority_waiters == 0);
48 os_event_free(mutex->high_priority_event);
49 mutex_free_func(&mutex->base_mutex);
50@@ -1572,6 +1583,7 @@
51 /* Init the mutex list and create the mutex to protect it. */
52
53 UT_LIST_INIT(mutex_list);
54+ UT_LIST_INIT(prio_mutex_list);
55 mutex_create(mutex_list_mutex_key, &mutex_list_mutex,
56 SYNC_NO_ORDER_CHECK);
57 #ifdef UNIV_SYNC_DEBUG
58@@ -1630,10 +1642,16 @@
59 sync_close(void)
60 /*===========*/
61 {
62- ib_mutex_t* mutex;
63+ ib_mutex_t* mutex;
64+ ib_prio_mutex_t* prio_mutex;
65
66 sync_array_close();
67
68+ for (prio_mutex = UT_LIST_GET_FIRST(prio_mutex_list); prio_mutex;) {
69+ mutex_free(prio_mutex);
70+ prio_mutex = UT_LIST_GET_FIRST(prio_mutex_list);
71+ }
72+
73 for (mutex = UT_LIST_GET_FIRST(mutex_list);
74 mutex != NULL;
75 /* No op */) {

Subscribers

People subscribed via source and target branches