Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
2bcb2460
Commit
2bcb2460
authored
Jul 15, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 8-10-stable
parents
4934cabb
8b7932c2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+10
-0
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+4
-0
No files found.
CHANGELOG
View file @
2bcb2460
...
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.10.0 (unreleased)
- Expose {should,force}_remove_source_branch (Ben Boeckel)
- Disable PostgreSQL statement timeout during migrations
- Fix projects dropdown loading performance with a simplified api cal. !5113 (tiagonbotelho)
- Fix commit builds API, return all builds for all pipelines for given commit. !4849
- Replace Haml with Hamlit to make view rendering faster. !3666
...
...
lib/gitlab/database/migration_helpers.rb
View file @
2bcb2460
...
...
@@ -20,11 +20,19 @@ module Gitlab
if
Database
.
postgresql?
options
=
options
.
merge
({
algorithm: :concurrently
})
disable_statement_timeout
end
add_index
(
table_name
,
column_name
,
options
)
end
# Long-running migrations may take more than the timeout allowed by
# the database. Disable the session's statement timeout to ensure
# migrations don't get killed prematurely. (PostgreSQL only)
def
disable_statement_timeout
ActiveRecord
::
Base
.
connection
.
execute
(
'SET statement_timeout TO 0'
)
if
Database
.
postgresql?
end
# Updates the value of a column in batches.
#
# This method updates the table in batches of 5% of the total row count.
...
...
@@ -133,6 +141,8 @@ module Gitlab
'in the body of your migration class'
end
disable_statement_timeout
transaction
do
add_column
(
table
,
column
,
type
,
default:
nil
)
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
2bcb2460
...
...
@@ -13,6 +13,10 @@ describe Gitlab::Database::MigrationHelpers, lib: true do
context
'outside a transaction'
do
before
do
expect
(
model
).
to
receive
(
:transaction_open?
).
and_return
(
false
)
unless
Gitlab
::
Database
.
postgresql?
allow_any_instance_of
(
Gitlab
::
Database
::
MigrationHelpers
).
to
receive
(
:disable_statement_timeout
)
end
end
context
'using PostgreSQL'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment