![]() count if count != build_project_id_count # cleanup is needed end end first # Note: distinct will be slow, we'll need to use loose-index scan build_project_id_count = Ci :: Build. each_batch do | projects | min, max, count = projects. Previous Ideas: eventual consistency Ideas Option 1: Extend ActiveRecordīy extending ActiveRecord's dependent option, we could remove the associated records in an after commit callback: Overall we are referring to this concept as "Loose foreign keys". The current Draft MR is at !69165 (merged). You can see more details in the thread #338535 (comment 655802260) and other comments below that. ![]() Current planĪsynchronous data cleanup using Postgres triggers and a queuing table in Postgres that is picked up by a sidekiq cron worker. Wrapping the operation with an extra transaction on the CI DB would address the problem however, it may cause long-running transactions which could affect the availability of GitLab. If a rollback is initiated after the ci_builds records are deleted, those rows will not be restored. ![]() The deletion in the ci_builds table is actually not part of the transaction. Transaction committed on the Main database.Transaction begins on the Main database.The cross_database_modification_check utility helps to locate these cases. ![]() The following example will not work as expected with two databases since the actual build record deletion happens outside of the scope of the transaction on the Main DB (where the projects table is located). Class Project <</a> ApplicationRecord has_many :builds, class_name: 'Ci::Build', inverse_of: :project, dependent: :delete_all end #.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |