From 2b75302780ab1a7e161b494c0b41044bd0e4caf7 Mon Sep 17 00:00:00 2001 From: Benjamin Rewis <32186188+benjirewis@users.noreply.github.com> Date: Mon, 1 Mar 2021 11:00:07 -0500 Subject: [PATCH] GODRIVER-1890 Add nil Client checks (#590) --- x/mongo/driver/operation.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x/mongo/driver/operation.go b/x/mongo/driver/operation.go index 7489850011..d0a51d0e12 100644 --- a/x/mongo/driver/operation.go +++ b/x/mongo/driver/operation.go @@ -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 { @@ -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 &&