Fix sql-preprocessor leading to deadlocks in parallel requests

This commit is contained in:
2022-12-22 16:51:04 +01:00
parent 0112d681ac
commit 984470b47d
3 changed files with 94 additions and 63 deletions

View File

@@ -1440,8 +1440,10 @@ func TestSendParallel(t *testing.T) {
uid := int(r0["user_id"].(float64))
sendtok := r0["send_key"].(string)
sem := make(chan tt.Void, 900) // semaphore pattern
for i := 0; i < 900; i++ {
count := 128
sem := make(chan tt.Void, count) // semaphore pattern
for i := 0; i < count; i++ {
go func() {
defer func() {
sem <- tt.Void{}
@@ -1454,7 +1456,7 @@ func TestSendParallel(t *testing.T) {
}()
}
// wait for goroutines to finish
for i := 0; i < 900; i++ {
for i := 0; i < count; i++ {
<-sem
}
}