File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change 11package topo
22
33import (
4+ "context"
45 "strings"
56
67 "go.mongodb.org/mongo-driver/v2/mongo"
@@ -63,6 +64,15 @@ func isMongoCommandError(err error, name string) bool {
6364// IsTransientError checks if the error is a transient error that can be retried.
6465// It checks for specific MongoDB error codes that indicate transient issues.
6566func IsTransientError (err error ) bool {
67+ if mongo .IsNetworkError (err ) || mongo .IsTimeout (err ) || errors .Is (err , context .DeadlineExceeded ) {
68+ return true
69+ }
70+
71+ le , ok := err .(mongo.LabeledError ) //nolint:errorlint
72+ if ok {
73+ return le .HasErrorLabel ("RetryableWriteError" )
74+ }
75+
6676 transientErrorCodes := map [int ]struct {}{
6777 11602 : {}, // InterruptedDueToReplStateChange
6878 91 : {}, // ShutdownInProgress
@@ -93,10 +103,5 @@ func IsTransientError(err error) bool {
93103 return ok
94104 }
95105
96- le , ok := err .(mongo.LabeledError ) //nolint:errorlint
97- if ok {
98- return le .HasErrorLabel ("RetryableWriteError" )
99- }
100-
101106 return false
102107}
You can’t perform that action at this time.
0 commit comments