Copilot commented on code in PR #679:
URL: 
https://github.com/apache/skywalking-banyandb/pull/679#discussion_r2135504087


##########
banyand/backup/lifecycle/progress.go:
##########
@@ -177,6 +209,36 @@ func (p *Progress) IsMeasureGroupDeleted(group string) 
bool {
        return p.DeletedMeasureGroups[group]
 }
 
+// ClearErrors resets all prior stream/measure error records.
+func (p *Progress) ClearErrors() {
+       p.mu.Lock()
+       defer p.mu.Unlock()
+       p.StreamErrors = make(map[string]map[string]string)
+       p.MeasureErrors = make(map[string]map[string]string)
+}
+
+// MarkStreamError records an error message for a specific stream.
+func (p *Progress) MarkStreamError(group, stream, msg string) {
+       p.mu.Lock()
+       defer p.mu.Unlock()
+       if p.StreamErrors[group] == nil {
+               p.StreamErrors[group] = make(map[string]string)
+       }
+       p.StreamErrors[group][stream] = msg

Review Comment:
   Before setting p.CompletedStreams[group][stream] to false in 
MarkStreamError, ensure that p.CompletedStreams[group] is initialized to avoid 
a nil pointer dereference.
   ```suggestion
        p.StreamErrors[group][stream] = msg
        if p.CompletedStreams[group] == nil {
                p.CompletedStreams[group] = make(map[string]bool)
        }
   ```



##########
banyand/backup/lifecycle/progress.go:
##########
@@ -177,6 +209,36 @@ func (p *Progress) IsMeasureGroupDeleted(group string) 
bool {
        return p.DeletedMeasureGroups[group]
 }
 
+// ClearErrors resets all prior stream/measure error records.
+func (p *Progress) ClearErrors() {
+       p.mu.Lock()
+       defer p.mu.Unlock()
+       p.StreamErrors = make(map[string]map[string]string)
+       p.MeasureErrors = make(map[string]map[string]string)
+}
+
+// MarkStreamError records an error message for a specific stream.
+func (p *Progress) MarkStreamError(group, stream, msg string) {
+       p.mu.Lock()
+       defer p.mu.Unlock()
+       if p.StreamErrors[group] == nil {
+               p.StreamErrors[group] = make(map[string]string)
+       }
+       p.StreamErrors[group][stream] = msg
+       p.CompletedStreams[group][stream] = false
+}
+
+// MarkMeasureError records an error message for a specific measure.
+func (p *Progress) MarkMeasureError(group, measure, msg string) {
+       p.mu.Lock()
+       defer p.mu.Unlock()
+       if p.MeasureErrors[group] == nil {
+               p.MeasureErrors[group] = make(map[string]string)
+       }
+       p.MeasureErrors[group][measure] = msg

Review Comment:
   In MarkMeasureError, verify that the map p.CompletedMeasures[group] is 
initialized before setting its value to prevent a potential nil pointer 
dereference.
   ```suggestion
        p.MeasureErrors[group][measure] = msg
        if p.CompletedMeasures[group] == nil {
                p.CompletedMeasures[group] = make(map[string]bool)
        }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to