Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix datarace on repo indexer queue #9490

Merged
merged 2 commits into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/indexer/code/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func Init() {
return
}

initQueue(setting.Indexer.UpdateQueueLength)

ctx, cancel := context.WithCancel(context.Background())

graceful.GetManager().RunAtTerminate(ctx, func() {
Expand Down
5 changes: 4 additions & 1 deletion modules/indexer/code/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ type repoIndexerOperation struct {

var repoIndexerOperationQueue chan repoIndexerOperation

func initQueue(queueLength int) {
repoIndexerOperationQueue = make(chan repoIndexerOperation, queueLength)
}

func processRepoIndexerOperationQueue(indexer Indexer) {
repoIndexerOperationQueue = make(chan repoIndexerOperation, setting.Indexer.UpdateQueueLength)
for {
select {
case op := <-repoIndexerOperationQueue:
Expand Down