Skip lifecycle index creation when disk space is insufficient#2729
Skip lifecycle index creation when disk space is insufficient#2729delthas wants to merge 1 commit intodevelopment/9.3from
Conversation
Hello delthas,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 3 files with indirect coverage changes
@@ Coverage Diff @@
## development/9.3 #2729 +/- ##
===================================================
+ Coverage 74.51% 74.76% +0.25%
===================================================
Files 200 200
Lines 13610 13623 +13
===================================================
+ Hits 10141 10185 +44
+ Misses 3459 3428 -31
Partials 10 10
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
|
Review by Claude Code |
Before attempting to create lifecycle v2 indexes, check available disk space via dbStats and estimate the index creation cost from the collection's _id_ index size. If fsFreeSize < 2 * idIndexSize, skip index creation and fall back to v1 listing. This prevents the conductor from repeatedly attempting index creation on a full disk, and avoids further pressuring MongoDB storage when the volume is already constrained. Issue: BB-753
8f0cf5a to
e3b661b
Compare
|
LGTM |
| const idIndexSize = | ||
| (results.collStats.indexSizes && results.collStats.indexSizes._id_) || 0; |
There was a problem hiding this comment.
Confirmed in practice that the indexes created are about the same size as the default id index.
Summary
fsFreeSize < 2 * _id_ index size, skip index creation and fall back to v1 listing._indexesGetOrCreate).Context
When a large bucket fills the MongoDB PV, operators need lifecycle to empty it. The conductor tries to create v2 indexes for the bucket, which either fails (ENOSPC) or further pressures the disk. Currently the conductor retries index creation every cycle, failing each time and logging warnings.
This change adds a proactive disk space check using two MongoDB metadata calls (both ~10ms, no locks):
getDiskUsage()(dbStats) — filesystem free spacegetCollectionStats()(collStats) — per-collection index sizesThe
_id_index size is used as an estimate for the lifecycle index cost. On a test cluster with 1M objects:_id_= 76MB, each lifecycle index ≈ 60MB — so2 * _id_is a conservative estimate for both indexes combined.Design decisions
_indexesGetOrCreate, only for buckets that actually need index creation (indexes don't exist, auto-create enabled, not at concurrent limit). Most buckets already have indexes and return early.getDiskUsageandgetCollectionStatsrun in parallel viaasync.parallelto minimize latency.getDiskUsageand newgetCollectionStatsmethods.