Skip to content

Commit

Permalink
GODRIVER-2855 Relax closed, cleared, checkout conditions on logger ve…
Browse files Browse the repository at this point in the history
…rification (#1287)
  • Loading branch information
prestonvasquez authored Jun 13, 2023
1 parent 9a4ad54 commit 7d13beb
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions mongo/integration/unified/logger_verification.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,19 @@ func isUnorderedLog(log *logMessage) bool {
// or close a connection first. Because of this, either log may be
// received in any order. To account for this behavior, we considered
// both logs to be "unordered".
//
// The connection pool must clear before the connection is closed.
// However, either of these conditions are valid:
//
// 1. connection checkout failed > connection pool cleared
// 2. connection pool cleared > connection checkout failed
//
// Therefore, the ConnectionPoolCleared literal is added to the
// unordered list. The check for cleared > closed is made in the
// matching logic.
return msgStr == logger.ConnectionCheckoutFailed ||
msgStr == logger.ConnectionClosed
msgStr == logger.ConnectionClosed ||
msgStr == logger.ConnectionPoolCleared
}

type logQueues struct {
Expand Down Expand Up @@ -251,8 +262,21 @@ func matchUnorderedLogs(ctx context.Context, logs logQueues) <-chan error {
go func() {
defer close(errs)

// Record the message literals as they occur.
actualMessageSet := map[string]bool{}

for actual := range logs.unordered {
var err error
msg, err := actual.Data.LookupErr(logger.KeyMessage)
if err != nil {
errs <- fmt.Errorf("could not lookup message from unordered log: %w", err)

break
}

msgStr := msg.StringValue()
if msgStr == logger.ConnectionPoolCleared && actualMessageSet[logger.ConnectionClosed] {
errs <- fmt.Errorf("connection has been closed before the pool could clear")
}

// Iterate over the unordered log messages and verify
// that at least one of them matches the actual log
Expand All @@ -272,6 +296,8 @@ func matchUnorderedLogs(ctx context.Context, logs logQueues) <-chan error {
if err != nil {
errs <- err
}

actualMessageSet[msgStr] = true
}
}()

Expand Down

0 comments on commit 7d13beb

Please sign in to comment.