Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Aug 20, 2024
1 parent 23f77c3 commit 7316ebe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion x/mongo/driver/topology/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,9 @@ func (p *pool) checkInNoEvent(conn *connection) error {
// not usable, which is not covered by the current pool events. We may need
// to add pool event information in the future to communicate that.
if conn.awaitingResponse != nil {
go bgRead(p, conn, *conn.awaitingResponse)
size := *conn.awaitingResponse
conn.awaitingResponse = nil
go bgRead(p, conn, size)
return nil
}

Expand Down
21 changes: 14 additions & 7 deletions x/mongo/driver/topology/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"net"
"os"
"regexp"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -1190,8 +1191,10 @@ func TestPool(t *testing.T) {
ctx, cancel := csot.MakeTimeoutContext(context.Background(), time.Second)
defer cancel()
_, err = conn.readWireMessage(ctx)
assert.ErrorContains(t, err,
"incomplete read of message header: context deadline exceeded: read unix ->./test.sock: i/o timeout")
regex := regexp.MustCompile(
`^connection\(.*\[-\d+\]\) incomplete read of message header: context deadline exceeded: read unix .*->\.\/test.sock: i\/o timeout$`,
)
assert.True(t, regex.MatchString(err.Error()), "mismatched err: %w", err)
err = p.checkIn(conn)
noerr(t, err)
wg.Wait()
Expand Down Expand Up @@ -1238,8 +1241,10 @@ func TestPool(t *testing.T) {
ctx, cancel := csot.MakeTimeoutContext(context.Background(), time.Second)
defer cancel()
_, err = conn.readWireMessage(ctx)
assert.ErrorContains(t, err,
"incomplete read of message header: context deadline exceeded: read unix ->./test.sock: i/o timeout")
regex := regexp.MustCompile(
`^connection\(.*\[-\d+\]\) incomplete read of message header: context deadline exceeded: read unix .*->\.\/test.sock: i\/o timeout$`,
)
assert.True(t, regex.MatchString(err.Error()), "mismatched err: %w", err)
err = p.checkIn(conn)
noerr(t, err)
wg.Wait()
Expand Down Expand Up @@ -1291,11 +1296,13 @@ func TestPool(t *testing.T) {

conn, err := p.checkOut(context.Background())
noerr(t, err)
ctx, cancel := csot.MakeTimeoutContext(context.Background(), time.Second)
ctx, cancel := csot.MakeTimeoutContext(context.Background(), 1*time.Second)
defer cancel()
_, err = conn.readWireMessage(ctx)
assert.ErrorContains(t, err,
"incomplete read of full message: context deadline exceeded: read unix ->./test.sock: i/o timeout")
regex := regexp.MustCompile(
`^connection\(.*\[-\d+\]\) incomplete read of full message: context deadline exceeded: read unix .*->\.\/test.sock: i\/o timeout$`,
)
assert.True(t, regex.MatchString(err.Error()), "mismatched err: %w", err)
err = p.checkIn(conn)
noerr(t, err)
wg.Wait()
Expand Down

0 comments on commit 7316ebe

Please sign in to comment.