Remove 1 cross-database foreign keys referencing `merge_requests`
merge_requests is referenced as a foreign key from other 1 other tables in a different database
The intention of this issue is to determine any risks when changing all of the below foreign keys referencing merge_requests to become Loose foreign keys. Loose foreign keys are cleaned up asynchronously which means when we perform a DELETE FROM merge_requests
we will queue a cleanup task that will be executed in ~5 mins to cleanup all of the rows that reference this record. This can mean there are sometimes strange UX bugs where they may see a link to something that no longer exists and clicking it may give an error or it may mean there is a background job that runs and errors due to an invalid foreign key or it may mean a 500 when rendering a certain page containing any of the below tables. Some more details about risks and mitigations are being documented in !76626 (merged) .
The groupsharding will be responsible for actually doing the work to convert the foreign keys to loose foreign keys but will likely need help from impacted teams to asses the risk and potentially determine or implement appropriate mitigation for any risks. Sometimes mitigation may mean refactoring code slightly to avoid errors or explicitly handling certain riskier cases by checking if there is a pending deletion for a record. It is also possible that we can optimize the 5 minute latency for cleanup in certain cases determined to be urgent.
-
ci_pipelines.merge_request_id
->merge_requests.id
-ON DELETE CASCADE
-
Best team to review (@fabiopitino): grouppipeline execution devopsverify -
MR: !78574 (merged) -
No way for user to access once parent is deleted. Please explain: <DETAIL>
-
Possible to access once parent deleted but low user impact. Please explain: <DETAIL>
-
Possible Sidekiq workers that may load directly and possibly lead to exceptions. Please explain: <DETAIL>
-
Possible user impact to be evaluated or mitigated. Please explain: In Ci::Pipeline#merge_request?
we rely solely on the presence of themerge_request_id
. If present we assume that we can safely usepipeline.merge_request
object. This won't be the case once the FK is removed. You can grep formerge_request?
inCi::Pipeline
model.- required remediation: change
merge_request?
method tomerge_request_id.present? && merge_request
. This should also be safe from performance perspective because all the places where we check formerge_request?
we end up using the memoized object.
- required remediation: change
-