Skip to content

Commit

Permalink
♻️ Fix race condition
Browse files Browse the repository at this point in the history
Signed-off-by: vankichi <kyukawa315@gmail.com>
  • Loading branch information
vankichi committed Jan 15, 2025
1 parent 3df88e8 commit 11cd40d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tests/e2e/operation/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,13 @@ func (c *client) InsertWithParameters(

if err != nil {
if err := evalidator(t, err); err != nil {
mu.Lock()
rerr = errors.Join(
rerr,
errors.Errorf(
"stream finished by an error: %s",
err.Error(),
),
)
mu.Unlock()
}
return
}
Expand Down Expand Up @@ -857,6 +855,7 @@ func (c *client) UpsertWithParameters(
}

wg := sync.WaitGroup{}
mu := sync.Mutex{}
wg.Add(1)
go func() {
defer wg.Done()
Expand All @@ -865,7 +864,9 @@ func (c *client) UpsertWithParameters(
for {
res, err := sc.Recv()
if err == io.EOF {
mu.Lock()
rerr = ierr
mu.Unlock()
return
}

Expand All @@ -879,7 +880,9 @@ func (c *client) UpsertWithParameters(
),
)
}
mu.Lock()
rerr = ierr
mu.Unlock()
return
}

Expand Down Expand Up @@ -918,7 +921,10 @@ func (c *client) UpsertWithParameters(
},
})
if err != nil {
return err
mu.Lock()
rerr = errors.Join(rerr, err)
mu.Unlock()
return
}
}

Expand Down

0 comments on commit 11cd40d

Please sign in to comment.