MCPcopy Create free account
hub / github.com/ethstorage/es-node / launchFixLoop

Method launchFixLoop

ethstorage/scanner/scanner.go:222–256  ·  view source on GitHub ↗
(interval time.Duration)

Source from the content-addressed store, hash-verified

220}
221
222func (s *Scanner) launchFixLoop(interval time.Duration) {
223 s.wg.Add(1)
224 go func() {
225 defer s.wg.Done()
226
227 s.lg.Info("Launching scan fix loop", "interval", interval.String())
228
229 fixTicker := time.NewTicker(interval)
230 defer fixTicker.Stop()
231
232 for {
233 select {
234 case <-fixTicker.C:
235 // hold until other possible ongoing scans finish
236 if !s.acquireScanPermit() {
237 return
238 }
239 s.statsMu.Lock()
240 kvIndices := s.stats.needFix()
241 s.statsMu.Unlock()
242 s.lg.Info("Scanner fixing batch triggered", "mismatchesToFix", kvIndices)
243 err := s.worker.fixBatch(s.ctx, kvIndices, func(kvi uint64, m *scanned) {
244 s.updateStats(kvi, m)
245 })
246 s.releaseScanPermit()
247 if err != nil {
248 s.lg.Error("Fixing batch failed", "error", err)
249 }
250
251 case <-s.ctx.Done():
252 return
253 }
254 }
255 }()
256}
257
258func (s *Scanner) logStats() {
259 localKvCount, sum := s.worker.summaryLocalKvs()

Callers 1

startMethod · 0.95

Calls 8

acquireScanPermitMethod · 0.95
updateStatsMethod · 0.95
releaseScanPermitMethod · 0.95
needFixMethod · 0.80
fixBatchMethod · 0.80
StringMethod · 0.45
StopMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected