From a79c1ef929ebdccff958365f319fd1f28ce686f9 Mon Sep 17 00:00:00 2001 From: volgunin-ttd Date: Thu, 9 Jan 2025 13:15:24 -0500 Subject: [PATCH] CLIENT-3256: Fixes to Pool class, load balancer detection and AsyncOperateWrite (#142) * Disable load balancer address detection for localhost * Incorrect behavior of Pool.PeekFirst * Listener is not copied when AsyncOperateWrite is cloned --- AerospikeClient/Async/AsyncOperateWrite.cs | 1 + AerospikeClient/Cluster/NodeValidator.cs | 5 ++++- AerospikeClient/Cluster/Pool.cs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AerospikeClient/Async/AsyncOperateWrite.cs b/AerospikeClient/Async/AsyncOperateWrite.cs index 11e7209a..a0317b30 100644 --- a/AerospikeClient/Async/AsyncOperateWrite.cs +++ b/AerospikeClient/Async/AsyncOperateWrite.cs @@ -35,6 +35,7 @@ public AsyncOperateWrite(AsyncCluster cluster, RecordListener listener, Key key, public AsyncOperateWrite(AsyncOperateWrite other) : base(other) { + this.listener = other.listener; this.args = other.args; } diff --git a/AerospikeClient/Cluster/NodeValidator.cs b/AerospikeClient/Cluster/NodeValidator.cs index d5599f61..f8cbcd17 100644 --- a/AerospikeClient/Cluster/NodeValidator.cs +++ b/AerospikeClient/Cluster/NodeValidator.cs @@ -230,7 +230,10 @@ private void ValidateAddress(Cluster cluster, IPAddress address, string tlsName, // Disable load balancer detection for localhost. detectLoadBalancer = false; } - + } + + if (detectLoadBalancer) + { // Seed may be load balancer with changing address. Determine real address. addressCommand = (cluster.tlsPolicy != null) ? cluster.useServicesAlternate ? "service-tls-alt" : "service-tls-std" : diff --git a/AerospikeClient/Cluster/Pool.cs b/AerospikeClient/Cluster/Pool.cs index efb8627c..99be5142 100644 --- a/AerospikeClient/Cluster/Pool.cs +++ b/AerospikeClient/Cluster/Pool.cs @@ -154,7 +154,7 @@ public T PeekFirst() return default; } - return items[head]; + return items[head == 0 ? items.Length - 1 : head - 1]; } finally {