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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b7a6b876
Commit
b7a6b876
authored
Sep 08, 2021
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename subtrans to savepoints
parent
a82dde8a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
11 deletions
+11
-11
lib/gitlab/database/migration_helpers.rb
lib/gitlab/database/migration_helpers.rb
+1
-1
lib/gitlab/database/migration_helpers/v2.rb
lib/gitlab/database/migration_helpers/v2.rb
+1
-1
lib/gitlab/database/with_lock_retries.rb
lib/gitlab/database/with_lock_retries.rb
+3
-3
spec/lib/gitlab/database/migration_helpers/v2_spec.rb
spec/lib/gitlab/database/migration_helpers/v2_spec.rb
+1
-1
spec/lib/gitlab/database/migration_helpers_spec.rb
spec/lib/gitlab/database/migration_helpers_spec.rb
+1
-1
spec/lib/gitlab/database/with_lock_retries_spec.rb
spec/lib/gitlab/database/with_lock_retries_spec.rb
+4
-4
No files found.
lib/gitlab/database/migration_helpers.rb
View file @
b7a6b876
...
...
@@ -414,7 +414,7 @@ module Gitlab
merged_args
=
{
klass:
self
.
class
,
logger:
Gitlab
::
BackgroundMigration
::
Logger
,
allow_s
ubtran
s:
true
allow_s
avepoint
s:
true
}.
merge
(
kwargs
)
Gitlab
::
Database
::
WithLockRetries
.
new
(
**
merged_args
)
...
...
lib/gitlab/database/migration_helpers/v2.rb
View file @
b7a6b876
...
...
@@ -41,7 +41,7 @@ module Gitlab
# * +logger+ - [Gitlab::JsonLogger]
# * +env+ - [Hash] custom environment hash, see the example with `DISABLE_LOCK_RETRIES`
def
with_lock_retries
(
*
args
,
**
kwargs
,
&
block
)
super
(
*
args
,
**
kwargs
.
merge
(
allow_s
ubtran
s:
false
),
&
block
)
super
(
*
args
,
**
kwargs
.
merge
(
allow_s
avepoint
s:
false
),
&
block
)
end
# Renames a column without requiring downtime.
...
...
lib/gitlab/database/with_lock_retries.rb
View file @
b7a6b876
...
...
@@ -61,10 +61,10 @@ module Gitlab
[
10
.
seconds
,
10
.
minutes
]
].
freeze
def
initialize
(
logger:
NULL_LOGGER
,
allow_s
ubtran
s:
true
,
timing_configuration:
DEFAULT_TIMING_CONFIGURATION
,
klass:
nil
,
env:
ENV
)
def
initialize
(
logger:
NULL_LOGGER
,
allow_s
avepoint
s:
true
,
timing_configuration:
DEFAULT_TIMING_CONFIGURATION
,
klass:
nil
,
env:
ENV
)
@logger
=
logger
@klass
=
klass
@allow_s
ubtrans
=
allow_subtran
s
@allow_s
avepoints
=
allow_savepoint
s
@timing_configuration
=
timing_configuration
@env
=
env
@current_iteration
=
1
...
...
@@ -123,7 +123,7 @@ module Gitlab
end
def
run_block_with_lock_timeout
raise
"WithLockRetries should not run inside already open transaction"
if
ActiveRecord
::
Base
.
connection
.
transaction_open?
&&
@allow_s
ubtran
s
.
blank?
raise
"WithLockRetries should not run inside already open transaction"
if
ActiveRecord
::
Base
.
connection
.
transaction_open?
&&
@allow_s
avepoint
s
.
blank?
ActiveRecord
::
Base
.
transaction
(
requires_new:
true
)
do
# rubocop:disable Performance/ActiveRecordSubtransactions
execute
(
"SET LOCAL lock_timeout TO '
#{
current_lock_timeout_in_ms
}
ms'"
)
...
...
spec/lib/gitlab/database/migration_helpers/v2_spec.rb
View file @
b7a6b876
...
...
@@ -262,7 +262,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers::V2 do
it
'defaults to disallowing subtransactions'
do
with_lock_retries
=
double
expect
(
Gitlab
::
Database
::
WithLockRetries
).
to
receive
(
:new
).
with
(
hash_including
(
allow_s
ubtran
s:
false
)).
and_return
(
with_lock_retries
)
expect
(
Gitlab
::
Database
::
WithLockRetries
).
to
receive
(
:new
).
with
(
hash_including
(
allow_s
avepoint
s:
false
)).
and_return
(
with_lock_retries
)
expect
(
with_lock_retries
).
to
receive
(
:run
).
with
(
raise_on_exhaustion:
false
)
model
.
with_lock_retries
(
env:
env
,
logger:
in_memory_logger
)
{
}
...
...
spec/lib/gitlab/database/migration_helpers_spec.rb
View file @
b7a6b876
...
...
@@ -2335,7 +2335,7 @@ RSpec.describe Gitlab::Database::MigrationHelpers do
it
'defaults to allowing subtransactions'
do
with_lock_retries
=
double
expect
(
Gitlab
::
Database
::
WithLockRetries
).
to
receive
(
:new
).
with
(
hash_including
(
allow_s
ubtran
s:
true
)).
and_return
(
with_lock_retries
)
expect
(
Gitlab
::
Database
::
WithLockRetries
).
to
receive
(
:new
).
with
(
hash_including
(
allow_s
avepoint
s:
true
)).
and_return
(
with_lock_retries
)
expect
(
with_lock_retries
).
to
receive
(
:run
).
with
(
raise_on_exhaustion:
false
)
model
.
with_lock_retries
(
env:
env
,
logger:
in_memory_logger
)
{
}
...
...
spec/lib/gitlab/database/with_lock_retries_spec.rb
View file @
b7a6b876
...
...
@@ -5,8 +5,8 @@ require 'spec_helper'
RSpec
.
describe
Gitlab
::
Database
::
WithLockRetries
do
let
(
:env
)
{
{}
}
let
(
:logger
)
{
Gitlab
::
Database
::
WithLockRetries
::
NULL_LOGGER
}
let
(
:subject
)
{
described_class
.
new
(
env:
env
,
logger:
logger
,
allow_s
ubtrans:
allow_subtran
s
,
timing_configuration:
timing_configuration
)
}
let
(
:allow_s
ubtran
s
)
{
true
}
let
(
:subject
)
{
described_class
.
new
(
env:
env
,
logger:
logger
,
allow_s
avepoints:
allow_savepoint
s
,
timing_configuration:
timing_configuration
)
}
let
(
:allow_s
avepoint
s
)
{
true
}
let
(
:timing_configuration
)
do
[
...
...
@@ -258,8 +258,8 @@ RSpec.describe Gitlab::Database::WithLockRetries do
end
end
context
'Stop using subtransactions - allow_s
ubtran
s: false'
do
let
(
:allow_s
ubtran
s
)
{
false
}
context
'Stop using subtransactions - allow_s
avepoint
s: false'
do
let
(
:allow_s
avepoint
s
)
{
false
}
it
'prevents running inside already open transaction'
do
allow
(
ActiveRecord
::
Base
.
connection
).
to
receive
(
:transaction_open?
).
and_return
(
true
)
...
...
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