Skip to content

Commit 09ccd6f

Browse files
author
Divjot Arora
authored
GODRIVER-1572 Fix server description creation for network errors (#435)
Server descriptions used to set the server to Unknown after a network error should not have TopologyVersion set because they always need to be applied to the topology.
1 parent 3b60559 commit 09ccd6f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

x/mongo/driver/topology/server.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,10 @@ func (s *Server) ProcessHandshakeError(err error, startingGenerationNumber uint6
245245
return
246246
}
247247

248-
// Since the only kind of ConnectionError we receive from pool.Get will be an initialization
249-
// error, we should set the description.Server appropriately.
250-
s.updateDescription(description.NewServerFromError(s.address, wrappedConnErr, s.Description().TopologyVersion))
248+
// Since the only kind of ConnectionError we receive from pool.Get will be an initialization error, we should set
249+
// the description.Server appropriately. The description should not have a TopologyVersion because the staleness
250+
// checking logic above has already determined that this description is not stale.
251+
s.updateDescription(description.NewServerFromError(s.address, wrappedConnErr, nil))
251252
s.pool.clear()
252253
}
253254

@@ -367,8 +368,9 @@ func (s *Server) ProcessError(err error, conn driver.Connection) {
367368
return
368369
}
369370

370-
// updates description to unknown
371-
s.updateDescription(description.NewServerFromError(s.address, err, desc.TopologyVersion))
371+
// Update description to Unknown and clear the pool. The description should not have a TopologyVersion because
372+
// the staleness checking logic above has already determined that this description is not stale.
373+
s.updateDescription(description.NewServerFromError(s.address, err, nil))
372374
s.pool.clear()
373375
}
374376

0 commit comments

Comments
 (0)