Repository navigation
MOD-18289 Reserve file descriptors for the disk open-files cap - #11551
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Line 705 in 055eb6f
IndexDiskAPI.updateMaxOpenFiles now explicitly reports false on failure, but this loop discards that result and unconditionally returns success. If SpeedB rejects a runtime cap update for one index, CONFIG SET updates the stored value while that database retains its old cap; when lowering, the process-wide reservation has already been reduced, so the unchanged database can consume descriptors that are no longer reserved and cause file-open failures elsewhere. Check every result and either roll back the reservation/already-updated databases or make the operation transactional in the disk layer.
Lines 701 to 705 in 055eb6f
This iteration only visits indexes still present in specDict_g, but Indexes_RemoveSpecFromGlobals removes an index from that dictionary before IndexSpec_FreeUnlinkedData eventually calls SearchDisk_CloseIndex, and outstanding strong references can delay that close on the cleanup thread. If the cap is lowered while such a dropped index is still draining, its open database retains the old higher cap even though the process-wide reservation has already been reduced, allowing actual descriptor use to exceed the reservation. Track and update every still-open disk handle, including unlinked specs awaiting destruction, before committing the lower reservation.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #11551 +/- ##
==========================================
- Coverage 84.26% 83.51% -0.76%
==========================================
Files 640 665 +25
Lines 85418 86519 +1101
Branches 39255 40347 +1092
==========================================
+ Hits 71981 72255 +274
- Misses 13071 13890 +819
- Partials 366 374 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
055eb6f to
b6169f5
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6169f5690
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
b6169f5 to
5868d92
Compare
87f9814 to
153f301
Compare
search-disk-max-open-files now doubles as the unit the process-wide file-descriptor reservation is granted in: every live disk index costs exactly the cap in reserved descriptors. Raising the cap (at CONFIG SET time or via the disk backend's cap-reapply path) can therefore be refused if the process can't reserve enough headroom, in which case the change is rejected and no database is touched. Lowering always succeeds. Creating a new disk index can likewise be refused if there isn't enough headroom for its share of the cap; surface that as an ordinary index-creation error instead of an assertion, since it's an expected operating condition rather than a bug. Also tightens DISK_MAX_OPEN_FILES_MIN to 20 and lowers the default cap to 200, matching SpeedB's actual table-cache floor (SanitizeOptions clips below 20 anyway) instead of the previous headroom-for-non-data- files estimate. Updates the pre-existing default-value assertion in test_config.py to match. The reservation is granted through RedisModule_SetOpenFilesReservation, which redisearch_disk needs from a newer redismodule-rs commit than RediSearch currently pins; bump the shared redis-module rev so the combined dependency graph resolves to a single version (two revs in the same build previously produced extern "C" signature mismatches). RediSearch's own RedisModule_Init also needs to fetch the new API pointer from the server's GET_API table itself, since the vendored crate declaring it doesn't make the server populate it. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
153f301 to
af38471
Compare
|



search-disk-max-open-filesnow doubles as the unit of a process-wide file-descriptor reservation: every live disk index costs exactly the cap value in reserved descriptors, requested via the newRedisModule_SetOpenFilesReservationAPI.SearchDisk_CanCreateIndexcharges that reservation before a new disk index is opened, and is called fromIndexSpec_ParseFromArgCursorahead ofSearchDisk_OpenIndex; if the process can't reserve enough descriptors, creation is refused with an ordinary index-creation error rather than an assertion, since running out of reservation headroom is an expected operating condition, not a bug.Adds
SearchDisk_ReleaseCreateFailure, called fromspec.cto undo that charge when a create attemptCanCreateIndexadmitted subsequently fails to open for an unrelated reason, so the charge doesn't outlive the index it was reserved for.Adds the
RedisModule_SetOpenFilesReservationdeclaration and itsREDISMODULE_GET_APIentry, following the same pattern as the module's other Big-module API pointers. The server-side API itself landed in redislabsdev/Redis#1849, and the Rust-visible declaration in RedisLabsModules/redismodule-rs#486 (both merged). TheREDISMODULE_GET_APIentry is load-bearing rather than cosmetic: the module links one global per API pointer, shared by its C and Rust halves, and only this header'sRedisModule_Initpopulates it — omit the entry and the pointer stays NULL and the Rust disk layer panics on first use.Lowers the default cap from 1024 to 200: at 1024, 4000 indexes would need ~4.1M reserved descriptors, well past the ~1M per-process ceiling (
fs.nr_open); the setting is immutable, so a deployment needing more per-index headroom must set it at module load time rather than raising it later.Also updates
module.conf's documented default to match (200), and rewraps/trims the comments this commit touches.codecov/patchfails on this PR because the behavioral coverage for this C plumbing (admission, refusal, and release-after-drop) lives in Enterprise PR redislabsdev/RediSearchEnterprise#1040, not because the change itself is untested.Release Notes
🤖 Generated with Claude Code