Add feature flag for async pipeline creation in NewMergeRequestWorker
What does this MR do and why?
This MR introduces a feature flag async_mr_pipeline_creation to switch pipeline creation to async mode in MergeRequests::AfterCreateService.
Problem
The NewMergeRequestWorker has a P90 latency of over 3 seconds, which exceeds our S3 criteria target of less than 1 second. One of the slow parts is the synchronous pipeline creation in MergeRequests::AfterCreateService#prepare_for_mergeability.
Solution
When the async_mr_pipeline_creation feature flag is enabled:
- Pipeline creation is performed asynchronously via
MergeRequests::CreatePipelineWorker - This reduces the time spent in
NewMergeRequestWorkerby offloading pipeline creation to a separate worker - The existing
execute_asyncmethod inMergeRequests::CreatePipelineServicehandles the async flow, including GraphQL subscription triggers for real-time UI updates
Feature Flag
-
Name:
async_mr_pipeline_creation -
Type:
gitlab_com_derisk - Default: disabled
- Scope: project-level
How to test
Setup
- Enable the feature flag for a test project:
Feature.enable(:async_mr_pipeline_creation, Project.find(<project_id>))
Test Steps
-
With feature flag disabled (default behavior):
- Create a new merge request in the test project
- Observe that the pipeline is created synchronously during MR creation
- The MR should display the pipeline status immediately after creation
-
With feature flag enabled (async behavior):
- Enable the feature flag as shown above
- Create a new merge request in the test project
- Observe that the MR is created quickly (pipeline creation is offloaded)
- The pipeline should appear shortly after via
MergeRequests::CreatePipelineWorker - Verify the pipeline status updates in the UI via GraphQL subscriptions
Expected Results
- Both scenarios should result in a pipeline being created for the merge request
- With the flag enabled, MR creation should be noticeably faster
- No functional difference in the end result - only timing of pipeline creation changes
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist.
Related issues
- Epic: &10991
- Related investigation: #417973 (closed)
Edited by Marc Shaw