Split out notification service from refresh worker

What does this MR do and why?

This MR implements the second step in splitting the MergeRequests::RefreshService by extracting notification-related functionality into a separate service and worker. This refactoring improves the separation of concerns and allows for better performance optimization of merge request refresh operations.

Key Changes:

  1. New MergeRequests::Refresh::NotificationService: Extracts notification-related logic from the main refresh service, including:
    • Outdating suggestions on merge requests
    • Marking pending todos as done
    • Adding system notes for branch presence changes
    • Tracking merge request activity metrics
    • Handling push notifications to merge requests
    • Processing commit-related notifications and system notes
  2. New MergeRequests::Refresh::NotificationWorker: A Sidekiq worker that processes notifications asynchronously with:
    • Low urgency and CPU resource boundary
    • Idempotent execution with deduplication
    • Proper error handling for missing projects/users
    • Weight of 2 to handle the processing load
  3. Feature Flag Integration: Introduces split_refresh_worker_notification feature flag to gradually roll out the new architecture:
    • When enabled: Notification processing happens asynchronously via the new worker
    • When disabled: Falls back to the original synchronous behavior
  4. EE Extension: Maintains Enterprise Edition functionality with proper override for merge train handling

Benefits:

  • Performance: Moves time-consuming notification operations to background processing
  • Scalability: Reduces blocking time in the main refresh flow
  • Maintainability: Better separation of concerns with focused, testable services
  • Gradual Rollout: Feature flag allows safe deployment and rollback if needed

Implementation Notes:

This approach uses direct worker enqueuing rather than events to allow independent feature flag control during the transition period. The worker will only execute if both project and user exist, providing robust error handling for edge cases.

The notification service handles all user-facing notifications including system notes for branch changes, commit notifications, suggestion outdating, and todo management.

References

Related to the ongoing effort to optimize merge request refresh performance and split worker responsibilities for better scalability.

Part of: #554081 (closed)

Edited by Marc Shaw

Merge request reports

Loading