IL-0439 Cybozu · 2018-06-28 (published)database
Database access slowed after each block device and filesystem expansion because the Linux kernel dropped the page cache
The page cache is the kernel feature that keeps copies of storage data in memory: the first read copies data from the device into the page cache, later reads are served from memory, and writes go to the page cache and are written back to the device later. Because memory is several orders of magnitude faster than SSDs or HDDs, once the page cache is lost, reads go to the much slower storage device again. The statistics from free and sar suggested that expanding the block device invalidated the page cache of the filesystem on it.
In the kernel source, check_disk_size_change(), called during a block device size change, logs "%s: detected capacity change from %lld to %lld\n" and calls flush_disk(bdev, false) whenever the old size bdev_size differs from the new size disk_size, which invalidates the page cache (and other caches such as those used for path resolution) of the filesystem on the device, on shrinking and on expanding alike. No kernel setting avoided this. Using git blame to find the commit that added the flush_disk() call, Cybozu learned its purpose: on shrinking, data being read or written in the removed area loses its destination and causes I/O errors, and expansion could cause the same problem in the special case of expanding right after shrinking. A full reading of the related source showed that the kernel's locking makes that case impossible, so invalidation on expansion was unnecessary.
Cybozu's patch to fs/block_dev.c calls flush_disk() only when bdev_size > disk_size, that is when the device shrinks, and otherwise only sets bdev->bd_invalidated = 1 when disk_part_scan_enabled(bdev->bd_disk) is true. The patched kernel was tested in the development environment and applied in production, which ended the problem inside Cybozu. The patch was also submitted upstream as "[RFC PATCH] fs: don't flush pagecahce when expanding block device", got no reply at first, and after several simplified resubmissions over a few months was taken into the next tree and finally into Linux v4.17.
- Severity
- –
- Scope
- Database access slowed down temporarily after each filesystem expansion, showing as slower application responses for customers
- Users affected
- –
- Region
- –
- Time to detect
- –
- Time to resolve
- –
Symptoms
For years, at Cybozu, database access slowed down for a while each time a filesystem was expanded. Customers saw it as slower responses from the application.
Part of Cybozu's data is stored in SQLite. When a database grows and the filesystem runs short of free space, operators first expand the block device the filesystem sits on and then expand the filesystem on that device. The slowdown came after the second step.
free and sar showed that the amount of page cache in the system dropped sharply after the block device was expanded. After the filesystem was expanded, storage device access rose in step with the drop in database performance, and fell again as performance recovered.
Symptom High latency
Root cause
Root cause Software defect
- Trigger
- Operators expanded a block device, a RAID1 multiple device made of two iSCSI devices backed by LVM volumes on remote servers, and then expanded the filesystem on it because the database had grown.
Detection
The slowdown appeared as worse response times of the application customers use.
Remediation
- Patched check_disk_size_change() so the kernel invalidates the page cache only when a block device shrinks
- Tested the patched kernel in the development environment and applied it in production
Action items
- Get the patch merged into the upstream Linux kernel so it need not be backported at each future OS upgrade
Lessons
When the intent of kernel code is unclear, the comments and the description of the commit that introduced it are the standard place to learn why it was written. The fix was 4 added lines and 2 removed lines, but reaching it took much investigation, so the effort of a source fix does not follow the number of lines changed.
Sources
Related cases
IL-0462Some MySQL pods on Shopify's GKE clusters took up to 30 minutes to start, slowing instance replacementShopify · 2021same root cause · shared Linux kernel, Database
IL-0451Setting indexes INVISIBLE on Aurora MySQL 3.10 spiked CPU and ReadIOPS on all three readers but not on the writerDaangn · 2026same root cause · shared Database
IL-0313Decagon voice requests stalled for exactly 300 seconds behind self-managed PgBouncer and exhausted the SQLAlchemy poolDecagon · 2026same root cause · shared Database
IL-0281PostHog's Logs ClickHouse cluster silently deleted almost all its S3 data, losing US logs older than 3 daysPostHog · 2026same root cause · shared Database
IL-0310An Aurora PostgreSQL failover to an upsized reader reversed twice and backend writes failed in read-only transactionsHightouch · 2025same root cause · shared Database
IL-0150A latent race condition in DynamoDB's DNS automation left an empty DNS record for dynamodb.us-east-1.amazonaws.com, and the DynamoDB and EC2 launch failures that followed caused EKS, ECS and Fargate container launch failures and cluster scaling delays in us-east-1Amazon Web Services · 2025same root cause · shared Database
IL-0436A supremum lock left by ROLLBACK TO SAVEPOINT in a long transaction blocked inserts and filled Aurora MySQL connectionsfreee · 2025same root cause · shared Database
IL-0247One in a million search requests took 100 times longer on Pinterest's Manas leaf nodes after moving to KubernetesPinterest · 2025same root cause · shared Linux kernel
IL-0527OpenStreetMap.org made no replication diffs for 16 hours as PostgreSQL logical decoding failed on a memory alloc errorOpenStreetMap Foundation · 2025same root cause · shared Database
IL-0329A routine migration left PGAudit stuck holding Postgres locks, causing intermittent timeouts and a 2-minute outageincident.io · 2025same root cause · shared Database
IL-0138A failed Nvidia driver build left broken kernel packages on the only Kubernetes master node, which hit a kernel panic on reboot after a power outage and took the homelab cluster down for six daysBarush Mendez · 2025same root cause · shared Linux kernel
IL-0347About 25% of Scaleway FR-PAR-1 hypervisors lost VPC connectivity when both VPC BGP route reflectors got stuckScaleway · 2024same root cause · shared Database
IL-0373Heroku Postgres Essential-tier databases in the EU region ran out of memory and refused connections, twice in four daysHeroku · 2024same root cause · shared Database
IL-0024Expensive cache-backed API calls and uncancelled database requests overloaded MongoDB and took the Hugging Face Hub down three timesHugging Face · 2024same root cause · shared Database
IL-0217Honeycomb's main MySQL database locked up under cache-miss reads and ran out of connections, a 68-minute total outageHoneycomb · 2023same root cause · shared Database
IL-0330Requests timed out for two weeks waiting on Go's database/sql connection pool, one for almost 20 secondsincident.io · 2023same root cause · shared Database
IL-0112The daily node rollover put DFDS's EKS nodes on an AMI later recalled for a kernel issue, causing "PLEG is not healthy" NodeNotReady flaps and pod network timeoutsDFDS · 2022same root cause · shared Linux kernel
IL-0385GitHub MySQL read replicas hit a semaphore deadlock during a schema migration's table rename and kept crash-recoveringGitHub · 2021same root cause · shared Database
IL-0029Slow user-facing services from CPU throttling on containers that used far less CPU than their limitBuffer · 2020same root cause · shared Linux kernel
IL-0196Adding a second Redis replica and lowering memory limits in one RedisFailover change restarted the only Redis pod that held data, and Sentinel promoted the empty new replica, erasing the dataPalark · 2020same root cause · shared Database
IL-0012CPU limits and an unpatched kernel CFS quota bug throttled multi-threaded services into stalls, failed health checks and timeoutsOmio · 2020same root cause · shared Linux kernel
IL-0486Figma's PostgreSQL 9 database on RDS slowed under high write IOPS and lock contention until the site was unavailableFigma · 2020same root cause · shared Database
IL-0143GKE nodes upgraded to certain 1.13 and 1.14 versions had an elevated number of kernel panics, fixed by releases that downgraded the Container-Optimized OS imageGoogle Cloud · 2019same root cause · shared Linux kernel
IL-0241A database shard could not elect a new primary, and the Stripe API failed most requests in two periods on one dayStripe · 2019same root cause · shared Database
IL-0277Patching Elastic Cloud's ZooKeeper ensemble in us-east-1 lost quorum, and hosted clusters and Kibana went unreachableElastic · 2019same root cause · shared Linux kernel
IL-0388A Google Cloud live migration took a Discord Redis primary offline, and the failover broke API instances and then guildsDiscord · 2017same root cause · shared Database
IL-0454Baemin billing servers could not open new MariaDB connections at the start of a card-discount eventWoowa Brothers · 2016same root cause · shared Database
IL-0536Amazon SimpleDB in US East returned HTTP 500 to nearly all API calls for two hours after its nodes left the clusterAmazon Web Services · 2014same root cause · shared Database
IL-0485Dropbox went down when an OS upgrade script reinstalled active MySQL master-replica pairs and backup restores ran slowDropbox · 2014same root cause · shared Database
IL-0589Every Kickstarter MySQL replica on Amazon RDS stopped replicating on a duplicate-key error in the backings tableKickstarter · 2013same root cause · shared Database
IL-0303GitHub's MySQL master failed over to a node with a cold buffer pool during a schema migration and GitHub.com went downGitHub · 2012same root cause · shared Database
Check your cluster for this
For AI tools and scripts
- This case as JSON: https://incidentlib-api.benchlet.com/cases/IL-0439
- The cases most like it: https://incidentlib-api.benchlet.com/cases/IL-0439/similar
- MCP server (Streamable HTTP, no key):
https://incidentlib-mcp.benchlet.com/mcp
The API needs no key. The MCP server offers search_incidents, get_incident, list_incidents, get_topic and vocab; both are explained on API and MCP.