Bobcares

How to resolve “InnoDB: Unable to lock ./ibdata1, error: 11”

by | Oct 31, 2018

ERROR (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

 

This is a commonly seen error in database driven sites. The same error can show up when a connection or restart for MySQL server is attempted via commandline.

A quick check of the log files may reveal that the actual error faced by MySQL server is “InnoDB: Unable to lock ./ibdata1, error: 11”.

In our role as Outsourced Tech Support for web hosting providers, database errors are one major category of issues we resolve for the customers.

What causes “InnoDB: Unable to lock ./ibdata1, error: 11”

We’ve come across various reasons why the error “InnoDB: Unable to lock ./ibdata1, error: 11” shows up in MySQL error logs.

1. Duplicate process

Most often, an improper MySQL service restart is the main culprit. If a previously running process was not properly shut down and a process restart is attempted, you get this error.

A running MySQL process locks the MySQL socket and data files, and the error logs show the message:

InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process

2. Corrupt data file

ibdata1 file in the MySQL data directory contains the shared tablespace that stores InnoDB’s internal data. The data stored in this file includes:

a. data dictionary (metadata of tables)
b. change buffer
c. doublewrite buffer
d. undo logs

In very busy database servers, over time the ibdata1 grows into huge size. This can lead to service crash or data corruption, causing MySQL errors.

InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
InnoDB: Operating system error number 11 in a file operation.

3. Lack of disk space

MySQL uses tmp directories to store intermittent data while processing queries. When this tmp folder or disk space gets full, or inode usage exceeds limit, MySQL throws errors.

4. File system errors

File system errors such as I/O errors or read-only file system, can cause errors to pop up in various services, including MySQL.

5. Permission and ownership

The MySQL data directory and socket file require specific permission and ownership, for the service to work fine. If there is any mismatch in these parameters, MySQL would be unable to access the data files.

6. AppArmor configuration

AppArmor is a security module to bring restrictions on services by configuring custom profiles. Any corruption or misconfiguration in these profiles or module can lead to InnoDB error 11.

7. Slow queries

Database driven website software usually involves a lot of MySQL queries. Many of these queries can be complex or slow, clogging the resources allocated to MySQL server.

Such resource locks can lead to incomplete MySQL server restarts and inability to allocate resources for the other queries or processes.

InnoDB: Unable to open the first data file
InnoDB: Error in opening ./ibdata1
InnoDB: Operating system error number 11 in a file operation.
InnoDB: Error number 11 means 'Resource temporarily unavailable'.

How to fix “InnoDB: Unable to lock ./ibdata1, error: 11”

When we notice a MySQL error in a website or server, the first thing we do is to examine the error logs. The ‘Error’ entries in the log during that time period is checked.

The lines that follow the Error “InnoDB: Unable to lock ./ibdata1, error: 11” gives us hints about the issue. We then debug the issue in these ways.

1. Remove hung processes

When the error is obtained during MySQL service restart, we first check if there is an already running process. At times there may be some scripts which keep on restarting MySQL.

An unexpected server restart can also cause hung or stuck process in the server. The stuck process is identified and killed. Then the MySQL server is restarted and confirmed to be running fine.

2. Restore data directory

In cases where the data directory or ibdata1 file is corrupt, we recreate and restore them. The permissions and ownership of these files and folders are updated to the desired parameters.

3. Filesystem checks

The server logs are investigated and filesystem checks are performed to identify errors related to bad sectors or disk space issues.

With our periodic server audits, we proactively detect such file system issues in the servers we manage. This enables us to take prompt actions to prevent a server downtime.

4. Fix AppArmor configuration

In cases where the issue is caused due to AppArmor profiles being corrupt, we recreate the profiles and fix the related configuration issues.

5. Debug slow queries

To detect the queries that are taking up the MySQL resources, we configure slow query logs in the servers we manage. These logs are examined during our periodic audits.

From these logs, it is easy to pinpoint the queries that are clogging the resources. Fixing these slow query logs helps to avoid overheads and related errors in MySQL service.

Conclusion

Database errors occurs due to a number of reasons. And they end up crippling your servers. Today, we’ve seen the possible causes for ‘InnoDB: Unable to lock ./ibdata1, error: 11’ and how our Support Engineers fix them.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

SEE SERVER ADMIN PLANS

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF