🐛 bug: remove unbounded background goroutines from logger, cache, and internal storage memory#4378
🐛 bug: remove unbounded background goroutines from logger, cache, and internal storage memory#4378Copilot wants to merge 6 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4378 +/- ##
==========================================
+ Coverage 91.33% 91.37% +0.03%
==========================================
Files 132 132
Lines 13105 13112 +7
==========================================
+ Hits 11970 11981 +11
+ Misses 716 712 -4
Partials 419 419
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot Thanks, this does remove the goroutine leak, but please reconsider the mechanism per case instead of removing all three goroutines uniformly. Logger + cache timestamp: the original bug was N goroutines for N middleware instances. The cleanest fix is a single process-wide coarse clock: one background updater started once via internal/storage/memory GC: this case is different. That Storage already has a real lifecycle ( Summary: coarse-clock singleton (or lazy) for logger/cache, stoppable goroutine (buffered done + idempotent Close) for the memory storage GC. |
Addressed in b7a14fa (plus 8cef4d3 for the follow-up field alignment). Logger/cache stay on the lazy request-time path, |
Description
This change removes per-instance background goroutine patterns from logger and cache, while preserving the background GC in
internal/storage/memoryand making it cleanly stoppable through the storage’s existing lifecycle.Logger
${time}background updater with lazy timestamp refresh during request handling.TimeFormat, timezone, and update interval semantics without spawning a goroutine per middleware instance.Cache
Age/expiration calculations.Internal storage memory
internal/storage/memory.donechannel and an idempotentClose()so storage instances can stop their GC goroutine without blocking or double-close issues.Tests
internal/storage/memory.Close()calls do not block.Changes introduced
List the new features or adjustments introduced in this pull request. Provide details on benchmarks, documentation updates, changelog entries, and if applicable, the migration guide.
internal/storage/memoryGC shutdown safe with a buffered stop signal and idempotentClose().${time}and cache expiration logic now refresh from request-time reads, whileinternal/storage/memorycontinues to reclaim expired entries in the background and now stops cleanly viaClose().Type of change
Please delete options that are not relevant.
Checklist
Before you submit your pull request, please make sure you meet these requirements:
/docs/directory for Fiber's documentation.Commit formatting
Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md