From 14e4c0800d00731647be7ef3cad7391ad5df072b Mon Sep 17 00:00:00 2001 From: Rob Skillington Date: Tue, 5 Jan 2021 11:05:37 -0500 Subject: [PATCH] [dbnode] Add ExcludeOrigin to skip localhost on BorrowConnections (#3066) --- src/dbnode/client/session.go | 6 +++++- src/dbnode/client/types.go | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/dbnode/client/session.go b/src/dbnode/client/session.go index e1de530ebe..6c8bdda825 100644 --- a/src/dbnode/client/session.go +++ b/src/dbnode/client/session.go @@ -655,6 +655,10 @@ func (s *session) BorrowConnections( // Error or has broken return } + if opts.ExcludeOrigin && s.origin != nil && s.origin.ID() == host.ID() { + // Skip origin host. + return + } var ( userResult WithBorrowConnectionResult @@ -937,7 +941,7 @@ func (s *session) setTopologyWithLock(topoMap topology.Map, queues []hostQueue, if s.pools.multiReaderIteratorArray == nil { s.pools.multiReaderIteratorArray = encoding.NewMultiReaderIteratorArrayPool([]pool.Bucket{ - pool.Bucket{ + { Capacity: replicas, Count: s.opts.SeriesIteratorPoolSize(), }, diff --git a/src/dbnode/client/types.go b/src/dbnode/client/types.go index 0de707fe23..2fc6203641 100644 --- a/src/dbnode/client/types.go +++ b/src/dbnode/client/types.go @@ -260,6 +260,9 @@ type BorrowConnectionOptions struct { // ContinueOnBorrowError allows skipping hosts that cannot borrow // a connection for. ContinueOnBorrowError bool + // ExcludeOrigin will exclude attempting to borrow a connection for + // the origin host (i.e. the local host). + ExcludeOrigin bool } // BorrowConnectionsResult is a result used when borrowing connections.