summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb
Commit message (Collapse)AuthorAgeFilesLines
* Handle null serialised commits in background migration39181-gitlab-backgroundmigration-deserializemergerequestdiffsandcommits-error-nomethoderror-undefined-method-map-for-nil-nilclassSean McGivern2017-10-171-0/+1
| | | | This is already handled for diffs, but not commits.
* Make MR diff background migration less likely to time outSean McGivern2017-09-291-9/+25
| | | | | | | | | | | | | | | This version does not use transactions, but individual statements. As we have unique constraints on the target tables for the inserts, we can just ignore uniqueness violations there (as long as we always insert the same batch size, in the same order). This means the spec now must use truncation, not a transaction, as the uniqueness violation means that the whole transaction for that spec would be invalid, which isn't what we'd want. In real-world use, this isn't run in a transaction anyway. This commit also wraps unhandled exceptions, for easier finding in Sentry, and logs with a consistent format, for easier searching.
* Insert at most 1,000 rows at once in MR diff background migrationSean McGivern2017-09-291-3/+9
| | | | | | We were hitting the statement timeout for very large MR diffs. Now we insert at most 1,000 rows to `merge_request_diff_commits` in a single statement, or 100 rows to `merge_request_diff_files`.
* Fix MR diffs background migration when file modes are missing36630-activerecord-statementinvalid-pg-notnullviolation-error-null-value-in-column-a_mode-violates-not-null-constraintSean McGivern2017-08-181-1/+13
| | | | | | | | | | | Guess the modes based on the following: 1. If the file didn't exist, it's zero. 2. If the diff contains 'Subproject commit', it might be a submodule, so 0600. 3. Otherwise, it's 0644. This isn't perfect, but it doesn't have to be - it won't change file modes in the repository.
* Fix merge request diff deserialisation when too_large was absentSean McGivern2017-08-111-0/+2
| | | | | Not all diffs in st_diffs had the too_large attribute set at all, but the column is non-nullable. Explicitly cast to boolean to avoid that problem.
* Migrate MR commits and diffs to new tablesmerge-request-commits-background-migrationSean McGivern2017-08-031-0/+107
Previously, we stored these as serialised fields - `st_{commits,diffs}` - on the `merge_request_diffs` table. These now have their own tables - `merge_request_diff_{commits,diffs}` - with a column for each attribute of the serialised data. Add a background migration to go through the existing MR diffs and migrate them to the new format. Ignore any contents that cannot be displayed. Assuming that we have 5 million rows to migrate, and each batch of 2,500 rows can be completed in 5 minutes, this will take about 7 days to migrate everything.