summaryrefslogtreecommitdiff
path: root/lib/gitlab/database
Commit message (Collapse)AuthorAgeFilesLines
* Reduce UPDATEs for background column type changesbackground-migration-fixYorick Peterse2018-01-181-2/+3
| | | | | | | | | | | | | | | Prior to this commit we would essentially update all rows in a table, even those where the source column (e.g. `issues.closed_at`) was NULL. This in turn could lead to statement timeouts when using the default batch size of 10 000 rows per job. To work around this we don't schedule jobs for rows where the source value is NULL. We also don't update rows where the source column is NULL (as an extra precaution) or the target column already has a non-NULL value. Using this approach it should be possible to update 10 000 rows in the "issues" table in about 7.5 - 8 seconds. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/42158
* Adds Rubocop rule for line break around conditionals🙈 jacopo beschi 🙉2018-01-112-0/+2
|
* Run background migrations with a minimum intervaldelay-background-migrationsYorick Peterse2018-01-051-0/+6
| | | | | | | | | | | | | | | This adds a minimum interval to BackgroundMigrationWorker, ensuring background migrations of the same class only run once every 5 minutes. This prevents a thundering herd problem where scheduled migrations all run at once due to their delays having been expired (e.g. as the result of a queue being paused for a long time). If a job was recently executed it's rescheduled with a delay that equals the remaining time of the job's lease. This means that if the lease expires in two minutes we only need to wait two minutes, instead of five. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/41624
* Use a background migration for issues.closed_atchange-issues-closed-at-background-migrationYorick Peterse2018-01-031-10/+111
| | | | | | | | | | | | | | | | | In a previous attempt (rolled back in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16021) we tried to migrate `issues.closed_at` from timestamp to timestamptz using a regular migration. This has a bad impact on GitLab.com and as such was rolled back. This commit re-implements the original migrations using generic background migrations, allowing us to still migrate the data in a single release but without a negative impact on availability. To ensure the database schema is up to date the background migrations are performed inline in development and test environments. We also make sure to not migrate that that doesn't need migrating in the first place or has already been migrated.
* Merge remote-tracking branch 'upstream/master' into no-ivar-in-modulesLin Jen-Shin2017-12-151-2/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * upstream/master: (671 commits) Make rubocop happy Use guard clause Improve language Prettify Use temp branch Pass info about who started the job and which job triggered it Docs: add indexes for monitoring and performance monitoring clearer-documentation-on-inline-diffs Add docs for commit diff discussion in merge requests sorting for tags api Clear BatchLoader after each spec to prevent holding onto records longer than necessary Include project in BatchLoader key to prevent returning blobs for the wrong project moved lfs_blob_ids method into ExtractsPath module Converted JS modules into exported modules spec fixes Bump gitlab-shell version to 5.10.3 Clear caches before updating MR diffs Use new Ruby version 2.4 in GitLab QA images moved lfs blob fetch from extractspath file Update GitLab QA dependencies ...
| * Consistently schedule Sidekiq jobsdm-application-workerDouwe Maan2017-12-051-2/+2
| |
* | Merge remote-tracking branch 'upstream/master' into no-ivar-in-modulesLin Jen-Shin2017-11-223-3/+26
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * upstream/master: (126 commits) Update VERSION to 10.3.0-pre Update CHANGELOG.md for 10.2.0 default fill color for SVGs ignore hashed repos (for now) when using `rake gitlab:cleanup:repos` Use Redis cache for branch existence checks Update CONTRIBUTING.md: Link definition of done to criteria Use `make install` for Gitaly setups in non-test environments FileUploader should check for hashed_storage?(:attachments) to use disk_path Set the default gitlab-shell timeout to 3 hours Update composite pipelines index to include "id" Use arrays in Pipeline#latest_builds_with_artifacts Fix blank states using old css Skip confirmation user api Custom issue tracker Revert "check for `read_only?` first before seeing if request is disallowed" add `#with_metadata` scope to remove a N+1 from the notes' API Fix promoting milestone updating all issuables without milestone Batchload blobs for diff generation check for `read_only?` first before seeing if request is disallowed use `Gitlab::Routing.url_helpers` instead of `Rails.application.routes.url_helpers` ...
| * Don't move project repository/attachments when using hashed storageBob Van Landuyt2017-11-202-3/+17
| | | | | | | | | | | | | | | | When a project is using hashed storage, the repositories and attachments wouldn't be saved on disk using the `full_path`. So the migration would not do anything. However: best to just skip moving when hashed storage is enabled.
| * Add computed update docs for update_column_in_batchesSean McGivern2017-11-171-0/+9
| |
* | Move ModuleWithInstanceVariables to Gitlab namespaceLin Jen-Shin2017-11-221-2/+2
| | | | | | | | | | And use .rubocop.yml to exclude paths we don't care, rather than using the cop itself to exclude.
* | Use StrongMemoize and enable/disable cops properlyLin Jen-Shin2017-11-181-3/+2
| |
* | Merge remote-tracking branch 'upstream/master' into no-ivar-in-modulesLin Jen-Shin2017-11-171-11/+19
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * upstream/master: (507 commits) Add dropdowns documentation Convert migration to populate latest merge request ID into a background migration Set 0.69.0 instead of latest for codeclimate image De-duplicate background migration matchers defined in spec/support/migrations_helpers.rb Update database_debugging.md Update database_debugging.md Move installation of apps higher Change to Google Kubernetes Cluster and add internal links Add Ingress description from official docs Add info on creating your own k8s cluster from the cluster page Add info about the installed apps in the Cluster docs Resolve "lock/confidential issuable sidebar custom svg icons iteration" Update HA README.md to clarify GitLab support does not troubleshoot DRBD. Update license_finder to 3.1.1 Make sure NotesActions#noteable returns a Noteable in the update action Cache the number of user SSH keys Adjust openid_connect_spec to use `raise_error` Resolve "Clicking on GPG verification badge jumps to top of the page" Add changelog for container repository path update Update container repository path reference ...
| * Fix TRIGGER checks for MySQLfix-mysql-grant-checkYorick Peterse2017-11-061-11/+19
| | | | | | | | | | | | | | | | | | This ensures we can check if the user has TRIGGER permissions without querying restricted tables. Thanks to Steve Norman (https://gitlab.com/stevenorman) for helping out with this merge request. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/38372
* | Add cop to make sure we don't use ivar in a moduleLin Jen-Shin2017-09-181-0/+1
|/
* Merge branch 'mk-delete-conflicting-redirects-mysql' into 'master'Douwe Maan2017-09-181-0/+88
|\ | | | | | | | | | | | | Clean up redirect routes that conflict with regular routes Closes #36229 See merge request gitlab-org/gitlab-ce!13783
| * Spread out the work a littleMichael Kozono2017-09-141-3/+43
| |
| * Extract helper for queuing background jobsMichael Kozono2017-09-141-0/+48
| |
* | Fix setting share_with_group_lockfix-share-with-group-lock-updateYorick Peterse2017-09-151-0/+16
|/ | | | | | | | | | | | | | | | | | | Prior to this commit running Namespace#force_share_with_group_lock_on_descendants would result in updating _all_ namespaces in the namespaces table, not just the descendants. This is the result of ActiveRecord::Relation#update_all not taking into account the CTE. To work around this we use the CTE query as a sub-query instead of directly calling #update_all. To prevent this from happening the relations returned by Gitlab::GroupHierarchy are now marked as read-only, resulting in an error being raised when methods such as #update_all are used. Fortunately on GitLab.com our statement timeouts appear to have prevented this query from actually doing any damage other than causing a very large amount of dead tuples. Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/37916
* Improve migrations using triggerscheck-trigger-permissions-mysqlYorick Peterse2017-08-292-4/+66
| | | | | | | | | | | | | | | | This adds a bunch of checks to migrations that may create or drop triggers. Dropping triggers/functions is done using "IF EXISTS" so we don't throw an error if the object in question has already been dropped. We now also raise a custom error (message) when the user does not have TRIGGER privileges. This should prevent the schema from entering an inconsistent state while also providing the user with enough information on how to solve the problem. The recommendation of using SUPERUSER permissions is a bit extreme but we require this anyway (Omnibus also configures users with this permission). Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36633
* Fix invalid default argument in migration helpersGrzegorz Bizon2017-08-231-1/+1
|
* Add Sidekiq migration helpers for migrating queuesGrzegorz Bizon2017-08-221-0/+14
|
* Fix Error 500s when attempting to destroy a protected tagStan Hu2017-08-201-0/+5
| | | | | | | | | | | | | | | Due to a missing `on_delete: :cascade`, users would hit the error that looked like: ``` PG::ForeignKeyViolation: ERROR: update or delete on table "protected_tags" violates foreign key constraint "fk_rails_f7dfda8c51" on table "protected_tag_create_access_levels" DETAIL: Key (id)=(1385) is still referenced from table "protected_tag_create_access_levels". : DELETE FROM "protected_tags" WHERE "protected_tags"."id" = 1385 ``` Closes #36013
* Add a foreign key to `merge_requests.head_pipeline_id`Grzegorz Bizon2017-07-181-1/+3
|
* Support multiple Redis instances based on queue typePaul Charlton2017-07-111-2/+2
|
* Added code for defining SHA attributesYorick Peterse2017-06-291-0/+34
| | | | | | These attributes are stored in binary in the database, but exposed as strings. This allows one to query/create data using plain SHA1 hashes as Strings, while storing them more efficiently as binary.
* Adjust for new static-analysis failuresbvl-rename-all-reserved-paths-mysqlBob Van Landuyt2017-06-271-2/+2
|
* Only do one query for updating routesBob Van Landuyt2017-06-271-5/+15
|
* Update routes directly by ID instead of filtering by pathBob Van Landuyt2017-06-261-4/+12
|
* Clear the cache for projects one-by-oneBob Van Landuyt2017-06-261-14/+16
|
* Add punctuation to log messagesBob Van Landuyt2017-06-263-4/+6
|
* Keep failed renames in redisBob Van Landuyt2017-06-261-1/+13
|
* Use the migration name as a key in redisBob Van Landuyt2017-06-261-1/+1
|
* Don't break rolling back when a namespace or project was renamedBob Van Landuyt2017-06-262-5/+7
|
* More logging so we know we have the rename in redisBob Van Landuyt2017-06-261-1/+5
|
* Revert renames from a migrationBob Van Landuyt2017-06-261-0/+5
|
* Revert namespace renamesBob Van Landuyt2017-06-262-1/+23
|
* Add methods to revert project renamesBob Van Landuyt2017-06-262-6/+49
|
* Track all renames in redisBob Van Landuyt2017-06-263-0/+9
|
* Merge branch 'master' into fix/gb/improve-updating-column-in-batches-helperGrzegorz Bizon2017-06-224-35/+35
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * master: (56 commits) File view buttons Don't reset the session when the example failed, because we need capybara-screenshot to have access to it Resolve "MR comment + system note highlight don't have the same width" Add feature spec for dashboard state filter tabs Wording of Mysql support. a new feature checklist and more elaborate documentation requirements Filter archived project in API v3 only if param present Revert to using links instead of buttons in Issuable Index tabs. Do not run the codeclimate job on docs-only changes Only show gray footer space if environment actions exist Migrate Gitlab::Git::Blob.find to Gitaly Backport filtered search lazy token consistent state fix Add a comment explaining how the branch clean up happens Fix Github::Representation::PullRequest#source_branch_exists? Add CHANGELOG Fix GitHub importer performance on branch existence check Rebuild the dynamic path before validating it Rename stage ref migration specs to match a class name Enable Style/DotPosition Rubocop :cop: Revert "Merge branch 'winh-merge-request-related-issues' into 'master'" ... Conflicts: db/post_migrate/20170526185921_migrate_build_stage_reference.rb
| * Enable Style/DotPosition Rubocop :cop:Grzegorz Bizon2017-06-214-35/+35
| |
* | Raise if updating columns in batches within a transactionGrzegorz Bizon2017-06-211-0/+6
|/
* Put an upper limit on update batchesupdate-column-in-batches-batch-sizeYorick Peterse2017-06-191-0/+6
| | | | | | | When using update_column_in_batches the upper limit on the batch size is now 1000. This ensures that for very large tables we don't lock tens of thousands of rows during the update. This in turn should reduce the likelyhood of running into deadlocks.
* Add database helpers 'add_timestamps_with_timezone' and ↵32054-rails-should-use-timestamptz-database-type-for-postgresqlblackst0ne2017-06-131-0/+33
| | | | 'timestamps_with_timezone'
* Only use DROP INDEX CONCURRENTLY on postgreql 9.2+Nick Thomas2017-05-251-1/+34
|
* Fixes for the rename reserved paths helpersBob Van Landuyt2017-05-183-1/+16
|
* Disallow NULL on renamed column after default has been setDouwe Maan2017-05-151-1/+2
|
* Merge branch 'rename-column-concurrently-defaults' into 'master' Rémy Coutable2017-05-151-1/+5
|\ | | | | | | | | Fix adding defaults for concurrent column renames See merge request !11335
| * Fix adding defaults for concurrent column renamesrename-column-concurrently-defaultsYorick Peterse2017-05-121-1/+5
| | | | | | | | | | | | By adding the default value _after_ adding the column we avoid updating all rows in a table, saving a lot of time and unnecessary work in the process.
* | Update rename_base.rbJames Lopez2017-05-121-1/+1
| |
* | Only rename namespaces and projects with an invalid pathBob Van Landuyt2017-05-121-1/+1
|/ | | | For exact matches, not namespaces that end with an invalid path