mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 06:56:36 +08:00
autoresearch iter 5: recover panics in background cleanup loops
Four long-running goroutines were launched with a bare go statement, so a
panic in any of them took down the whole process: the RAM cache's expired-key
eviction, the batch writer's flush worker, the disk cache cleanup worker and
the PoW memory store sweeper. Route them through util.Go.
The architecture gate only grepped for 'go func(', which is why the named-call
form went unnoticed; widen it to cover both launch styles.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package pow
|
||||
|
||||
import (
|
||||
"Wavelet/pkg/util"
|
||||
"context"
|
||||
"errors"
|
||||
"sync"
|
||||
@@ -43,7 +44,7 @@ func NewMemoryStore(cleanupInterval time.Duration) *MemoryStore {
|
||||
items: make(map[string]memoryItem),
|
||||
}
|
||||
if cleanupInterval > 0 {
|
||||
go store.startCleanupLoop(cleanupInterval)
|
||||
util.Go(func() { store.startCleanupLoop(cleanupInterval) })
|
||||
}
|
||||
return store
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
pkgcache "Wavelet/pkg/cache/disk"
|
||||
"Wavelet/pkg/util"
|
||||
)
|
||||
|
||||
// Status represents the runtime cache statistics.
|
||||
@@ -49,7 +50,7 @@ func GetGlobalCache() *DiskCache {
|
||||
// Load initial configs from database
|
||||
globalCache.ReloadConfig(context.Background())
|
||||
// Start background routine to clean expired items every 10 minutes
|
||||
go globalCache.StartCleanupWorker(defaultCleanupInterval * time.Minute)
|
||||
util.Go(func() { globalCache.StartCleanupWorker(defaultCleanupInterval * time.Minute) })
|
||||
})
|
||||
return globalCache
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user