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.4from
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 5 files with indirect coverage changes
@@ Coverage Diff @@
## development/9.4 #2729 +/- ##
===================================================
+ Coverage 74.50% 74.74% +0.24%
===================================================
Files 200 200
Lines 13610 13623 +13
===================================================
+ Hits 10140 10183 +43
+ Misses 3460 3430 -30
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 |
8f0cf5a to
e3b661b
Compare
|
LGTM |
Jira issue not foundThe Jira issue BB-753 was not found. |
e3b661b to
a4deb09
Compare
|
LGTM |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
|
|
should scality/Arsenal#2605 be bumped here first? |
SylvainSenechal
left a comment
There was a problem hiding this comment.
Did this error ever happened in production ? What's the context that lead to this work, I don't see the linked ticket in the pr
I'm a bit surprised as you say :
"The 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 — so 2 * id is a conservative estimate for both indexes combined."
It means a bucket with 100 million objects would only take ~7gb, which is.. fine ? Or maybe I misunderstood something and we are talking about ram instead of disk storage. Maybe the bigger problem is not the storage, but simply adding index on millions of objects is hammering the db for tens of minutes which also affects other apis calls
a4deb09 to
6b69c2c
Compare
|
6b69c2c to
da882c7
Compare
|
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
da882c7 to
d6e8a29
Compare
|
LGTM |
The use case is for when your disk is (almost) full and you want to create a workflow to empty the bucket, but you can't because there isn't enough space to create the workflow index. |
Summary
fsFreeSize < 3 * _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 — worse — crashes the MongoDB shard. We confirmed this on a test cluster: attempting index creation with 50MB free on a 10GB PV caused "Connection closed by peer" and the shard went into a crash loop (560+ restarts). Removing the filler files was required to recover.
This change adds a proactive disk space check using two MongoDB metadata calls run sequentially (~11ms total, no locks):
getDiskUsage()(dbStats) — filesystem free spacegetCollectionStats()(collStats) — per-collection index sizesWhy
3 * _id_index size?After running
compacton a test collection with 1.37M objects, all three indexes (_id_, both lifecycle) are the same size (~60MB each). However, the_id_index is typically bloated from incremental inserts (101MB before compact vs 58MB after). Since each lifecycle index is freshly built at its compact size,3 * _id_provides a safe margin:_id_is bloated (101MB): threshold = 303MB, actual cost ~120MB — conservative, safe_id_is compact (58MB): threshold = 174MB, actual cost ~120MB — still safeDesign decisions
async.series) to avoid creating extra MongoDB connections/sessions. Latency is not critical here._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.getDiskUsageand newgetCollectionStatsmethods.