Skip to content

Commit

Permalink
GODRIVER-1949 add more ignored killAllSessions errors for unified tes… (
Browse files Browse the repository at this point in the history
  • Loading branch information
iwysiu authored May 11, 2021
1 parent f41a6ed commit dabf9b6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions mongo/integration/unified/admin_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import (
"go.mongodb.org/mongo-driver/mongo/options"
)

const (
errorInterrupted int32 = 11601
var (
ignoredKillAllSessionsErrors = []int{
11601, // Interrupted, for SERVER-38335 on server versions below 4.2
13, // Unauthorized, for SERVER-54216 on atlas
}
)

// terminateOpenSessions executes a killAllSessions command to ensure that sesssions left open on the server by a test
Expand All @@ -34,9 +37,13 @@ func terminateOpenSessions(ctx context.Context) error {
}

err := client.Database("admin").RunCommand(ctx, cmd).Err()
if ce, ok := err.(mongo.CommandError); ok && ce.Code == errorInterrupted {
// Workaround for SERVER-38335 on server versions below 4.2.
err = nil
if se, ok := err.(mongo.ServerError); ok {
for _, code := range ignoredKillAllSessionsErrors {
if se.HasErrorCode(code) {
err = nil
break
}
}
}
return err
}
Expand Down

0 comments on commit dabf9b6

Please sign in to comment.