Skip to content

Commit 9a14cd2

Browse files
committed
Need global cursor for node recovery #1810
Should try each node in turn if still failing
1 parent 3b68d34 commit 9a14cd2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Elasticsearch.Net/ConnectionPool/StickyConnectionPool.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public StickyConnectionPool(IEnumerable<Node> nodes, IDateTimeProvider dateTimeP
4848
this.LastUpdate = this.DateTimeProvider.Now();
4949
}
5050

51+
protected int GlobalCursor = -1;
52+
5153
public IEnumerable<Node> CreateView(Action<AuditEvent, Node> audit = null)
5254
{
5355
var now = this.DateTimeProvider.Now();
@@ -58,9 +60,10 @@ public IEnumerable<Node> CreateView(Action<AuditEvent, Node> audit = null)
5860

5961
if (count == 0)
6062
{
63+
var globalCursor = Interlocked.Increment(ref GlobalCursor);
6164
//could not find a suitable node retrying on first node off globalCursor
6265
audit?.Invoke(AuditEvent.AllNodesDead, null);
63-
node = this.InternalNodes[0];
66+
node = this.InternalNodes[globalCursor % this.InternalNodes.Count];
6467
node.IsResurrected = true;
6568
audit?.Invoke(AuditEvent.Resurrection, node);
6669
yield return node;

0 commit comments

Comments
 (0)