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
Jérome Perrin
gitlab-ce
Commits
103b5bf6
Commit
103b5bf6
authored
Jun 02, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix keys seed
parent
e4eac1ff
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
config/initializers/forbid_sidekiq_in_transactions.rb
config/initializers/forbid_sidekiq_in_transactions.rb
+14
-10
db/fixtures/development/11_keys.rb
db/fixtures/development/11_keys.rb
+10
-1
No files found.
config/initializers/forbid_sidekiq_in_transactions.rb
View file @
103b5bf6
module
Sidekiq
module
Sidekiq
module
Worker
module
Worker
mattr_accessor
:inside_after_commit
mattr_accessor
:skip_transaction_check
self
.
inside_after_commit
=
false
self
.
skip_transaction_check
=
false
def
self
.
skipping_transaction_check
(
&
block
)
skip_transaction_check
=
self
.
skip_transaction_check
self
.
skip_transaction_check
=
true
yield
ensure
self
.
skip_transaction_check
=
skip_transaction_check
end
module
ClassMethods
module
ClassMethods
module
NoSchedulingFromTransactions
module
NoSchedulingFromTransactions
...
@@ -9,7 +17,7 @@ module Sidekiq
...
@@ -9,7 +17,7 @@ module Sidekiq
%i(perform_async perform_at perform_in)
.
each
do
|
name
|
%i(perform_async perform_at perform_in)
.
each
do
|
name
|
define_method
(
name
)
do
|*
args
|
define_method
(
name
)
do
|*
args
|
return
super
(
*
args
)
if
Sidekiq
::
Worker
.
inside_after_commit
return
super
(
*
args
)
if
Sidekiq
::
Worker
.
skip_transaction_check
return
super
(
*
args
)
unless
ActiveRecord
::
Base
.
connection
.
open_transactions
>
NESTING
return
super
(
*
args
)
unless
ActiveRecord
::
Base
.
connection
.
open_transactions
>
NESTING
raise
<<-
MSG
.
strip_heredoc
raise
<<-
MSG
.
strip_heredoc
...
@@ -30,16 +38,12 @@ end
...
@@ -30,16 +38,12 @@ end
module
ActiveRecord
module
ActiveRecord
class
Base
class
Base
module
Inside
AfterCommit
module
SkipTransactionCheck
AfterCommit
def
committed!
(
*
)
def
committed!
(
*
)
inside_after_commit
=
Sidekiq
::
Worker
.
inside_after_commit
Sidekiq
::
Worker
.
skipping_transaction_check
{
super
}
Sidekiq
::
Worker
.
inside_after_commit
=
true
super
ensure
Sidekiq
::
Worker
.
inside_after_commit
=
inside_after_commit
end
end
end
end
prepend
Inside
AfterCommit
prepend
SkipTransactionCheck
AfterCommit
end
end
end
end
db/fixtures/development/11_keys.rb
View file @
103b5bf6
require
'./spec/support/sidekiq'
require
'./spec/support/sidekiq'
# Creating keys runs a gitlab-shell worker. Since we may not have the right
# Creating keys runs a gitlab-shell worker. Since we may not have the right
# gitlab-shell path set (yet) we need to disable this for these fixtures.
# gitlab-shell path set (yet) we need to disable this for these fixtures.
Sidekiq
::
Testing
.
disable!
do
Sidekiq
::
Testing
.
disable!
do
Gitlab
::
Seeder
.
quiet
do
Gitlab
::
Seeder
.
quiet
do
# We want to run `add_to_shell` immediately instead of after the commit, so
# that it falls under `Sidekiq::Testing.disable!`.
Key
.
skip_callback
(
:commit
,
:after
,
:add_to_shell
)
User
.
first
(
10
).
each
do
|
user
|
User
.
first
(
10
).
each
do
|
user
|
key
=
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt
#{
user
.
id
+
100
}
6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
key
=
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt
#{
user
.
id
+
100
}
6k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0="
user
.
keys
.
create
(
key
=
user
.
keys
.
create
(
title:
"Sample key
#{
user
.
id
}
"
,
title:
"Sample key
#{
user
.
id
}
"
,
key:
key
key:
key
)
)
Sidekiq
::
Worker
.
skipping_transaction_check
do
key
.
add_to_shell
end
print
'.'
print
'.'
end
end
end
end
...
...
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