Bug #56791 Remove ios_mutex from InnoDB code

Submitted: 15 Sep 2010 10:32 Modified: 9 Dec 2010 22:44
Reporter: Jimmy Yang Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.5 OS:Any
Assigned to: Jimmy Yang CPU Architecture:Any

[15 Sep 2010 10:32] Jimmy Yang
Description:
We have a ios_mutex to protect counter "ios" in io_handler_thread():

/** Count of I/O operations in io_handler_thread() */
static ulint            ios;

io_handler_thread()
{
        for (i = 0;; i++) {
                fil_aio_wait(segment);

                mutex_enter(&ios_mutex);
                ios++;
                mutex_exit(&ios_mutex);
        }

}

This mutex is not necessary. We can make the counter increment atomic, or even if it is not atomic, no need to dedicate a mutex for this counter.

How to repeat:
See the code
[15 Sep 2010 15:30] MySQL Verification Team
Thank you for the bug report.
[21 Sep 2010 16:58] Omer Barnir
triage: setting to SRMRTBD (code cleanup)
[21 Oct 2010 12:34] Marko Mäkelä
The variable "ios" that is protected by "ios_mutex" is completely unused. It a static variable in srv0start.c that is only initialized or incremented, never read or copied. We should remove it as well. Because there is some contention on the useless ios_mutex, I think that this bug should be fixed already in 5.5, if not 5.1.
[21 Oct 2010 12:38] Jimmy Yang
Updated a few counters in the similar situation:

1) Removed ios_mutex
2) Added generic counter operation to increment/decrement following counters atomically if HAVE_ATOMIC_BUILTINS is defined:
 a) ios
 b) dict_table_t::n_foreign_key_checks_running
 c) trx_sys->rseg_history_len

We will fall back to mutex protection for "n_foreign_key_checks_running" and "rseg_history_len" if  HAVE_ATOMIC_BUILTINS not defined.
[21 Oct 2010 12:44] Calvin Sun
Fine with the fix in 5.1.
[21 Oct 2010 12:59] Jimmy Yang
We will use this patch just to remove ios_mutex and ios which is a static counter not being used.
[22 Oct 2010 6:39] Jimmy Yang
Checked in mysql-5.5-innodb.
[13 Nov 2010 16:26] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:41] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:alexander.nozdrin@oracle.com-20101113152540-gxro4g0v29l27f5x) (pib:21)
[16 Dec 2010 22:34] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.043 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.