fix: backup memory usage#1582
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
Summary by CodeRabbit
WalkthroughAdds a new ChangesMultipart import parse memory
Security recommendation: keep Sequence Diagram(s)sequenceDiagram
participant Routes as backend/app/api/routes.go
participant V1Controller
participant HandleCollectionImport
participant ParseMultipartForm as r.ParseMultipartForm
Routes->>V1Controller: v1.WithMaxParseMemory(a.conf.Web.MaxParseMemory)
V1Controller->>V1Controller: store ctrl.maxParseMemory
HandleCollectionImport->>ParseMultipartForm: ParseMultipartForm(ctrl.maxParseMemory << 20)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
backend/internal/sys/config/conf.go (1)
100-102: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueFix the typos in the new field's doc comment.
Two small grammar slips: "the data that does not fit" should drop the leading "the", and "spil" should be "spill".
📝 Proposed wording
- // MaxParseMemory is the amount of memory used when parsing multipart form - // the data that does not fit into this memory will spil to temp files. - // Defaults to 64 MB. + // MaxParseMemory is the amount of memory (in MB) used when parsing a + // multipart form; data that does not fit into this memory will spill to + // temp files. Defaults to 64 MB.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/internal/sys/config/conf.go` around lines 100 - 102, The new MaxParseMemory doc comment in conf.go has two wording typos that should be corrected: remove the extra leading “the” from the phrase describing data that does not fit in memory, and change “spil” to “spill.” Update the comment attached to MaxParseMemory so the grammar is clean and consistent with the surrounding documentation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/app/api/handlers/v1/v1_ctrl_exports.go`:
- Around line 230-233: Update the multipart upload comment near
ParseMultipartForm in v1_ctrl_exports.go to reflect the actual behavior:
maxParseMemory is only the memory-vs-disk threshold for ParseMultipartForm,
while the total request size limit is enforced separately by the path-aware
middleware. Keep the note aligned with the multipart handling logic in the
export handler so the comment does not imply ParseMultipartForm is enforcing the
whole-body cap.
---
Nitpick comments:
In `@backend/internal/sys/config/conf.go`:
- Around line 100-102: The new MaxParseMemory doc comment in conf.go has two
wording typos that should be corrected: remove the extra leading “the” from the
phrase describing data that does not fit in memory, and change “spil” to
“spill.” Update the comment attached to MaxParseMemory so the grammar is clean
and consistent with the surrounding documentation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c2153155-eb89-41a0-890c-7961f6996aae
📒 Files selected for processing (4)
backend/app/api/handlers/v1/controller.gobackend/app/api/handlers/v1/v1_ctrl_exports.gobackend/app/api/routes.gobackend/internal/sys/config/conf.go
75a8d9e to
70dbfa0
Compare
What type of PR is this?
What this PR does / why we need it:
This PR creates a separate setting for memory to use when importing backups. Currently the upload limit is used for memory settings for
ParseMultipartForm, which is not ideal for running in constrained environments.Which issue(s) this PR fixes:
Fixes #1581
Testing
I have tested the change with the manually uploading my export of 1.2GB on a system that previously crashed with OOME.