mrproliu commented on code in PR #955:
URL:
https://github.com/apache/skywalking-banyandb/pull/955#discussion_r2715372911
##########
banyand/property/listener.go:
##########
@@ -234,30 +234,38 @@ func (s *snapshotListener) Rev(ctx context.Context,
message bus.Message) bus.Mes
defer s.snapshotMux.Unlock()
storage.DeleteStaleSnapshots(s.s.snapshotDir, s.s.maxFileSnapshotNum,
s.s.minFileSnapshotAge, s.s.lfs)
sn := s.snapshotName()
- shardsRef := s.s.db.sLst.Load()
- if shardsRef == nil {
- return bus.NewMessage(bus.MessageID(time.Now().UnixNano()), nil)
- }
- shards := *shardsRef
- for _, shard := range shards {
- select {
- case <-ctx.Done():
- return
bus.NewMessage(bus.MessageID(time.Now().UnixNano()), nil)
- default:
+ var snapshotResult *databasev1.Snapshot
+ s.s.db.groups.Range(func(_, value any) bool {
+ gs := value.(*groupShards)
+ sLst := gs.shards.Load()
+ if sLst == nil {
+ return true
}
- snpDir := path.Join(s.s.snapshotDir, sn, storage.DataDir,
filepath.Base(shard.location))
- lfs.MkdirPanicIfExist(snpDir, storage.DirPerm)
- err := shard.store.TakeFileSnapshot(snpDir)
- if err != nil {
- s.s.l.Error().Err(err).Str("shard",
filepath.Base(shard.location)).Msg("fail to take shard snapshot")
- return
bus.NewMessage(bus.MessageID(time.Now().UnixNano()), &databasev1.Snapshot{
- Name: sn,
- Catalog: commonv1.Catalog_CATALOG_PROPERTY,
- Error: err.Error(),
- })
+ for _, shardRef := range *sLst {
+ select {
+ case <-ctx.Done():
Review Comment:
Done. It makes sense that if the context is canceled, then it should return
an error.
--
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]