Copilot commented on code in PR #992:
URL:
https://github.com/apache/skywalking-banyandb/pull/992#discussion_r2896035653
##########
banyand/trace/svc_standalone.go:
##########
@@ -467,16 +469,25 @@ func (d *standaloneSnapshotListener) Rev(ctx
context.Context, message bus.Messag
}
groupName := g.GetSchema().Metadata.Name
snapshotPath := filepath.Join(d.s.snapshotDir, sn, groupName)
- if errGroup := d.s.takeGroupSnapshot(snapshotPath, groupName);
errGroup != nil {
+ created, errGroup := d.s.takeGroupSnapshot(snapshotPath,
groupName)
+ if errGroup != nil {
d.s.l.Error().Err(errGroup).Str("group",
groupName).Msg("fail to take group snapshot")
err = multierr.Append(err, errGroup)
continue
}
+ if !created {
+ d.s.l.Info().Str("group", groupName).Msg("skip empty
group snapshot")
+ continue
+ }
+ snapshotCreated++
// Compare snapshot with data directory to verify consistency
dataPath := filepath.Join(d.s.dataPath, groupName)
d.compareSnapshotWithData(snapshotPath, dataPath, groupName)
}
+ if snapshotCreated == 0 && err == nil {
+ return bus.NewMessage(bus.MessageID(time.Now().UnixNano()), nil)
+ }
Review Comment:
Returning a bus message with a `nil` payload when no snapshot is created can
be ambiguous for downstream consumers (e.g., they may still treat it as a
successful snapshot event but fail to decode/handle a nil body). Consider
returning the original `message` unchanged, or emitting an explicit typed/empty
snapshot marker that downstream can reliably interpret as 'no snapshot
created'. (Same pattern appears in other listeners in this PR.)
##########
banyand/internal/storage/tsdb_test.go:
##########
@@ -271,6 +272,42 @@ func TestTakeFileSnapshot(t *testing.T) {
require.NoError(t, tsdb.Close())
})
+
+ t.Run("Take snapshot with of segments", func(t *testing.T) {
Review Comment:
The subtest name has a grammatical typo; consider renaming it to clearly
express the intent (e.g., 'Take snapshot without segments').
```suggestion
t.Run("Take snapshot without segments", func(t *testing.T) {
```
--
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]