mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-07 21:37:04 +09:00
GO-5727: Subscriptions: improve lock contention
This commit is contained in:
parent
7b8dd360f0
commit
108ab57e33
1 changed files with 8 additions and 4 deletions
|
@ -225,10 +225,14 @@ func (s *service) SubscribeGroups(req SubscribeGroupsRequest) (*pb.RpcObjectGrou
|
|||
|
||||
func (s *service) Unsubscribe(subIds ...string) (err error) {
|
||||
s.lock.Lock()
|
||||
subs := make([]*spaceSubscriptions, 0, len(s.spaceSubs))
|
||||
for _, spaceSub := range s.spaceSubs {
|
||||
err = errors.Join(spaceSub.Unsubscribe(subIds...))
|
||||
subs = append(subs, spaceSub)
|
||||
}
|
||||
s.lock.Unlock()
|
||||
for _, spaceSub := range subs {
|
||||
err = errors.Join(spaceSub.Unsubscribe(subIds...))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -614,9 +618,6 @@ type SubscribeGroupsRequest struct {
|
|||
func (s *spaceSubscriptions) SubscribeGroups(req SubscribeGroupsRequest) (*pb.RpcObjectGroupsSubscribeResponse, error) {
|
||||
subId := ""
|
||||
|
||||
s.m.Lock()
|
||||
defer s.m.Unlock()
|
||||
|
||||
q := database.Query{
|
||||
Filters: req.Filters,
|
||||
}
|
||||
|
@ -678,6 +679,9 @@ func (s *spaceSubscriptions) SubscribeGroups(req SubscribeGroupsRequest) (*pb.Rp
|
|||
subId = bson.NewObjectId().Hex()
|
||||
}
|
||||
|
||||
s.m.Lock()
|
||||
defer s.m.Unlock()
|
||||
|
||||
var sub subscription
|
||||
if colObserver != nil {
|
||||
sub = s.newCollectionGroupSub(subId, domain.RelationKey(req.RelationKey), flt, groups, colObserver)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue