From 36c40a743788d45516b33beabc6f10b379f4de51 Mon Sep 17 00:00:00 2001 From: Brian Nichols Date: Fri, 16 Aug 2024 13:21:46 -0400 Subject: [PATCH 1/6] CLIENT-3081 Upgrade grpc version to 1.65.1 for the proxy client. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 03d679aaf..3fe926122 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 4.1.111.Final 2.0.62.Final - 1.59.0 + 1.65.1 3.0.1 0.4 1.8.0 From 9b9aee95c11e43454e217f55b98949beb5f6a5f6 Mon Sep 17 00:00:00 2001 From: Brian Nichols Date: Tue, 27 Aug 2024 11:36:47 -0400 Subject: [PATCH 2/6] CLIENT-3097 Add XDR_KEY_BUSY result code. --- client/src/com/aerospike/client/ResultCode.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/com/aerospike/client/ResultCode.java b/client/src/com/aerospike/client/ResultCode.java index cdf1d8341..54a3ce096 100644 --- a/client/src/com/aerospike/client/ResultCode.java +++ b/client/src/com/aerospike/client/ResultCode.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 Aerospike, Inc. + * Copyright 2012-2024 Aerospike, Inc. * * Portions may be licensed to Aerospike, Inc. under one or more contributor * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. @@ -233,6 +233,11 @@ public final class ResultCode { */ public static final int LOST_CONFLICT = 28; + /** + * Write can't complete until XDR finishes shipping. + */ + public static final int XDR_KEY_BUSY = 32; + /** * There are no more records left for query. */ @@ -582,6 +587,9 @@ public static String getResultString(int resultCode) { case LOST_CONFLICT: return "Transaction failed due to conflict with XDR"; + case XDR_KEY_BUSY: + return "Write can't complete until XDR finishes shipping"; + case QUERY_END: return "Query end"; From d10055efb24276f95b93fd3f533d44611ef8e813 Mon Sep 17 00:00:00 2001 From: Brian Nichols Date: Fri, 6 Sep 2024 12:57:05 -0400 Subject: [PATCH 3/6] CLIENT-3115 Support both old and new (introduced in server 7.2) error response formats in UDF register(). --- .../client/command/RegisterCommand.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/client/src/com/aerospike/client/command/RegisterCommand.java b/client/src/com/aerospike/client/command/RegisterCommand.java index b5b8b30c7..d55c7389b 100644 --- a/client/src/com/aerospike/client/command/RegisterCommand.java +++ b/client/src/com/aerospike/client/command/RegisterCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 Aerospike, Inc. + * Copyright 2012-2024 Aerospike, Inc. * * Portions may be licensed to Aerospike, Inc. under one or more contributor * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. @@ -55,11 +55,23 @@ public static RegisterTask register(Cluster cluster, Policy policy, byte[] bytes String file = null; String line = null; String message = null; + String messageNew = null; + int errorCode = 0; while (parser.next()) { String name = parser.getName(); - - if (name.equals("error")) { + + if (name.startsWith("ERROR")) { + // New error format: ERROR::;file=;line=;message= + int idx = name.indexOf(';'); + String s = (idx > 0)? name.substring(0, idx) : name; + Info.Error ie = new Info.Error(s); + messageNew = ie.message; + errorCode = ie.code; + file = parser.getValue(); + } + else if (name.equals("error")) { + // Old error format: error=;file=;line=;message= error = parser.getValue(); } else if (name.equals("file")) { @@ -72,8 +84,15 @@ else if (name.equals("message")) { message = parser.getStringBase64(); } } - - if (error != null) { + + if (errorCode != 0) { + throw new AerospikeException(errorCode, "Registration failed: " + System.lineSeparator() + + "File: " + file + System.lineSeparator() + + "Line: " + line + System.lineSeparator() + + "Message: " + messageNew + ". " + message + ); + } + else if (error != null) { throw new AerospikeException("Registration failed: " + error + System.lineSeparator() + "File: " + file + System.lineSeparator() + "Line: " + line + System.lineSeparator() + From 3bc9c06bc5972dcd5acac7ef9fc42584288280ad Mon Sep 17 00:00:00 2001 From: Brian Nichols Date: Mon, 16 Sep 2024 15:51:33 -0400 Subject: [PATCH 4/6] CLIENT-3117 Replace an existing node in the cluster when a new peer has the same node name, but a different IP address. The existing node must also have recent cluster tend failures and not be a localhost IP address (127.0.0.1) for the node replacement to proceed. --- .../com/aerospike/client/cluster/Cluster.java | 12 ++--- .../com/aerospike/client/cluster/Node.java | 44 ++++++++++++------- .../com/aerospike/client/cluster/Peer.java | 3 +- .../com/aerospike/client/cluster/Peers.java | 4 +- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/client/src/com/aerospike/client/cluster/Cluster.java b/client/src/com/aerospike/client/cluster/Cluster.java index 7bb55ad3d..10e601a4c 100644 --- a/client/src/com/aerospike/client/cluster/Cluster.java +++ b/client/src/com/aerospike/client/cluster/Cluster.java @@ -569,11 +569,11 @@ private final void tend(boolean failIfNotConnected, boolean isInit) { } // Handle nodes changes determined from refreshes. - ArrayList removeList = findNodesToRemove(peers.refreshCount); + findNodesToRemove(peers); // Remove nodes in a batch. - if (removeList.size() > 0) { - removeNodes(removeList); + if (peers.removeList.size() > 0) { + removeNodes(peers.removeList); } } @@ -762,8 +762,9 @@ protected Node createNode(NodeValidator nv) { return node; } - private final ArrayList findNodesToRemove(int refreshCount) { - ArrayList removeList = new ArrayList(); + private final void findNodesToRemove(Peers peers) { + int refreshCount = peers.refreshCount; + ArrayList removeList = peers.removeList; for (Node node : nodes) { if (! node.isActive()) { @@ -797,7 +798,6 @@ private final ArrayList findNodesToRemove(int refreshCount) { } } } - return removeList; } private final boolean findNodeInPartitionMap(Node filter) { diff --git a/client/src/com/aerospike/client/cluster/Node.java b/client/src/com/aerospike/client/cluster/Node.java index e1d30a3f4..8fa6be5a7 100644 --- a/client/src/com/aerospike/client/cluster/Node.java +++ b/client/src/com/aerospike/client/cluster/Node.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2023 Aerospike, Inc. + * Copyright 2012-2024 Aerospike, Inc. * * Portions may be licensed to Aerospike, Inc. under one or more contributor * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. @@ -426,7 +426,7 @@ protected final void refreshPeers(Peers peers) { boolean peersValidated = true; for (Peer peer : peers.peers) { - if (findPeerNode(cluster, peers, peer.nodeName)) { + if (findPeerNode(cluster, peers, peer)) { // Node already exists. Do not even try to connect to hosts. continue; } @@ -450,19 +450,16 @@ protected final void refreshPeers(Peers peers) { if (Log.warnEnabled()) { Log.warn("Peer node " + peer.nodeName + " is different than actual node " + nv.name + " for host " + host); } - - if (findPeerNode(cluster, peers, nv.name)) { - // Node already exists. Do not even try to connect to hosts. - nv.primaryConn.close(); - nodeValidated = true; - break; - } } // Create new node. Node node = cluster.createNode(nv); peers.nodes.put(nv.name, node); - nodeValidated = true; + nodeValidated = true; + + if (peer.replaceNode != null) { + peers.removeList.add(peer.replaceNode); + } break; } catch (Throwable e) { @@ -490,20 +487,37 @@ protected final void refreshPeers(Peers peers) { } } - private static boolean findPeerNode(Cluster cluster, Peers peers, String nodeName) { + private static boolean findPeerNode(Cluster cluster, Peers peers, Peer peer) { // Check global node map for existing cluster. - Node node = cluster.nodesMap.get(nodeName); + Node node = cluster.nodesMap.get(peer.nodeName); if (node != null) { - node.referenceCount++; - return true; + // Node name found. + if (node.failures <= 0 || node.address.getAddress().isLoopbackAddress()) { + // If the node does not have cluster tend errors or is localhost, + // reject new peer as the IP address does not need to change. + node.referenceCount++; + return true; + } + + // Match peer hosts with the node host. + for (Host h : peer.hosts) { + if (h.equals(node.host)) { + // Main node host is also the same as one of the peer hosts. + // Peer should not be added. + node.referenceCount++; + return true; + } + } + peer.replaceNode = node; } // Check local node map for this tend iteration. - node = peers.nodes.get(nodeName); + node = peers.nodes.get(peer.nodeName); if (node != null) { node.referenceCount++; + peer.replaceNode = null; return true; } return false; diff --git a/client/src/com/aerospike/client/cluster/Peer.java b/client/src/com/aerospike/client/cluster/Peer.java index 05ab16a1d..83712a5a8 100644 --- a/client/src/com/aerospike/client/cluster/Peer.java +++ b/client/src/com/aerospike/client/cluster/Peer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 Aerospike, Inc. + * Copyright 2012-2024 Aerospike, Inc. * * Portions may be licensed to Aerospike, Inc. under one or more contributor * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. @@ -24,4 +24,5 @@ public final class Peer { String nodeName; String tlsName; List hosts; + Node replaceNode; } diff --git a/client/src/com/aerospike/client/cluster/Peers.java b/client/src/com/aerospike/client/cluster/Peers.java index bd28255d1..9c38f8a49 100644 --- a/client/src/com/aerospike/client/cluster/Peers.java +++ b/client/src/com/aerospike/client/cluster/Peers.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 Aerospike, Inc. + * Copyright 2012-2024 Aerospike, Inc. * * Portions may be licensed to Aerospike, Inc. under one or more contributor * license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0. @@ -26,6 +26,7 @@ public final class Peers { public final ArrayList peers; public final HashMap nodes; + public final ArrayList removeList; private final HashSet invalidHosts; public int refreshCount; public boolean genChanged; @@ -33,6 +34,7 @@ public final class Peers { public Peers(int peerCapacity) { peers = new ArrayList(peerCapacity); nodes = new HashMap(16); + removeList = new ArrayList(); invalidHosts = new HashSet(8); } From 610109ef64684bd45d989c5de6497ba60f75d6c7 Mon Sep 17 00:00:00 2001 From: Brian Nichols Date: Tue, 17 Sep 2024 11:41:46 -0400 Subject: [PATCH 5/6] Upgrade to netty 4.1.112.Final and commons-cli 1.9.0 per snyk. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3fe926122..b6bc2569d 100644 --- a/pom.xml +++ b/pom.xml @@ -39,12 +39,12 @@ 2.18.1 3.2.0 - 4.1.111.Final + 4.1.112.Final 2.0.62.Final 1.65.1 3.0.1 0.4 - 1.8.0 + 1.9.0 4.13.1 From 95a64d9a2f744519861febe501cd892d4cb5155a Mon Sep 17 00:00:00 2001 From: Brian Nichols Date: Tue, 17 Sep 2024 11:56:01 -0400 Subject: [PATCH 6/6] Update version 8.1.4 --- benchmarks/pom.xml | 2 +- client/pom.xml | 2 +- examples/pom.xml | 2 +- pom.xml | 2 +- proxy/pom.xml | 2 +- test/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index e79957d8c..cb4b52b73 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -6,7 +6,7 @@ com.aerospike aerospike-parent - 8.1.3 + 8.1.4 aerospike-benchmarks jar diff --git a/client/pom.xml b/client/pom.xml index 65008b3ef..dfe67163a 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -6,7 +6,7 @@ com.aerospike aerospike-parent - 8.1.3 + 8.1.4 aerospike-client-jdk8 jar diff --git a/examples/pom.xml b/examples/pom.xml index 21ced4a1f..fad839b13 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -6,7 +6,7 @@ com.aerospike aerospike-parent - 8.1.3 + 8.1.4 aerospike-examples jar diff --git a/pom.xml b/pom.xml index b6bc2569d..359cdd7f7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.aerospike aerospike-parent aerospike-parent - 8.1.3 + 8.1.4 pom https://github.com/aerospike/aerospike-client-java diff --git a/proxy/pom.xml b/proxy/pom.xml index 8e8ebd270..9be7dce26 100644 --- a/proxy/pom.xml +++ b/proxy/pom.xml @@ -6,7 +6,7 @@ com.aerospike aerospike-parent - 8.1.3 + 8.1.4 aerospike-proxy-client jar diff --git a/test/pom.xml b/test/pom.xml index ac86ff071..1ed1b89a9 100644 --- a/test/pom.xml +++ b/test/pom.xml @@ -6,7 +6,7 @@ com.aerospike aerospike-parent - 8.1.3 + 8.1.4 aerospike-client-test jar