[MDEV-12674] Innodb_row_lock_current_waits has overflow Created: 2017-05-03 Updated: 2020-08-25 Resolved: 2017-05-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.0, 10.1, 10.1.20, 10.2 |
| Fix Version/s: | 10.1.24, 10.0.31, 10.2.7 |
| Type: | Bug | Priority: | Major |
| Reporter: | Chris Calender (Inactive) | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
Innodb_row_lock_current_waits appears to have an overflow.
I don't know how to reproduce it, but have access to the system showing this (and it is currently still in this state). |
| Comments |
| Comment by Marko Mäkelä [ 2017-05-11 ] | ||||||||||||||||||||||||||||||||||||||
|
The underlying counter is srv_stats.n_lock_wait_current_count, which is only modified by the function lock_wait_suspend_thread(). The incrementing is protected by lock_sys->wait_mutex, but the decrementing does not appear to be protected by anything. This mismatch could allow the counter to be corrupted when a lock wait is terminating roughly at the same time with the start of a wait on (possibly another) lock. | ||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-05-11 ] | ||||||||||||||||||||||||||||||||||||||
|
The inaccuracy seems to be by design:
That said, much of the time this template is instantiated with N=1, which appears to boil down to a single counter that is padded to two cache line sizes:
It seems reasonable to use atomics for the various _ctr_1_t counters when the performance impact is low. When atomic memory operations are not available, I think it would be more acceptable to have some overflows than to risk significantly reducing performance with some mutex operations. The only multi-slot counter types are ulint_ctr_64_t (used by a number of srv_stats counters) and int64_counter_t (used by rw_lock_stats). For the rw_lock_stats we should not care about accuracy. For srv_stats, the following counters are inaccurate by design. Based on the names of these counters, they are only ever incremented, never decremented, and it would seem to be acceptable to lose a few increments:
| ||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-05-11 ] | ||||||||||||||||||||||||||||||||||||||
|
Only the following counters are both incremented and decremented, and thus we probably should use atomic memory access for updating them:
| ||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-05-11 ] | ||||||||||||||||||||||||||||||||||||||
|
srv_stats.os_log_pending_writes should be fine, because it is protected by log_sys->mutex (10.0, 10.1) or log_sys->write_mutex (10.2). Similarly, fil_n_pending_log_flushes and fil_n_pending_tablespace_flushes are protected by fil_system->mutex. So, the only overflow-prone ‘pending’ counter is Innodb_row_lock_current_waits. | ||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-05-11 ] | ||||||||||||||||||||||||||||||||||||||
|
bb-10.0-marko | ||||||||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2017-05-12 ] | ||||||||||||||||||||||||||||||||||||||
|
ok to push. |