Skip to content

Commit

Permalink
GODRIVER-1890 Add nil Client checks (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjirewis authored and Benjamin Rewis committed Mar 1, 2021
1 parent d07cbc8 commit 2b75302
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions x/mongo/driver/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ func (op Operation) Execute(ctx context.Context, scratch []byte) error {
connDesc := conn.Description()
retryableErr := tt.Retryable(connDesc.WireVersion)
preRetryWriteLabelVersion := connDesc.WireVersion != nil && connDesc.WireVersion.Max < 9
inTransaction := !(op.Client.Committing || op.Client.Aborting) && op.Client.TransactionRunning()
inTransaction := op.Client != nil &&
!(op.Client.Committing || op.Client.Aborting) && op.Client.TransactionRunning()
// If retry is enabled and the operation isn't in a transaction, add a RetryableWriteError label for
// retryable errors from pre-4.4 servers
if retryableErr && preRetryWriteLabelVersion && retryEnabled && !inTransaction {
Expand Down Expand Up @@ -465,7 +466,8 @@ func (op Operation) Execute(ctx context.Context, scratch []byte) error {
if op.Type == Write {
retryableErr = tt.RetryableWrite(connDesc.WireVersion)
preRetryWriteLabelVersion := connDesc.WireVersion != nil && connDesc.WireVersion.Max < 9
inTransaction := !(op.Client.Committing || op.Client.Aborting) && op.Client.TransactionRunning()
inTransaction := op.Client != nil &&
!(op.Client.Committing || op.Client.Aborting) && op.Client.TransactionRunning()
// If retryWrites is enabled and the operation isn't in a transaction, add a RetryableWriteError label
// for network errors and retryable errors from pre-4.4 servers
if retryEnabled && !inTransaction &&
Expand Down

0 comments on commit 2b75302

Please sign in to comment.