fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

merging: count compound shards in loop (#235)

incrementing and decrementing the counter turned out to be too brittle,
especially because we want to be able delete shards on disk manually if
necessary. It make most sense to just count them in the main loop that is running
to fetch new repo options from frontend.

author
Stefan Hengl
committer
GitHub
date (Dec 22, 2021, 12:11 PM +0100) commit 4a99786b parent 8a0872da
+5 -5
-1
cmd/zoekt-sourcegraph-indexserver/cleanup.go
··· 320 320 s.muIndexDir.Lock() 321 321 for _, p := range paths { 322 322 os.Remove(p) 323 - metricNumberCompoundShards.Dec() 324 323 } 325 324 s.muIndexDir.Unlock() 326 325 shardsLog(s.IndexDir, "delete", []shard{{Path: path}})
+5 -3
cmd/zoekt-sourcegraph-indexserver/main.go
··· 301 301 missing := s.queue.Bump(repos.IDs) 302 302 s.Sourcegraph.ForceIterateIndexOptions(s.queue.AddOrUpdate, missing...) 303 303 304 + setCompoundShardCounter(s.IndexDir) 305 + 304 306 <-cleanupDone 305 307 } 306 308 }() ··· 673 675 return i 674 676 } 675 677 676 - func initializeCompoundShardCounter(indexDir string) { 678 + func setCompoundShardCounter(indexDir string) { 677 679 fns, err := filepath.Glob(filepath.Join(indexDir, "compound-*.zoekt")) 678 680 if err != nil { 679 - log.Printf("initializeCompoundShardCounter: %s\n", err) 681 + log.Printf("setCompoundShardCounter: %s\n", err) 680 682 return 681 683 } 682 684 metricNumberCompoundShards.Set(float64(len(fns))) ··· 844 846 } 845 847 846 848 initializeGoogleCloudProfiler() 847 - initializeCompoundShardCounter(s.IndexDir) 849 + setCompoundShardCounter(s.IndexDir) 848 850 849 851 if *listen != "" { 850 852 go func() {
-1
cmd/zoekt-sourcegraph-indexserver/merge.go
··· 70 70 debug.Printf("error during merging compound %d, stdErr: %s, err: %s\n", ix, stdErr, err) 71 71 continue 72 72 } 73 - metricNumberCompoundShards.Inc() 74 73 // for len(comp.shards)<=1, callMerge is a NOP. Hence there is no need to log 75 74 // anything here. 76 75 if len(comp.shards) > 1 {