Rubocop allow validate_foreign_key in with_lock_retries
What does this MR do and why?
ALTER TABLE VALIDATE CONSTRAINT
requires a table level lock ShareUpdateExclusiveLock
.
ShareUpdateExclusiveLock
might conflict with other processes, e.g. ANALYZE
and VACUUM
according to this doc.
In this case, it should be safer if validate_foreign_key
can be wrapped in the with_lock_retries
block.
gitlabhq_test_ci=# BEGIN TRANSACTION;
BEGIN
gitlabhq_test_ci=*# SET LOCAL lock_timeout TO '100ms';
SET
gitlabhq_test_ci=*# ALTER TABLE ci_pipeline_chat_data VALIDATE CONSTRAINT fk_64ebfab6b3_p_tmp;
ALTER TABLE
gitlabhq_test_ci=*# SELECT
gitlabhq_test_ci-*# relation::regclass AS relation_name,
gitlabhq_test_ci-*# *
gitlabhq_test_ci-*# FROM
gitlabhq_test_ci-*# pg_locks
gitlabhq_test_ci-*# WHERE
gitlabhq_test_ci-*# relation::regclass::text NOT LIKE 'pg_%'
gitlabhq_test_ci-*# AND relation::regclass::text NOT LIKE '%index%'
gitlabhq_test_ci-*# AND relation::regclass::text NOT LIKE '%idx%';
relation_name | locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath | waitstart
----------------------------+----------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+-------+--------------------------+---------+----------+-----------
ci_pipelines_pkey | relation | 13102713 | 13132521 | | | | | | | | 6/310685 | 51192 | AccessShareLock | t | t |
ci_pipelines | relation | 13102713 | 13126634 | | | | | | | | 6/310685 | 51192 | AccessShareLock | t | t |
ci_pipeline_chat_data_pkey | relation | 13102713 | 13132503 | | | | | | | | 6/310685 | 51192 | AccessShareLock | t | t |
ci_pipeline_chat_data | relation | 13102713 | 13126580 | | | | | | | | 6/310685 | 51192 | AccessShareLock | t | t |
p_ci_pipelines | relation | 13102713 | 13126625 | | | | | | | | 6/310685 | 51192 | AccessShareLock | t | t |
p_ci_pipelines | relation | 13102713 | 13126625 | | | | | | | | 6/310685 | 51192 | RowShareLock | t | t |
ci_pipeline_chat_data | relation | 13102713 | 13126580 | | | | | | | | 6/310685 | 51192 | ShareUpdateExclusiveLock | t | f |
(7 rows)
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Related to #428990 (closed)
Edited by Tianwen Chen