clear cached elastic data when sync is done, bug fix

This commit is contained in:
Cyberes 2024-03-17 17:30:29 -06:00
parent 9a450571bd
commit 3f305b104b
1 changed files with 7 additions and 1 deletions

View File

@ -85,7 +85,7 @@ func syncElasticsearch(doFullSync bool) {
return
case <-ticker.C:
elapsed := time.Since(start)
logStr := "ELASTIC - Sync in progress. Elapsed: %d. Busy Elastic delete workers: %d. Elastic deletes queued: %d"
logStr := "ELASTIC - Sync in progress. Elapsed: %s. Busy Elastic delete workers: %d. Elastic deletes queued: %d"
log.Debugf(logStr, elapsed, globals.ElasticCrawlers.BusyWorkers, globals.ElasticCrawlers.Queue.GetQueueSize())
}
}
@ -116,6 +116,12 @@ func syncElasticsearch(doFullSync bool) {
globals.ElasticCrawlers.Queue.Terminate()
aliveWorkers.Wait()
globals.ElasticCrawlers = nil
globalPathsByKeyMutex.Lock()
globalKeysByPathMutex.Lock()
globalKeysByPath = nil
globalPathsByKey = nil
globalPathsByKeyMutex.Unlock()
globalKeysByPathMutex.Unlock()
duration := time.Since(start)
log.Infof("ELASTIC - %s sync finished in %s", syncType, duration)