Skip to content

fix: list could lock if an error ocurred#167

Open
guilhem wants to merge 1 commit intodanielfoehrKn:masterfrom
guilhem:listlock
Open

fix: list could lock if an error ocurred#167
guilhem wants to merge 1 commit intodanielfoehrKn:masterfrom
guilhem:listlock

Conversation

@guilhem
Copy link
Contributor

@guilhem guilhem commented Mar 8, 2025

This pull request includes changes to the DoSearch function in the pkg/search.go file to improve the handling of the wait group for the result channel. The most important changes include moving the addition of the wait group counter to inside the goroutine and ensuring the counter is decremented with a defer statement.

Improvements to DoSearch function:

  • pkg/search.go: Moved wgResultChannel.Add(1) inside the loop to ensure it is called for each store in the goroutine.
  • pkg/search.go: Added defer wgResultChannel.Done() at the beginning of the goroutine to ensure the counter is decremented when the goroutine completes.
  • pkg/search.go: Removed the call to wgResultChannel.Done() from the end of the goroutine as it is now handled by the defer statement.


resultChannel := make(chan DiscoveredContext)
wgResultChannel := sync.WaitGroup{}
wgResultChannel.Add(len(stores))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we don't have the wait counter set up here any more, can we still call waitGroup.done() here when we read from the index? Looks to me like we wouldn't have a corresponding Add() any more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand where to .done() ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants