Commit Graph

327 Commits

Author SHA1 Message Date
Rémy Coutable 4037eb32e0
Put four flaky specs in quanrantine
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-04-17 15:54:14 +02:00
Michael Kozono b22a725a0c Merge branch 'sh-fix-issue-59985' into 'master'
Fix stage index migration failing in PostgreSQL 10

Closes #59985

See merge request gitlab-org/gitlab-ce!26972
2019-04-08 20:11:46 +00:00
Thong Kuah 4ec16912b8 Autocorrect with RSpec/ExampleWording cop
- rewords examples starting with 'should'
- rewords examples starting with 'it'

Note: I had to manually fixup "onlies" to "only"
2019-04-05 08:43:27 +00:00
Stan Hu 0f5b735685 Fix stage index migration failing in PostgreSQL 10
As discussed in
https://www.postgresql.org/message-id/9922.1353433645%40sss.pgh.pa.us,
the PostgreSQL window function last_value may not consider the
right rows:

Note that first_value, last_value, and nth_value consider only the rows
within the "window frame", which by default contains the rows from the
start of the partition through the last peer of the current row. This is
likely to give unhelpful results for last_value and sometimes also
nth_value. You can redefine the frame by adding a suitable frame
specification (RANGE or ROWS) to the OVER clause. See Section 4.2.8 for
more information about frame specifications.

This query could be fixed by adding `RANGE BETWEEN UNBOUNDED PRECEDING
AND UNBOUNDED FOLLOWING`, but that's quite verbose. It's simpler just to
use the first_value function.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/59985
2019-04-03 22:47:51 -07:00
Oswaldo Ferreira 929ee4d18d Add multiple assignees migration and table population
This will be further required for supporting multi-assignees MRs
2019-03-25 19:50:40 -03:00
Nick Thomas 9f05e97aad
Run rubocop -a 2019-03-13 13:42:43 +00:00
Imre Farkas 6d92a3d4e2 Remove undigested token column from personal_access_tokens table
Token column are no longer used as token values are stored digested in
token_digest.
2019-02-20 11:39:37 +00:00
Rémy Coutable 3a2abc1d50
Enable the Layout/ExtraSpacing cop
Signed-off-by: Rémy Coutable <remy@rymai.me>
2019-01-24 13:05:45 +01:00
Mayra Cabrera 70e5d0ad1b Removes factories on Cluster background migration
'Populate cluster kubernetes namespace' was using factories for their
specs. According to our documentation (see spec/migrations/readme.md),
we should use table helper to create a temproary ActiveRecord::Base
derived model for a table.
2019-01-22 09:18:07 -06:00
Bob Van Landuyt c905130ef0 Ignore existing offenses of FactoriesInMigration 2019-01-16 13:15:33 +01:00
Toon Claes 082cc12225 Fix failing spec with orphaned namespace 2019-01-11 15:36:57 +01:00
Stan Hu 618875c58c Fix duplicate disk path in Backfill ProjectRepos
On GitLab.com, we saw numerous duplicate disk entry inserts because
the migration was not taking the routes table into account. We now
implement this in the migration to be consistent.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/56061
2019-01-11 15:36:51 +01:00
Toon Claes b87dcc238a Remove backfill migration for legacy projects
We've found some problems with the backgroung migration:
BackfillLegacyProjectRepositories

See https://gitlab.com/gitlab-org/gitlab-ce/issues/56061

The migration was disabled to run on production:
https://gitlab.com/gitlab-com/gl-infra/infrastructure/issues/5906

So to overcome it's not being run anywhere, just remove it.

Whenever all problems in BackfillLegacyProjectRepositories are fixed
we'll create a new migration (with a different timestamp) to have it
run.
2019-01-10 16:45:14 +01:00
Kamil Trzciński 0103d5be96 Add config_options|variables to BuildMetadata
These are data columns that store runtime configuration
of build needed to execute it on runner and within pipeline.

The definition of this data is that once used, and when no longer
needed (due to retry capability) they can be freely removed.

They use `jsonb` on PostgreSQL, and `text` on MySQL (due to lacking
support for json datatype on old enough version).
2019-01-04 16:38:17 +01:00
Douglas Barbosa Alexandre 4a132952db
Extract a shared example for legacy and hashed storage migrations tests 2018-12-18 21:35:14 -02:00
Douglas Barbosa Alexandre 754f66113e
Backfill project_repositories for legacy storage projects
Adds a background migration that will ensure all projects that
are on legacy storage have a row in `project_repositories`.
2018-12-18 21:13:38 -02:00
Semyon Pupkov 3c2a6be04d Fix warning: already initialized constant STATUSES
spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb:9: warning: already initialized constant STATUSES
spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb:9: warning: previous definition of STATUSES was here
2018-12-13 12:01:47 +05:00
Douwe Maan 5a727a4d36 Merge branch 'osw-update-mr-metrics-with-events-data' into 'master'
Populate MR metrics with events table information (migration)

Closes #41587

See merge request gitlab-org/gitlab-ce!23564
2018-12-10 09:39:07 +00:00
Douglas Barbosa Alexandre 8c9e692095
Fill project_repositories for hashed storage 2018-12-06 22:57:56 -02:00
Oswaldo Ferreira 4f6999fa26 Populate MR metrics with events table information (migration) 2018-12-06 22:08:38 -02:00
Toon Claes 5237a55d62
Fill project_repositories for hashed storage
This adds a background migration that will ensure all projects that
are on hashed storage have a row in `project_repositories`.

Related issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/48527
2018-12-06 21:04:41 -02:00
Grzegorz Bizon 239a4f7264 Use plaintext token when migration is not complete 2018-12-03 14:29:51 +01:00
Grzegorz Bizon 0b8a2779e7 Merge branch 'master' into fix/gb/encrypt-runners-tokens
* master: (243 commits)

Conflicts:
	db/schema.rb
	lib/gitlab/import_export/import_export.yml
2018-11-28 13:14:04 +01:00
Toon Claes f35ff1ea48 Ensure all Routables have a parent
Or otherwise do not try to write repo config.
2018-11-27 22:48:55 +01:00
Toon Claes 4711100164 Always run CleanUp before writing the git config 2018-11-27 22:48:55 +01:00
Toon Claes 220208c051 Retry the failing projects 2018-11-27 22:48:55 +01:00
Nick Thomas 6ddefe7cad
Correctly handle data-loss scenarios when encrypting columns
If the EncryptColumns background migration runs in a sidekiq with a
stale view of the database schema, or when the purported destination
columns don't actually exist, data loss can result. Attempt to work
around these issues by reloading schema information before running
the migration, and raising errors if the model reports that any of its
source or destination columns are missing.
2018-11-27 18:24:18 +00:00
Grzegorz Bizon 1143411ae8 Reduce Sidekiq signature of scheduled tokens migration 2018-11-23 13:28:29 +01:00
Grzegorz Bizon 9ab50c86a9 Add specs for runners tokens encryption migration 2018-11-23 11:55:38 +01:00
Mayra Cabrera 477d2e1a47 Add background migration for Kubernetes Namespaces 2018-11-06 12:23:00 +00:00
George Tsiolis 733ae94921 Fix typos in comments and specs 2018-11-01 08:59:20 +02:00
Jan Provaznik 5b0b73d922 Merge branch 'security-redact-links' into 'master'
[master] Redact unsubscribe links in issuable texts

See merge request gitlab/gitlabhq!2528
2018-10-29 16:10:32 +00:00
Imre Farkas b9652d8e4d [master] Persist only SHA digest of PersonalAccessToken#token 2018-10-29 16:06:45 +00:00
Jan Provaznik c1c1496405 Redact unsubscribe links in issuable texts
It's possible that user pastes accidentally also unsubscribe link
which is included in footer of notification emails. This unsubscribe
link contains personal token which attacker then use to act as the
original user (e.g. for sending comments under his/her identity).
2018-10-23 21:20:20 +02:00
Alejandro Rodríguez a99bf447a2 Remove Gitlab::Git::Repository#rugged and Gollum code
Cleanup code, and refactor tests that still use Rugged. After this, there should
be no Rugged code that access the instance's repositories on non-test
environments. There is still some rugged code for other tasks like the
repository import task, but since it doesn't access any repository storage path
it can stay.
2018-10-02 16:34:28 -03:00
Nick Thomas 466371a06c
Migrate sensitive web hook data in the background 2018-10-01 15:34:16 +01:00
Matija Čupić eac01d4f65
Reorganize background_migration specs
This also adds specs for 3 distinct situations:

2. When there is an unknown pipeline with just a build
3. When there is an unknown pipeline with no statuses
1. When there is an unknown pipeline with a build and a status
2018-09-29 00:13:23 +02:00
Matija Čupić c0716421fa
Refactor pipeline id ordering 2018-09-28 23:56:56 +02:00
Matija Čupić 0b7ff7c57f
Restyle background_migration spec 2018-09-28 23:47:55 +02:00
Matija Čupić 3e309ea70d
Refactor migration specs using ActiveRecord models 2018-09-28 01:40:40 +02:00
Matija Čupić 4de93b6a3e
Refactor external_pipelines query 2018-09-27 19:28:24 +02:00
Matija Čupić 2122a7707c
Add frozen string literal comment 2018-09-25 21:09:14 +02:00
Matija Čupić c2fbd8677c
Add background migration to fill pipeline source 2018-09-25 21:09:14 +02:00
Shinya Maeda ffa2637a0c Squashed commit of the following:
commit 8ea114e5c349ad23f7293cf8141798aa6c9384e3
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Fri Aug 17 13:32:14 2018 +0900

    Remove redandant parentheses

commit 3eb34f9305980701f0c1528f95fd615c1ca4d50d
Merge: 24308e4d1da 46494f46a1
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Fri Aug 17 13:22:05 2018 +0900

    Merge branch 'master-ce' into add-background-migration-for-legacy-traces

commit 24308e4d1dab6fbf8437afc56fff7b83cc7ce534
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 16:39:20 2018 +0900

    Fix spec

commit 5a63312d1b36296440da6a874bb667b7dc06869c
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 14:46:59 2018 +0900

    Format SQL in MIgrateLegacyArtifacts class

commit 8894196d2aa2f9bf153cb03fef9603858478db70
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 14:31:18 2018 +0900

    Remove unnecessary index

commit d9753ac058fc48c8f594ee90064f675f7a869b17
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 14:24:20 2018 +0900

    Decouple pertial index to a different migration file

commit 1ce4a9bec6a4f0f981f4139c1a146ca7d887e6ba
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 14:14:03 2018 +0900

    Simplified adding file_location column

commit 47b101fae914470dc4d048f6d33c509ec8270656
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 14:11:42 2018 +0900

    Remove add_column_with_default

commit 80ec4f774f50bbf66e65f283f8fba541c6334e1c
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 14:02:46 2018 +0900

    Simplified job_artifact_uploader

commit d835dab36e85f4fc7a7d0735ede0f0ea081178bf
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 13:59:03 2018 +0900

    Elaborate comments on `file_location`

commit 6e78f23683bbae1372783f19179206369d7fbae7
Merge: fcef07ef361 79fdfec51f
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Aug 16 13:39:28 2018 +0900

    Merge branch 'master-ce' into add-background-migration-for-legacy-traces

commit fcef07ef361080823432071722897321b2dd8354
Merge: 1eac3083194 bf9fd9c3fc
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Fri Jul 6 21:46:22 2018 +0900

    Merge branch 'master' into add-background-migration-for-legacy-traces

commit 1eac30831947cceec7610be6acc7d3bffadaf617
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Fri Jul 6 21:45:49 2018 +0900

    Use SQL instead of strip_heredoc

commit 08b17e517722e1e4ef8b60e753d53d697953a293
Merge: c0f48ff243d dc478a8243
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Jul 5 23:20:37 2018 +0900

    Merge branch 'master' into add-background-migration-for-legacy-traces

commit c0f48ff243ddbe8af6c63aa0170538717191f44a
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Jul 5 17:37:40 2018 +0900

    Fix flaky spec

commit d082dab7cb456f9b31e76f49d1db46b606ba13ce
Merge: 8d6059d08ff 116955c453
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Jul 5 17:35:06 2018 +0900

    Merge branch 'master' into add-background-migration-for-legacy-traces

commit 8d6059d08fffaa99689afe32b66d93b538fb62f2
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jul 4 21:39:09 2018 +0900

    Fix static analysys failure

commit c4bdb18d582c520723a73c4c90c522332fa94d36
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jul 4 20:16:16 2018 +0900

    Cleanup spec

commit 469e826429feb6a8ce66eb5d5e087f7182eb8813
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jul 4 19:09:12 2018 +0900

    Clean up migrate_legacy_artifacts spec

commit dee84be650ad5afc9f18ac05eccb0736e4b1c121
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jul 4 18:13:19 2018 +0900

    Set default value at the database level

commit b32cb2f8a7e03238cf97d90f9e05ca11b5c8b687
Merge: 83f7c970ad8 4c1a2a9b99
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jul 4 17:06:02 2018 +0900

    Merge branch 'master' into add-background-migration-for-legacy-traces

commit 83f7c970ad821f1b52999398070facf59f320479
Merge: 823629c1d9a 275fbf24b1
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jul 3 18:39:36 2018 +0900

    Merge branch 'master' into add-background-migration-for-legacy-traces

commit 823629c1d9aac5e7dcfb6bc393557a72ca3370b4
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jul 2 14:59:54 2018 +0900

    Decouple background migrations of filling nullified file_locations

commit 42ec60e8a74478c62962f5c66abfbe3e908d9e49
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jul 2 14:46:38 2018 +0900

    Unify partial index migrations

commit c145e9306419f704b14e2a92f51a9cf2d105f7e7
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jul 2 14:24:14 2018 +0900

    Make file_location non-null values

commit a442456f6a83327b2736f49b9522084b5675d129
Merge: c2cafa1051c 3cf683629e
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jul 2 13:16:29 2018 +0900

    Merge branch 'master' into add-background-migration-for-legacy-traces

commit c2cafa1051cb7a4582c93b653e0ef3506ee11af4
Merge: 8e5f4f88410 e38db19659
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Jun 28 17:13:48 2018 +0900

    Merge branch 'master' into add-background-migration-for-legacy-traces

commit 8e5f4f884107c0f574545f043fbacea2698ef3a4
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 27 18:54:03 2018 +0900

    Remove unneccesary specs

commit 86c1c68b1000770fcf8086fa71801b332fb6df5a
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 27 18:05:36 2018 +0900

    Add a partial index on ci_builds.id for legacy artifacts search

commit 70aa08c89bb6cd9b12d38b64cbf1838fb919c30f
Merge: 3780112298 292cf66890
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 27 17:15:33 2018 +0900

    Merge branch 'master' into add-background-migration-for-legacy-traces

commit 3780112298
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu Jun 7 14:18:00 2018 +0900

    Clean up migration code. Defining migration custom class in  only post migration file which requires it for each_batch

commit 5cfe73318b
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 23:57:03 2018 +0900

    Remove indexing for mysql. with_legacy_artifacts targets all archive rows. Enhance tests.

commit 696c030d4a
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 19:59:35 2018 +0900

    Fix static analysys. Split methods. Use `file_types`

commit 86217c650c
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 18:55:15 2018 +0900

    Use raw sql for better readability

commit df449404cb
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 17:47:39 2018 +0900

    Revert unneccesary change

commit 764977a1d9
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 16:09:14 2018 +0900

    Remove AddIndexToCiBuildsArtifactsFile. Add temporary index in background migration class.

commit 7728ab3f9d
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 15:28:50 2018 +0900

    Try to explicitly separate with postgresql and mysql for addin index

commit b95b47b965
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 14:29:18 2018 +0900

    Dry up code by referring `BackgroundMigration` namespace. Use `BETWEEN` raw SQL to make the edge case explicit.

commit 5b404e46e2
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 14:15:37 2018 +0900

    Use `store_path` to make spec more explicit

commit 9f80de8e5a
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 14:03:26 2018 +0900

    Use length not limit

commit f78503f3e5
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Wed Jun 6 13:48:51 2018 +0900

    Add length back for indexing

commit b96a57d5e5
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 12:42:14 2018 +0000

    Update schema.rb

commit 9c25acc975
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 12:40:48 2018 +0000

    Add the guard clause in #down method too

commit 2bd5dadbd1
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 19:41:08 2018 +0900

    Add a gurad caluse to block adding concurrent index for mysql

commit 9a5e12768e
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 19:20:33 2018 +0900

    Specify length of index in schema.rb manually for resolving mysql errors

commit c0ec68af02
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 17:51:40 2018 +0900

    Separate add_concurrent_index by database type

commit b5f4ed37d9
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 17:30:19 2018 +0900

    Fix length size to use TEXT

commit b38b56056f
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 17:20:35 2018 +0900

    Fix schema version for background migration spec

commit 32c48ef7cb
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 16:22:00 2018 +0900

    Specify length of indexed column. (This is neccessary for TEXT type)

commit a2e975f2e6
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue Jun 5 15:13:42 2018 +0900

    Fix spec; migrate_legacy_artifacts_to_job_artifacts_spec.rb

commit c78c1e3f12
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jun 4 20:15:23 2018 +0900

    Separate add_concurrent_index migration from background migration

commit ad55e33bc2
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jun 4 19:59:14 2018 +0900

    Revert "Remove index_exists? guard"

    This reverts commit d76807838cf06e023b608c16426174a752a8ccf5.

commit b2693be76f
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jun 4 17:11:47 2018 +0900

    Remove index_exists? guard

commit a2eb053d3b
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jun 4 15:41:54 2018 +0900

    Wrap insertion and deletion in a single transaction

commit d4bb2c709c
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon Jun 4 15:08:17 2018 +0900

    Add temporary index to ci_builds.artifacts_file to speed up SELECT query

commit 33d62be9ee
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon May 28 17:31:38 2018 +0900

    Add test for legacy path proxy

commit 57ab71a05b
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon May 28 15:59:36 2018 +0900

    Optimize queries. Add some tests for filtering logic.

commit 8f24dfaac7
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Mon May 28 15:30:38 2018 +0900

    Fix static analysis

commit ccc60ddd60
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu May 24 16:51:59 2018 +0900

    Add changelog

commit fdbdb07a40
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu May 24 16:50:55 2018 +0900

    Add spec for migrations

commit 04886af872
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu May 24 14:48:31 2018 +0900

    Revise comments

commit 55bcbee057
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Thu May 24 14:40:29 2018 +0900

    Revise comments

commit db6628675a
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 17:27:12 2018 +0900

    Add spec base (Not finished)

commit e92dcc392e
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 17:26:49 2018 +0900

    Added artifacts_metadata_store to remove in background migration

commit 91388399d8
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 17:26:20 2018 +0900

    Add a condition to exclude jobs which have job_artifacts already

commit e084ce1181
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 16:51:15 2018 +0900

    Clean up migrate_legacy_artifacts.rb (Fix static analysys)

commit ca4e5d33e2
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 16:32:59 2018 +0900

    Remove the culcuration method of metadata size

commit eac4c75be9
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 16:11:16 2018 +0900

    Remove Gitlab::BackgroundMigration:: scope

commit 4a5ca96b62
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 16:09:09 2018 +0900

    Add limit to file_location column

commit 49ff3d9c98
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 16:05:22 2018 +0900

    Use size.to_i instead of if-condition

commit 526656e6ee
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 15 16:02:57 2018 +0900

    Rename current_path to hashed_path

commit 8e6faca790
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 8 16:53:43 2018 +0900

    Rename location_1/2 to current/legacy_path

commit 5034543255
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Tue May 1 21:44:10 2018 +0900

    Rename path_type to file_location. Fix JobArtifactUploader to look up correct file location.

commit 4f7e3503f1
Author: Shinya Maeda <shinya@gitlab.com>
Date:   Fri Apr 27 17:33:15 2018 +0900

    Add background migration for legacy artifacts

Add default_value_for to file_location column

Set file_location explicityly with default_values_for

Add file_location to factory

Remove tests of default_values_for

Set file_location nil as default
2018-08-27 09:12:02 +02:00
Yorick Peterse 9606dbbb03
Whitelist existing destroy_all offenses
This whitelists all existing places where we use "destroy_all".
2018-08-16 17:29:37 +02:00
Jarka Kadlecová 8338f9b89b Remove todos of users without access to targets migration 2018-08-07 17:34:59 +02:00
Oswaldo Ferreira dffe984d94 Add :sidekiq group to cleanup redis in after callback 2018-07-24 12:23:33 -03:00
Jacob Vosmaer (GitLab) 5c651daa97 Remove unreachable Git code 2018-07-18 11:12:57 +00:00
Oswaldo Ferreira 659aeba43c Use schedulers and delete diff files upon deadtuples check 2018-07-10 10:25:48 -03:00
Oswaldo Ferreira db0f150516 Reschedule DeleteDiffFiles until there is none left to remove 2018-07-10 09:43:58 -03:00
Oswaldo Ferreira 19966e7095 Wait postgresql vacuum of deadtuples on merge_request_diff_files deletion 2018-07-10 09:43:58 -03:00
Oswaldo Ferreira 4455904bc1 Add 1000 files per minute deletion ratio on scheduler 2018-07-10 09:43:58 -03:00
Oswaldo Ferreira e66535e840 Create a diff deletion worker scheduler to avoid long-running post-migration 2018-07-10 09:43:58 -03:00
Sean McGivern 3acf7ba9ca Revert "Temporarily remove MR diffs removal migration"
This reverts commit 15ec6a13eb.
2018-07-10 09:43:57 -03:00
Lin Jen-Shin 4ee08b77bc Updates from `rubocop -a` 2018-07-09 21:13:08 +08:00
Jan Provaznik 1f320d1c50 Added tests for MRs 2018-07-05 10:12:15 +02:00
Jan Provaznik e33c95cf96 Migration which fixes cross-project label references 2018-07-03 21:21:36 +02:00
Sean McGivern 15ec6a13eb Temporarily remove MR diffs removal migration
We will re-add this with a more efficient bulk scheduling method.
2018-07-03 12:02:04 +01:00
Oswaldo Ferreira 31d8464f67 Schedule workers to delete non-latest diffs in post-migration 2018-06-28 10:58:32 -03:00
Jarka Kadlecová fa36101a7f Use data_source_exists? instead of table_exists?
Use data_source_exists? where possible instead of table_exists? in order to be Rails5 compatible
2018-06-14 08:39:43 +02:00
Shinya Maeda 8f1f73d4e3 Fix typo in spec. Add a test for the case of when trace is stored in database 2018-06-04 14:28:21 +09:00
Shinya Maeda bcd664f53a Fix specs. Rename migration file name which was conflicted with background migration's. 2018-06-04 14:14:20 +09:00
Shinya Maeda 0d00d02e84 Directly refer application code from migration code 2018-06-04 14:14:20 +09:00
Shinya Maeda 89b4304f12 Add background migrations to arhive legacy traces 2018-06-04 14:14:20 +09:00
Jacob Vosmaer (GitLab) edb9db37ed Add "deny disk access" Gitaly feature (tripswitch) 2018-06-01 11:56:29 +00:00
Tiago Botelho bddbcaefc2 Backports every CE related change from ee-44542 to CE 2018-05-04 17:33:26 +02:00
Grzegorz Bizon 0fd0b64be6 Use stages position column to track stage index 2018-05-01 14:30:44 +02:00
Grzegorz Bizon c9dc51111d Rename stage index column name to priority column 2018-04-24 15:48:10 +02:00
Grzegorz Bizon fc6ec8adab Remove empty line from stages index migration specs 2018-04-24 11:07:37 +02:00
Grzegorz Bizon 02999234d4 Add background migration that migrates stages indices 2018-04-24 11:07:37 +02:00
Douwe Maan 52967b107b
Merge branch 'jej/mattermost-notification-confidentiality-10-6' into 'security-10-6'
[10.6] Prevent notes on confidential issues from being sent to chat

See merge request gitlab/gitlabhq!2366
# Conflicts:
#	app/helpers/services_helper.rb
2018-04-05 08:41:56 +02:00
Grzegorz Bizon 9afabee3e0 Do not use STI mechanisms when migrating pipeline stages 2018-03-29 12:12:22 +02:00
Jan Provaznik 7b22381603 Reschedule commits_count background migration
We still have >100K unmigrated MergeRequestDiffs
which don't have commits_count set yet (see
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/17567#note_61904891)

This migration re-schedules the original background migration.
To assure that records are not processed twice, records with
commits_count set are skipped.

Related to #41698 and !17567
2018-03-09 09:56:49 +01:00
Grzegorz Bizon 011ddb51b4 Merge branch 'master' into 'backstage/gb/build-stages-catch-up-migration'
# Conflicts:
#   db/schema.rb
2018-02-22 12:09:27 +00:00
Michael Kozono 3f017f07ee Prefer `table` helper in migration specs 2018-02-20 12:09:50 -08:00
Michael Kozono a02fed20d0 Move TrackUntrackedUploadsHelpers
into MigrationsHelpers namespace just for organization.
2018-02-20 12:09:50 -08:00
Michael Kozono 4b49eb495d Explicitly reference redefined models
And move UntrackedFile into PopulateUntrackedUploadsDependencies, and move its spec into its own file.
2018-02-20 12:09:49 -08:00
Michael Kozono 293c51e399 Remove more BG migration spec dependencies
For the `PrepareUntrackedUploads` spec.
2018-02-16 14:40:53 -08:00
Michael Kozono 348c60d9be Remove codebase dependencies from a BG migration
Specifically, `PopulateUntrackedUploads` and its spec.
2018-02-16 14:40:52 -08:00
Grzegorz Bizon d9a8d9f3de Merge branch 'master' into 'backstage/gb/build-stages-catch-up-migration'
Conflicts:
   db/schema.rb
2018-02-15 09:15:10 +00:00
Grzegorz Bizon 6cb5b7c872 Recover from unique constraint violation in stages migration 2018-02-15 10:13:20 +01:00
Grzegorz Bizon 378b2bad11 Migrate pipeline stages in batches instead of single row 2018-02-14 13:59:16 +01:00
Michael Kozono 080dba4a7e Avoid dropping tables in test
And use :migration tag to use deletion strategy, and to avoid caching tables, and to lock into a particular schema.

Attempting to fix intermittent spec errors `PG::UndefinedTable: ERROR:  relation "public.untracked_files_for_uploads" does not exist`.
2018-02-14 12:31:16 +01:00
Douwe Maan c133f1a748 Merge branch 'mk-fix-no-untracked-upload-files-error' into 'master'
Resolve "PrepareUntrackedUploads PostgreSQL syntax error"

Closes #42881

See merge request gitlab-org/gitlab-ce!17019
2018-02-13 12:50:12 +00:00
Michael Kozono 4e6a8eaab6 Dry up spec 2018-02-12 10:44:15 -08:00
Michael Kozono 67d310a1a6 Fix orphan temp table untracked_files_for_uploads 2018-02-12 10:44:15 -08:00
Michael Kozono f917fc5d76 Fix last batch size equals max batch size error 2018-02-12 10:44:15 -08:00
Rémy Coutable d1eac99b92 Use the :migration metadata in migration specs
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-02-12 16:54:21 +01:00
Stan Hu 4af914c25c Disable caching of tables for migration spec that drops a temporary table
This is to fix job failures, such as https://gitlab.com/gitlab-org/gitlab-ee/-/jobs/51409392.
2018-02-12 16:54:21 +01:00
Grzegorz Bizon 6c7422fbcc Merge branch 'master' into backstage/gb/build-stages-catch-up-migration
* master: (1480 commits)

Conflicts:
	db/schema.rb
2018-02-09 13:53:20 +01:00
Sean McGivern 5edd94ae75 Merge branch '40744-hashed-storage-specs' into 'master'
Use hashed storage in the specs

Closes #40744

See merge request gitlab-org/gitlab-ce!15681
2018-02-08 17:11:43 +00:00
Nick Thomas 6b0c6e69e1
Use hashed storage in the specs 2018-02-07 13:40:46 +00:00
Rémy Coutable 0c62b49484
Reset column information after the schema is migrated in MigrationsHelpers.schema_migrate_up!
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-02-07 11:38:50 +01:00
Rémy Coutable e39031deca
Reset Project's column information in spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_spec.rb
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-02-06 18:50:01 +01:00
Micaël Bergeron e3d32e8a26 fix specs 2018-02-01 12:14:46 -05:00
Micaël Bergeron 2057a6acde port of 594e6a0a625^..f74c90f68c6 2018-02-01 12:14:46 -05:00
Nick Thomas 93ea3234df
Use the DatabaseCleaner 'deletion' strategy instead of 'truncation' 2018-01-24 17:25:55 +00:00
Rémy Coutable d8eb961d0b
Fix a migration spec messing up the MergeRequestDiff DB schema
Signed-off-by: Rémy Coutable <remy@rymai.me>
2018-01-23 17:42:37 +01:00
Sean McGivern 9fd6440d4a Prevent background migration spec from polluting later models
If the schema changes after 20171114162227 for any of these models, and specs
after this one use factories, then those factories will use the models with
outdated column information cached.

We shouldn't really use factories in migration specs, but this is a special case
because there is a lot of git-related setup code in the model that would be
painful to copy to the migration. Instead, we just manually reset the column
information for the models we could pollute.
2018-01-16 10:58:07 +00:00
Jan Provaznik e6a1db6d9e Denormalize commits count for merge request diffs
For each MR diff an extra 'SELECT COUNT()' is executed
to get number of commits for the diff. Overall time to get counts for
all MR diffs may be quite expensive. To speed up loading of MR info,
information about number of commits is stored in a MR diff's extra column.

Closes #38068
2018-01-10 20:40:02 +01:00
Grzegorz Bizon 2d2f9e5159 Do not attempt to migrate legacy pipeline stages 2018-01-06 14:44:43 +01:00
Grzegorz Bizon 1ab0ffe383 Update background stages migration timestamp 2018-01-06 14:21:45 +01:00
Grzegorz Bizon cd6d0dbd5f Migrate a build stage completely in a background migration 2018-01-06 14:09:59 +01:00
Jarka Kadlecová 153ea18301 Refactor matchers for background migrations 2018-01-05 13:40:31 +01:00
Douwe Maan d2891822e7 Merge branch 'mk-no-op-delete-conflicting-redirects' into 'master'
Prevent excessive DB load due to faulty DeleteConflictingRedirectRoutes background migration

See merge request gitlab-org/gitlab-ce!16205
2018-01-04 15:57:45 +00:00
Yorick Peterse 51562aafc7 Merge branch 'sh-validate-path-project-import' into 'master'
Avoid leaving a push event empty if payload cannot be created

See merge request gitlab-org/gitlab-ce!16214
2018-01-04 12:17:20 +00:00
Stan Hu 57dc5a521b Avoid leaving a push event empty if payload cannot be created
If the payload cannot be created for some reason, we could be left with a nil
push event payload, which causes Error 500s when viewing the dashboard. Guard
against this error and log when it happens.

Avoids problems seen in #38823
2018-01-03 22:49:02 -08:00
Michael Kozono f635277228 Make DeleteConflictingRedirectRoutes no-op
Both the post-deploy and background migration.
2018-01-03 12:23:20 -08:00
Oswaldo Ferreira bf8c20729b Cache merged and closed events data in merge_request_metrics table 2018-01-02 17:45:25 -02:00
Rémy Coutable 4af9d592c5 Replace factory_girl_rails with factory_bot_rails
I've followed the [upgrade guide](https://github.com/thoughtbot/factory_bot/blob/4-9-0-stable/UPGRADE_FROM_FACTORY_GIRL.md) and ran these two commands:

```
grep -e FactoryGirl **/*.rake **/*.rb -s -l | xargs sed -i "" "s|FactoryGirl|FactoryBot|"
grep -e factory_girl **/*.rake **/*.rb -s -l | xargs sed -i "" "s|factory_girl|factory_bot|"
```

Signed-off-by: Rémy Coutable <remy@rymai.me>
2017-12-14 15:01:55 +01:00
Douwe Maan 58017e17cc Merge branch 'bvl-backport-migration-spec-changes-to-ce' into 'master'
Create models directly in migration specs

See merge request gitlab-org/gitlab-ce!15874
2017-12-13 14:16:22 +00:00
Michael Kozono acde0e3f5c Fix spec by avoiding monkeypatching 2017-12-12 14:25:33 -08:00
Bob Van Landuyt 5ac98f9315 Create models directly in migration specs
Instead of using the factories. Since the factories might be using
columns that aren't available in the schema at version the particular
spec is running in.
2017-12-12 09:44:21 +01:00
Michael Kozono 24c348f0d1 Fix specs for MySQL 2017-12-06 12:20:28 -08:00
Michael Kozono 03cba8c0f1 Fix specs after rebase
Later migrations added fields to the EE DB which were used by factories which were used in these specs.

And in CE on MySQL, a single appearance row is enforced.

The migration and migration specs should not depend on the codebase staying the same.
2017-12-06 09:34:25 -08:00
Michael Kozono 869d08b581 Process normal paths in batch containing bad paths 2017-12-05 14:57:58 -08:00
Michael Kozono 77be7efcf5 Guarantee all IDs are included 2017-12-05 11:19:23 -08:00
Michael Kozono dd4b35f864 Fix test for MySQL 2017-12-01 15:26:42 -08:00
Michael Kozono 473ddfb453 Don’t recreate deleted uploads 2017-12-01 15:26:42 -08:00
Michael Kozono 908aacddda Filter existing uploads with one query 2017-12-01 15:26:42 -08:00
Michael Kozono 7549d17f72 Refactor 2017-12-01 15:26:41 -08:00
Michael Kozono 67b58ffdc3 Get rid of tracked field
It makes a debugging slightly easier, but is not necessary, and is a waste of resources.
2017-12-01 15:26:41 -08:00
Michael Kozono edb5cac46c Use bulk inserts 2017-12-01 15:26:41 -08:00
Michael Kozono f5fa398724 Attempt to fix spec in CI 2017-12-01 15:26:41 -08:00
Michael Kozono 87529ce582 Move temp table creation into the prepare job
* Hopefully fixes spec failures in which the table doesn’t exist
* Decouples the background migration from the post-deploy migration, e.g. we could easily run it again even though the table is dropped when finished.
2017-12-01 15:26:41 -08:00
Michael Kozono 7fd2643419 Fix Rubocop offenses 2017-12-01 15:26:41 -08:00
Michael Kozono dd8680a7ae Drop temporary tracking table when finished 2017-12-01 15:26:41 -08:00
Michael Kozono d530085685 Refactor specs 2017-12-01 15:26:41 -08:00
Michael Kozono 3dc0b118ec Store paths relative to CarrierWave.root
So the path on source installs cannot be too long for our column.

And fix the column length test since Route.path is limited to 255 chars, it doesn’t matter how many nested groups there are.
2017-12-01 15:26:41 -08:00
Michael Kozono 1ba4d417fe Clean up after test 2017-12-01 15:26:41 -08:00
Michael Kozono c77a353dca Remove unnecessary clearing
Since duplicate inserts are now ignored.
2017-12-01 15:26:41 -08:00
Michael Kozono 1807bc1646 Reword test 2017-12-01 15:26:41 -08:00
Michael Kozono a210cb6b82 Rename table to untracked_files_for_uploads 2017-12-01 15:26:41 -08:00
Michael Kozono 2ab3031bd3 Refactor, no change in behavior 2017-12-01 15:26:41 -08:00
Michael Kozono ffbaf19fe8 Fix Rubocop offenses 2017-12-01 15:26:41 -08:00
Michael Kozono 13e0ee3735 Test batch processing 2017-12-01 15:26:40 -08:00
Michael Kozono 1bae010b63 Calculate checksums
by copy-pasting in the whole `Upload` class.

Also, fix `Namespace` `model_type` (it should not be `Group`).
2017-12-01 15:26:40 -08:00
Michael Kozono 3a0ad99d59 Add untracked files to uploads 2017-12-01 15:26:40 -08:00
Michael Kozono 8315c66a56 Kick off follow up background migration jobs
To process the unhashed_upload_files table.
2017-12-01 15:26:40 -08:00
Michael Kozono b6ea41d130 Find and store unhashed upload file paths 2017-12-01 15:26:40 -08:00
Yorick Peterse 124fa93a8a Merge branch 'remove-mr-diff-serialised-columns' into 'master'
Remove serialised diff and commit columns

Closes #39533

See merge request gitlab-org/gitlab-ce!15582
2017-11-29 13:33:06 +00:00
Bob Van Landuyt 4c4109e1b9 Create fork networks for forks for which the source was deleted.
That way we can join forks-of-forks into the same network even if
their original source was deleted.

Consider the following:

  `awesome-oss/badger` is forked to `coolstuff/badger`, which is
  forked to `user-a/badger` which in turn is forked to
  `user-b/badger`.

  When `awesome-oss/badger` is deleted, we will now create a fork
  network with `coolstuff/badger` as the root. The `user-a/badger`
  and `user-b/badger` projects will be added to the network.
2017-11-29 12:11:48 +01:00
Sean McGivern 4ebbfe5d3e Remove serialised diff and commit columns
The st_commits and st_diffs columns on merge_request_diffs historically held the
YAML-serialised data for a merge request diff, in a variety of formats.

Since 9.5, these have been migrated in the background to two new tables:
merge_request_diff_commits and merge_request_diff_files. That has the advantage
that we can actually query the data (for instance, to find out how many commits
we've stored), and that it can't be in a variety of formats, but must match the
new schema.

This is the final step of that journey, where we drop those columns and remove
all references to them. This is a breaking change to the importer, because we
can no longer import diffs created in the old format, and we cannot guarantee
the export will be in the new format unless it was generated after this commit.
2017-11-28 16:13:40 +00:00
Stan Hu 5cecff893d Convert migration to populate latest merge request ID into a background migration
This is to smear updates over a few hours to avoid causing excessive
replication lag as seen in https://gitlab.com/gitlab-com/infrastructure/issues/3235.
2017-11-17 10:23:48 +00:00
Bob Van Landuyt f961744bde Isolate the fork network background migrations
Before the `PopulateForkNetworksRange` spec would also call the
`CreateForkNetworkMemberships` which we would count on in the spec.

With this, I'm isolating that, and counting only records created in
this particular migration instead.
2017-11-15 10:13:57 +01:00
Bob Van Landuyt aaf18bb8c8 Don't try to create fork network memberships for forks of forks
In case the root project of a Fork-of-fork is deleted, the ForkNetwork
and the membership for that fork network is never created. In this
case we shouldn't try to create the membership, since the parent
membership will never be created.

This means that these fork networks will be lost.
2017-11-14 11:19:19 +01:00
Sean McGivern 9245bfc293 Handle null serialised commits in background migration
This is already handled for diffs, but not commits.
2017-10-17 12:15:40 +01:00
Yorick Peterse f277fa1409 Merge branch 'bvl-fork-network-migrations' into 'master'
Create fork networks for root projects that are deleted

Closes #38905

See merge request gitlab-org/gitlab-ce!14752
2017-10-09 12:33:35 +00:00
Rémy Coutable 781d2c22f4 Merge branch '37552-replace-js-true-with-js' into 'master'
Replaces `tag: true` into `:tag` in the specs

Closes #37552

See merge request gitlab-org/gitlab-ce!14653
2017-10-09 12:23:26 +00:00
Bob Van Landuyt 392e5df796 Don't create fork networks for root projects that are deleted 2017-10-09 08:44:23 +02:00
Michael Kozono 9ac732dda2 Add migration specs 2017-10-07 10:28:13 -07:00
Jacopo 0ce6785851 Replaces `tag: true` into `:tag` in the specs
Replaces all the explicit include metadata syntax in the specs (tag:
true) into the implicit one (:tag).
Added a cop to prevent future errors and handle autocorrection.
2017-10-07 13:57:54 +02:00
Bob Van Landuyt df7f530d84 Add a migration to populate fork networks
This uses the existing ForkedProjectLinks
2017-10-07 11:46:23 +02:00
Rubén Dávila 555f50b3e6 Add more specs. 2017-10-05 22:43:44 -05:00
Sean McGivern 1507ff8ab7 Make MR diff background migration less likely to time out
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.
2017-09-29 11:56:08 +01:00
Sean McGivern 917194153f Insert at most 1,000 rows at once in MR diff background migration
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`.
2017-09-29 11:00:19 +01:00
Michael Kozono f1e963bd89 Add specs for deleting conflicting redirects 2017-09-14 14:17:23 -07:00
Annabel Dunstone Gray 9b177bb7c9 Revert "Merge branch 'revert-f2421b2b' into 'master'"
This reverts merge request !14148
2017-09-11 15:44:42 +00:00
Rubén Dávila 52a2423e37 Revert "Merge branch '35012-navigation-add-option-to-change-navigation-color-palette' into 'master'"
This reverts merge request !13619
2017-09-08 14:48:44 +00:00
Sean McGivern f2421b2b97 Merge branch '35012-navigation-add-option-to-change-navigation-color-palette' into 'master'
Add option to change navigation color palette

Closes #35012

See merge request !13619
2017-09-07 15:56:00 +00:00
Sean McGivern 4ae8e20c9c Merge branch 'events-migration-cleanup' into 'master'
Finish migration to the new events setup

Closes #37241

See merge request !13932
2017-09-07 15:33:54 +00:00
Sean McGivern 1245cccf68 Use `table` helper in migration specs 2017-09-06 12:57:30 -05:00
Sean McGivern cd84ce1a1b Don't depend on user model in migration spec
The User model now has a default value for a field that didn't exist when these
migrations ran.
2017-09-06 12:56:22 -05:00
Yorick Peterse 235b105c91
Finish migration to the new events setup
This finishes the procedure for migrating events from the old format
into the new format. Code no longer uses the old setup and the database
tables used during the migration process are swapped, with the old table
being dropped.

While the database migration can be reversed this will 1) take a lot of
time as data has to be coped around 2) won't restore data in the
"events.data" column as we have no way of restoring this.

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/37241
2017-09-06 16:40:31 +02:00
Ashley Dumaine ef4b3a39bc Add functionality to collapse outdated diff comments regardless of discussion resolution 2017-09-06 10:07:46 +01:00
Kamil Trzciński e00e62c2c8 Merge branch 'backstage/gb/migrate-stages-statuses' into 'master'
Migrate CI/CD stages statuses

Closes #33453

See merge request !12584
2017-08-21 11:47:44 +00:00
Sean McGivern 34a859ee2a Fix MR diffs background migration when file modes are missing
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.
2017-08-18 13:02:30 +01:00
Grzegorz Bizon 3a1103fd91 Add specs for stage status background migration class 2017-08-17 12:56:09 +02:00
Grzegorz Bizon c76f8f3e8f Make it possible to provide schema version in tests 2017-08-16 13:05:18 +02:00
Bob Van Landuyt 2ea8442ff3 Move the personal snippet uploads from `system` to `-/system`
Update the markdown unconditionally since the move might have been
done before, but the markdown not updated.
2017-08-11 18:17:45 +02:00
Sean McGivern e80a893ff0 Merge branch 'split-events-into-push-events' into 'master'
Use a separate table for storing push events

See merge request !12463
2017-08-11 14:40:03 +00:00
Sean McGivern d2315054e6 Fix merge request diff deserialisation when too_large was absent
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.
2017-08-11 11:58:36 +01:00
Yorick Peterse 0395c47193
Migrate events into a new format
This commit migrates events data in such a way that push events are
stored much more efficiently. This is done by creating a shadow table
called "events_for_migration", and a table called "push_event_payloads"
which is used for storing push data of push events. The background
migration in this commit will copy events from the "events" table into
the "events_for_migration" table, push events in will also have a row
created in "push_event_payloads".

This approach allows us to reclaim space in the next release by simply
swapping the "events" and "events_for_migration" tables, then dropping
the old events (now "events_for_migration") table.

The new table structure is also optimised for storage space, and does
not include the unused "title" column nor the "data" column (since this
data is moved to "push_event_payloads").

== Newly Created Events

Newly created events are inserted into both "events" and
"events_for_migration", both using the exact same primary key value. The
table "push_event_payloads" in turn has a foreign key to the _shadow_
table. This removes the need for recreating and validating the foreign
key after swapping the tables. Since the shadow table also has a foreign
key to "projects.id" we also don't have to worry about orphaned rows.

This approach however does require some additional storage as we're
duplicating a portion of the events data for at least 1 release. The
exact amount is hard to estimate, but for GitLab.com this is expected to
be between 10 and 20 GB at most. The background migration in this commit
deliberately does _not_ update the "events" table as doing so would put
a lot of pressure on PostgreSQL's auto vacuuming system.

== Supporting Both Old And New Events

Application code has also been adjusted to support push events using
both the old and new data formats. This is done by creating a PushEvent
class which extends the regular Event class. Using Rails' Single Table
Inheritance system we can ensure the right class is used for the right
data, which in this case is based on the value of `events.action`. To
support displaying old and new data at the same time the PushEvent class
re-defines a few methods of the Event class, falling back to their
original implementations for push events in the old format.

Once all existing events have been migrated the various push event
related methods can be removed from the Event model, and the calls to
`super` can be removed from the methods in the PushEvent model.

The UI and event atom feed have also been slightly changed to better
handle this new setup, fortunately only a few changes were necessary to
make this work.

== API Changes

The API only displays push data of events in the new format. Supporting
both formats in the API is a bit more difficult compared to the UI.
Since the old push data was not really well documented (apart from one
example that used an incorrect "action" nmae) I decided that supporting
both was not worth the effort, especially since events will be migrated
in a few days _and_ new events are created in the correct format.
2017-08-10 17:45:44 +02:00
Alejandro Rodríguez e363fbf71a Move `deltas` and `diff_from_parents` logic to Gitlab::Git::Commit
This helps keep the abstraction layers simpler, and also keep the
interface of those methods consistent, in case of implementation
changes.
2017-08-07 23:33:40 -04:00
Sean McGivern f2d50af917 Migrate MR commits and diffs to new tables
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.
2017-08-03 13:20:26 +01:00
Robert Speicher 72a7b30c9f Change all `:empty_project` to `:project` 2017-08-02 17:47:31 -04:00
Bob Van Landuyt c156030ef9 Add a background migration to rename `uploads` in the uploads table 2017-07-18 15:38:54 +02:00