-
Notifications
You must be signed in to change notification settings - Fork 355
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 a deadlock issue using search asynchronously #446
Conversation
I can't follow your thoughts. Removing the mutex check from |
Another problem. This failure is rarely a race condition, even if the messageMutex locks. I guess it doesn't reproduce after running again. https://github.com/go-ldap/ldap/actions/runs/5599882841/jobs/10241454178?pr=447 |
We cannot guarantee that the the I still don't see what the exact problem is, maybe because of the language barrier. Lets break things down:
What am I missing here? 😓 |
I see. I agree with using mutex to get After #440, two goroutine access to You can probably reproduce easily. This is how to reproduce in my environment.
Additionally, searchResponse.Next() doesn't need to access |
Agreed @t2y 👍 Admittedly, the missing mutex for GetLastError was an oversight of me. At the time it wasn't designed for parallelism like |
…is trying to lock, and another goroutine waits since full of channel buffers go-ldap#440
741471d
to
735afe6
Compare
@cpuschma Thanks for your review. I follow you. |
The previous change is merged from #440.
I'm implementing #422 using the search asynchronous feature. I found a deadlock issue with the low-sized buffered channel in my local environment. When the buffered channel is full, a goroutine waits to send to the channel. But sometimes, searchResponse.Next() occurs deadlock since the messageMutex cannot get a lock in Conn.GetLastError().
While working at #440, I found Conn.err is a race condition. So I added messageMutex.Lock() code, which causes a deadlock issue with certain conditions (e.g., a low-sized buffered channel). That makes a more complicated problem.
This code is young, and we can revert quickly.