@@ -113,9 +113,9 @@ func (p *partitions) updateLocalPartitions(local map[int]bool) {
113
113
}
114
114
}
115
115
116
- func ( p * partitions ) deDupe (nodes []string ) []string {
116
+ func dedupe (nodes []string ) []string {
117
117
found := map [string ]bool {}
118
- dedupedNodes := make ([]string , len (nodes ))
118
+ dedupedNodes := make ([]string , 0 , len (nodes ))
119
119
for _ , node := range nodes {
120
120
if ! found [node ] {
121
121
found [node ] = true
@@ -144,12 +144,22 @@ func (p *partitions) updateRemotePartitions(nodes []string) {
144
144
}
145
145
}
146
146
147
- for partitionId , partition := range remote {
148
- newPartition := make ([]string , len (partition ))
149
- copy (newPartition , partition )
147
+ for partitionId , partition := range p .remote {
148
+ disappearedPeers := make ([]string , len (partition ))
150
149
151
- unDedupedPartition := append (newPartition , p .disappeared [partitionId ]... )
152
- p .disappeared [partitionId ] = p .deDupe (unDedupedPartition )
150
+ for _ , oldPeer := range partition {
151
+ found := false
152
+ for _ , newPeer := range remote [partitionId ] {
153
+ if newPeer == oldPeer {
154
+ found = true
155
+ }
156
+ }
157
+ if ! found {
158
+ disappearedPeers = append (disappearedPeers , oldPeer )
159
+ }
160
+ }
161
+
162
+ p .disappeared [partitionId ] = dedupe (append (disappearedPeers , p .disappeared [partitionId ]... ))
153
163
if len (p .disappeared [partitionId ]) >= 1024 {
154
164
p .disappeared [partitionId ] = p .disappeared [partitionId ][:1024 ]
155
165
}
0 commit comments