@@ -128,13 +128,15 @@ func (r *Reporter) SpanConfigConformance(
128
128
return roachpb.SpanConfigConformanceReport {}, err
129
129
}
130
130
131
- report := roachpb.SpanConfigConformanceReport {}
131
+ ret := roachpb.SpanConfigConformanceReport {}
132
132
unavailableNodes := make (map [roachpb.NodeID ]struct {})
133
133
134
134
isLiveMap := r .dep .NodeVitalityInterface .ScanNodeVitalityFromCache ()
135
135
for _ , span := range spans {
136
+ // Build a separate report per span, so that we can handle resets correctly.
137
+ spanReport := roachpb.SpanConfigConformanceReport {}
136
138
if err := r .dep .Scan (ctx , int (rangeDescPageSize .Get (& r .settings .SV )),
137
- func () { report = roachpb.SpanConfigConformanceReport {} /* init */ },
139
+ func () { spanReport = roachpb.SpanConfigConformanceReport {} /* init */ },
138
140
span ,
139
141
func (descriptors ... roachpb.RangeDescriptor ) error {
140
142
for _ , desc := range descriptors {
@@ -152,21 +154,21 @@ func (r *Reporter) SpanConfigConformance(
152
154
return isLive
153
155
}, int (conf .GetNumVoters ()), int (conf .GetNumNonVoters ()))
154
156
if ! status .Available {
155
- report .Unavailable = append (report .Unavailable ,
157
+ spanReport .Unavailable = append (spanReport .Unavailable ,
156
158
roachpb.ConformanceReportedRange {
157
159
RangeDescriptor : desc ,
158
160
Config : conf ,
159
161
})
160
162
}
161
163
if status .UnderReplicated || status .UnderReplicatedNonVoters {
162
- report .UnderReplicated = append (report .UnderReplicated ,
164
+ spanReport .UnderReplicated = append (spanReport .UnderReplicated ,
163
165
roachpb.ConformanceReportedRange {
164
166
RangeDescriptor : desc ,
165
167
Config : conf ,
166
168
})
167
169
}
168
170
if status .OverReplicated || status .OverReplicatedNonVoters {
169
- report .OverReplicated = append (report .OverReplicated ,
171
+ spanReport .OverReplicated = append (spanReport .OverReplicated ,
170
172
roachpb.ConformanceReportedRange {
171
173
RangeDescriptor : desc ,
172
174
Config : conf ,
@@ -189,7 +191,7 @@ func (r *Reporter) SpanConfigConformance(
189
191
c .NumReplicas = conf .NumReplicas
190
192
}
191
193
if len (overall .SatisfiedBy [i ]) < int (c .NumReplicas ) {
192
- report .ViolatingConstraints = append (report .ViolatingConstraints ,
194
+ spanReport .ViolatingConstraints = append (spanReport .ViolatingConstraints ,
193
195
roachpb.ConformanceReportedRange {
194
196
RangeDescriptor : desc ,
195
197
Config : conf ,
@@ -206,7 +208,7 @@ func (r *Reporter) SpanConfigConformance(
206
208
c .NumReplicas = conf .GetNumVoters ()
207
209
}
208
210
if len (voters .SatisfiedBy [i ]) < int (c .NumReplicas ) {
209
- report .ViolatingConstraints = append (report .ViolatingConstraints ,
211
+ spanReport .ViolatingConstraints = append (spanReport .ViolatingConstraints ,
210
212
roachpb.ConformanceReportedRange {
211
213
RangeDescriptor : desc ,
212
214
Config : conf ,
@@ -219,10 +221,16 @@ func (r *Reporter) SpanConfigConformance(
219
221
}); err != nil {
220
222
return roachpb.SpanConfigConformanceReport {}, err
221
223
}
224
+
225
+ // Merge the spanReport into the return value.
226
+ ret .Unavailable = append (ret .Unavailable , spanReport .Unavailable ... )
227
+ ret .UnderReplicated = append (ret .UnderReplicated , spanReport .UnderReplicated ... )
228
+ ret .OverReplicated = append (ret .OverReplicated , spanReport .OverReplicated ... )
229
+ ret .ViolatingConstraints = append (ret .ViolatingConstraints , spanReport .ViolatingConstraints ... )
222
230
}
223
231
224
232
for nid := range unavailableNodes {
225
- report .UnavailableNodeIDs = append (report .UnavailableNodeIDs , int32 (nid ))
233
+ ret .UnavailableNodeIDs = append (ret .UnavailableNodeIDs , int32 (nid ))
226
234
}
227
- return report , nil
235
+ return ret , nil
228
236
}
0 commit comments