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

Configure Feed

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

indexserver: only log if someone else is running (#395)

We inverted the condition around alreadyRunning. Luckily the only
side-effect was extra debug logs. I noticed this while testing with
debug logs on.

Test Plan: Run with debug logs and notice the already running messages
disappear. Add in a sleep for 2 minutes in indexing then check already
running messages pop up.

SRC_LOG_LEVEL=dbug go run ./cmd/zoekt-sourcegraph-indexserver \
-listen 127.0.0.1:6072 \
-index_concurrency 4 \
-sourcegraph_url ~/src \
-index /tmp/zoekt-test

plz-review-url: https://plz.review/review/6899

+8 -2
+6
cmd/zoekt-sourcegraph-indexserver/index_mutex.go
··· 25 25 running map[string]struct{} 26 26 } 27 27 28 + // With runs f if no other f with the same repoName is running. If f runs true 29 + // is returned, otherwise false is returned. 30 + // 31 + // With blocks if f runs or the Global lock is held. 28 32 func (m *indexMutex) With(repoName string, f func()) bool { 29 33 m.indexMu.RLock() 30 34 defer m.indexMu.RUnlock() ··· 58 62 return true 59 63 } 60 64 65 + // Global runs f once the global lock is held. IE no other Global or With f's 66 + // will be running. 61 67 func (m *indexMutex) Global(f func()) { 62 68 metricIndexMutexGlobal.Inc() 63 69 defer metricIndexMutexGlobal.Dec()
+2 -2
cmd/zoekt-sourcegraph-indexserver/main.go
··· 386 386 387 387 args := s.indexArgs(opts) 388 388 389 - alreadyRunning := s.muIndexDir.With(opts.Name, func() { 389 + ran := s.muIndexDir.With(opts.Name, func() { 390 390 // only record time taken once we hold the lock. This avoids us 391 391 // recording time taken while merging/cleanup runs. 392 392 start := time.Now() ··· 410 410 s.queue.SetIndexed(opts, state) 411 411 }) 412 412 413 - if alreadyRunning { 413 + if !ran { 414 414 // Someone else is processing the repository. We can just skip this job 415 415 // since the repository will be added back to the queue and we will 416 416 // converge to the correct behaviour.