Skip to content

Commit 8b2f29c

Browse files
authored
fix datarace on issue indexer queue (#9490)
1 parent f88715e commit 8b2f29c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

modules/indexer/code/indexer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func Init() {
3838
return
3939
}
4040

41+
initQueue(setting.Indexer.UpdateQueueLength)
42+
4143
ctx, cancel := context.WithCancel(context.Background())
4244

4345
graceful.GetManager().RunAtTerminate(ctx, func() {

modules/indexer/code/queue.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ type repoIndexerOperation struct {
2121

2222
var repoIndexerOperationQueue chan repoIndexerOperation
2323

24+
func initQueue(queueLength int) {
25+
repoIndexerOperationQueue = make(chan repoIndexerOperation, queueLength)
26+
}
27+
2428
func processRepoIndexerOperationQueue(indexer Indexer) {
25-
repoIndexerOperationQueue = make(chan repoIndexerOperation, setting.Indexer.UpdateQueueLength)
2629
for {
2730
select {
2831
case op := <-repoIndexerOperationQueue:

0 commit comments

Comments
 (0)