nandi/gleanpublic Fork 0
a0b2768
Commits
Clone
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Defer RecountSubscriberCounts to after full syncUnverified

Julien Robert committed 2026-05-05T20:41:44+02:00 Browse files
a0b2768 parent: 65861f6
modified internal/atproto/sync.go +0 -6
@@ -36,12 +36,6 @@ func (s *Sync) Run(ctx context.Context, userDID string) error {
3636 if err := s.syncSubscriptions(ctx, userDID); err != nil {
3737 s.logger.Error("sync subscriptions failed", "error", err, "did", userDID)
3838 }
39- // Recompute subscriber_count from subscriptions table rather than
40- // maintaining it incrementally (done here to avoid drift from race conditions
41- // between stream handler events and sync operations).
42- if err := s.articles.RecountSubscriberCounts(ctx); err != nil {
43- s.logger.Error("recount subscriber counts failed", "error", err, "did", userDID)
44- }
4539 if err := s.syncLikes(ctx, userDID); err != nil {
4640 s.logger.Error("sync likes failed", "error", err, "did", userDID)
4741 }
@@ -36,12 +36,6 @@ func (s *Sync) Run(ctx context.Context, userDID string) error {
36 if err := s.syncSubscriptions(ctx, userDID); err != nil {36 if err := s.syncSubscriptions(ctx, userDID); err != nil {
37 s.logger.Error("sync subscriptions failed", "error", err, "did", userDID)37 s.logger.Error("sync subscriptions failed", "error", err, "did", userDID)
38 }38 }
39- // Recompute subscriber_count from subscriptions table rather than
40- // maintaining it incrementally (done here to avoid drift from race conditions
41- // between stream handler events and sync operations).
42- if err := s.articles.RecountSubscriberCounts(ctx); err != nil {
43- s.logger.Error("recount subscriber counts failed", "error", err, "did", userDID)
44- }
45 if err := s.syncLikes(ctx, userDID); err != nil {39 if err := s.syncLikes(ctx, userDID); err != nil {
46 s.logger.Error("sync likes failed", "error", err, "did", userDID)40 s.logger.Error("sync likes failed", "error", err, "did", userDID)
47 }41 }
modified internal/server/server.go +5 -0
@@ -520,6 +520,11 @@ func (s *Server) runSyncAll(ctx context.Context) {
520520
521521 metrics.SyncRuns.Inc()
522522 }
523+
524+ // Recompute subscriber_count once after all users are synced.
525+ if err := s.dbs.Articles.RecountSubscriberCounts(ctx); err != nil {
526+ s.logger.Error("recount subscriber counts failed", "error", err)
527+ }
523528 }
524529
525530 func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@@ -520,6 +520,11 @@ func (s *Server) runSyncAll(ctx context.Context) {
520 520
521 metrics.SyncRuns.Inc()521 metrics.SyncRuns.Inc()
522 }522 }
523+
524+ // Recompute subscriber_count once after all users are synced.
525+ if err := s.dbs.Articles.RecountSubscriberCounts(ctx); err != nil {
526+ s.logger.Error("recount subscriber counts failed", "error", err)
527+ }
523 }528 }
524 529
525 func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {530 func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {