Skip to main contentমূল বিষয়বস্তুতে যান

Case study Server WooCommerce

MariaDB stuck after an out-of-memory crash: recovering a WooCommerce store on a cPanel VPS without losing data

Client
Independent online retailer (anonymised)
Service
Diagnosis, data preservation, recovery and stabilisation
Stack
WooCommerce · MariaDB 10.6 · cPanel & WHM · AlmaLinux VPS
Timeline
Site restored and stabilised within three working days

The short answer

MariaDB was not corrupted. After an out-of-memory event, it restarted while the server was still short of memory, stalled part-way through crash recovery, and kept holding the lock on its data files, so every new start failed with "Unable to lock ./ibdata1, error: 11". We preserved the complete data directory first and proved the copy was consistent, then recovered the database without losing any data. The underlying cause was PHP running in CGI mode with no process limit and no swap space, which we fixed so it could not happen again.

MD Mahe Alam Leon, Founder & Lead Engineer, Hostaccent

Work led and reviewed by MD Mahe Alam LeonFounder & Lead Engineer, Hostaccent · 15 years of hands-on server and hosting work · Reviewed

About Hostaccent

0

data lost

Every order, product and customer record from the agreed restore point was present and verified table by table.

≈900

files proven unchanged during the copy

Checksums of the whole data directory matched before and after the copy, so the preserved image was consistent.

46 s → 3 s

home page load time

Measured during the memory shortage and again after moving PHP from CGI to PHP-FPM.

100%

of the second database untouched

Every table matched its recorded row count and checksum after recovery.

The problem

An online store running WordPress and WooCommerce on a self-managed cPanel VPS went down when its database stopped responding. A MariaDB process was still running but answered nothing, and every attempt to start the service failed with "InnoDB: Unable to lock ./ibdata1, error: 11". A normal stop signal had no effect.

The server held two databases: the live store, and an older database the owner wanted left exactly as it was. The owner had a database backup from a few days before the outage and was willing to return to it, but only once there was a proven way back if anything went wrong. Forcing the process to stop, or deleting InnoDB files, are common suggestions online, and both can turn a recoverable situation into permanent data loss.

How we investigated

We started with restricted, read-only SSH access, with every additional permission scoped to specific commands, reviewed and approved by the owner in writing before it was used.

  1. Find out what the stuck process was actually doing

    Killing a process that is waiting on disk can make things worse, so we first checked its state, its kernel stack, its CPU time and its disk write counters.

    Finding: The process was idle and waiting internally, not on disk. It had used 20 seconds of CPU in about two days and was holding the InnoDB lock, so a forced stop would be expected to succeed without a reboot.

  2. Read the database's own error log

    The error log is the only record of what happened at the moment of failure, and it is the step most often skipped.

    Finding: After the out-of-memory kill, MariaDB had restarted while memory was still exhausted ("Out of memory" at startup), began crash recovery and never finished. Every later start failed because the stalled process still held the lock.

  3. Preserve everything before changing anything

    We streamed a copy of the complete data directory, both databases and all shared InnoDB files, to encrypted storage, writing nothing to the server, and recorded a checksum of every file before and after the copy.

    Finding: All checksums were identical before and after, and the process wrote nothing during the copy, which proves the copy was a consistent point-in-time image rather than a torn one.

  4. Rehearse the recovery on the copy

    We started the copy in an isolated MariaDB of the exact same version, let crash recovery run, checked every table and exported both databases separately.

    Finding: Crash recovery completed cleanly and every table passed. The export of the second database was restored into a scratch database and matched row for row, so either database could now be restored on its own.

  5. Prove the backup restores before relying on it

    A backup file that looks complete is not proof that it will import. We test-imported the owner's backup into the same MariaDB version, and scanned it for statements that could touch any other database.

    Finding: It imported without errors, every table passed its integrity check, and it contained nothing that referenced the second database.

Root cause

  1. 1Unlimited PHP CGI processes
  2. 2Server out of memory, no swap
  3. 3MariaDB crash recoveryStalled, still holding the lock
  4. 4WordPress and WooCommerceNo database to connect to
With the database stalled, every page failed to load the store.

The database was a victim, not the cause. With PHP running in CGI mode, every visitor request started a new PHP process that loaded WordPress, WooCommerce and the theme from scratch, with no code caching and no limit on how many could run at once. A burst of traffic, together with days of postponed scheduled tasks, started dozens of these processes. With no swap space, the server ran out of memory, the kernel killed MariaDB, and MariaDB restarted into the same memory shortage and stalled.

The MariaDB error log recorded "Out of memory" at startup followed by a crash recovery that never completed, and the very same data directory recovered cleanly in an isolated environment, ruling out corruption.

The evidence

What we measuredResult
State of the stuck MariaDB processIdle and waiting internally, not on disk: safe to stop
Data directory checksums before and after the copyIdentical for all ≈900 files, with no disk writes in between
Crash recovery on the preserved copyCompleted cleanly; every table passed its integrity check
Test import of the owner's backupNo errors; nothing referencing the second database
Second database after production recoveryEvery table's row count and checksum unchanged
Server during the follow-up memory shortageLoad average ≈146, ≈65 MB of memory free, 87 PHP processes
Home page load timeUp to 46 s during the shortage, about 3 s after the fix

What we recommended

Each change was small, reversible and measured before and after.

  1. Stop the stalled process only after preservation

    Once a verified copy existed, the stuck process was stopped. It exited within two seconds and MariaDB's own crash recovery completed exactly as it had in the rehearsal. No reboot and no InnoDB force-recovery mode were needed.

  2. Restore only what needed restoring

    The live store's database was returned to the owner's restore point. The second database was verified read-only and never written to, as the owner had required.

  3. Move PHP from CGI to PHP-FPM with a worker limit

    PHP-FPM caches compiled code and caps the number of PHP workers, so a traffic burst can no longer exhaust the server's memory.

  4. Add swap space

    A swap file gives the server a safety margin, so a short memory spike slows it down instead of the kernel killing the database.

  5. Run WordPress scheduled tasks from the server

    Scheduled tasks were moved from visitor requests to a single, locked server cron job, so they can no longer pile up and run all at once.

  6. Every change as a reviewable, reversible script

    Each change was delivered as a short script the owner reviewed and installed, with a matching rollback script, and each stage ran only after written approval.

Results

  • 0

    data lost. The store was restored to the agreed point, and the second database was proven unchanged, table by table.

  • 15×

    faster home page: from up to 46 seconds during the memory shortage to about 3 seconds on PHP-FPM.

  • 2 days

    before the disk would have filled up. Our follow-up check found the backup plugin keeping 15 full local copies of about 5.7 GB each, so the owner moved backups off the server before the next run.

  • 1

    old full-site backup file found downloadable by anyone on the internet, and moved out of the website directory the same day.

What happened next

Since the stabilisation, the server has run with its load below 1 and swap unused. When the owner later asked us to quote an upgrade to a newer MariaDB release, we explained that, with the database port closed to the internet and the business possibly being sold, the risk of waiting a few months was modest, and advised deferring rather than introducing another change. All copies of the client's data held by us were securely deleted once the work was confirmed.

MariaDB won't start after a crash? Check these six things first

  1. Don't delete ibdata1 or the redo logs

    "Unable to lock ./ibdata1, error: 11" means another MariaDB process still holds the lock. Deleting InnoDB files to get past it can destroy your data.

  2. Check for a leftover MariaDB process

    Look for a mariadbd or mysqld process that is still running after a failed stop. Note whether it is busy, idle, or stuck waiting on disk before deciding what to do with it.

  3. Read the MariaDB error log

    It records why the server stopped and how far crash recovery got. On cPanel servers, it is usually in the data directory.

  4. Look for out-of-memory events

    The kernel log shows whether the system killed MariaDB for memory. If it did, the database was the victim; the cause is whatever used the memory.

  5. Preserve before you restart

    Make a consistent copy of the whole data directory before forcing anything to stop, and prove it is consistent, for example with checksums taken before and after.

  6. Test your backup before you need it

    A backup that has never been imported is a hope, not a plan. Import it into the same database version somewhere safe first.

Frequently asked questions

What does "InnoDB: Unable to lock ./ibdata1, error: 11" mean?

A new MariaDB or MySQL process cannot get the lock on its system tablespace because another process already holds it, usually a previous server process that never finished stopping. It is not, by itself, a sign of corruption.

Is it safe to kill a stuck MariaDB process?

Sometimes, but not first. InnoDB is designed to recover from a sudden stop, yet if anything goes wrong you need a way back. Preserve a verified copy of the data directory first, check whether the process is waiting on disk, and only then stop it. In this case it exited within two seconds and recovered cleanly.

Why would MariaDB be killed for running out of memory when it uses little memory?

The Linux out-of-memory killer chooses a process to free memory, and a database is often chosen even when something else caused the shortage. Here, MariaDB used about 150 MB; the memory was consumed by dozens of PHP processes.

Can you copy a MariaDB data directory while the server is running?

Only if nothing writes to it during the copy, and you need proof of that. We compared checksums of every file before and after the copy and confirmed the process made no disk writes in between, then proved the copy by recovering it in an isolated environment.

Why does PHP in CGI mode cause memory problems on a VPS?

CGI starts a separate PHP process for every request, with no shared code cache and no limit on how many run together. A busy WordPress store can start dozens at once. PHP-FPM reuses a limited pool of workers, which uses memory predictably.

Can one database be restored without affecting another on the same server?

Yes, with care. We restored only the store's database from its backup and verified the second database read-only afterwards, comparing every table's row count and checksum with the values recorded beforehand.

How long does a recovery like this take?

The diagnosis and preservation took about a day, including written approval at each stage. The recovery itself, with the database restored and checked, took under an hour. The stabilisation changes followed over the next two days.

The client, business and website have been anonymised, and some figures rounded, to protect confidentiality. All findings come from the client's own server logs and databases, examined with the client's written authorisation. No client data is held by Hostaccent.

Database down and afraid to touch it?

We start read-only, preserve and verify your data before anything changes, and nothing happens without your written approval. Fixed-price diagnosis from US$49.