Skip to content

Commit

Permalink
Merge pull request #456 from aerospike/stage
Browse files Browse the repository at this point in the history
Go Client v7.7.2
  • Loading branch information
khaf authored Nov 1, 2024
2 parents 63370c8 + 8ffe7be commit d66939d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change History

## November 1 2024: v7.7.2

Minor fix release.

- **Fixes**
- [CLIENT-3156] Fix an issue where rack policy always returns the master node. Resolves #455

## September 18 2024: v7.7.1

Hot Fix release. This version fixes a major bug introduced in v7.7.0. You should use this release instead.
Expand Down
8 changes: 6 additions & 2 deletions partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,25 @@ func (ptn *Partition) getSequenceNode(cluster *Cluster) (*Node, Error) {
func (ptn *Partition) getRackNode(cluster *Cluster) (*Node, Error) {
replicas := ptn.partitions.Replicas

// Try to find a node on the same rack first:
for _, rackId := range cluster.clientPolicy.RackIds {
seq := ptn.sequence
for range replicas {
index := ptn.sequence % len(replicas)
index := seq % len(replicas)
node := replicas[index][ptn.PartitionId]

if node != nil && node != ptn.prevNode && node.hasRack(ptn.Namespace, rackId) && node.IsActive() {
ptn.prevNode = node
ptn.sequence = seq
ptn.sequence = seq + 1 // start from the next node and save a comparison
return node, nil
}
seq++
}
}

// A node on the same Rack was not found, so try other options.
// Same node as the previous will be the last option,
// since it is the least desirable.
for range replicas {
index := ptn.sequence % len(replicas)
node := replicas[index][ptn.PartitionId]
Expand Down

0 comments on commit d66939d

Please sign in to comment.