fix: pruning goroutine lifecycle management to prevent nil pointer on Close#2800
fix: pruning goroutine lifecycle management to prevent nil pointer on Close#2800blindchaser wants to merge 3 commits intomainfrom
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2800 +/- ##
===========================================
+ Coverage 48.37% 57.25% +8.87%
===========================================
Files 671 2099 +1428
Lines 50621 172437 +121816
===========================================
+ Hits 24486 98721 +74235
- Misses 23987 64865 +40878
- Partials 2148 8851 +6703
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| default: | ||
| } | ||
|
|
||
| pruneStartTime := time.Now() |
Check warning
Code scanning / CodeQL
Calling the system time Warning
| } | ||
| m.startOnce.Do(func() { | ||
| m.wg.Add(1) | ||
| go m.pruneLoop() |
Check notice
Code scanning / CodeQL
Spawning a Go routine Note
| time.Sleep(time.Duration(m.pruneInterval+randomDelay) * time.Second) | ||
| // Generate a random percentage (between 0% and 100%) of the fixed interval as a delay | ||
| randomPercentage := rand.Float64() | ||
| randomDelay := int64(float64(m.pruneInterval) * randomPercentage) |
Check notice
Code scanning / CodeQL
Floating point arithmetic Note
b1ef012 to
9dba675
Compare
… Close - Add proper Stop() with stopCh/WaitGroup to pruning Manager for graceful shutdown - Save pruning manager in CompositeStateStore and stop it on Close (idempotent) - Add defensive nil checks in pebbledb/rocksdb Prune() for closed databases - Remove duplicate stateStore.Close() in app HandleClose (already closed by BaseApp) Co-authored-by: Cursor <cursoragent@cursor.com>
9dba675 to
c4fa85d
Compare
Previously, pruneSnapshots() was only called after a successful snapshot rewrite. If snapshot creation kept failing, old snapshots would accumulate indefinitely. Now we prune old snapshots regardless of rewrite outcome. Co-authored-by: Cursor <cursoragent@cursor.com>
Describe your changes and provide context
Testing performed to validate your change