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
5289b2d9
Commit
5289b2d9
authored
Nov 15, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent the Geo log cursor from running on primary nodes
parent
a7046b5b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
1 deletion
+33
-1
changelogs/unreleased-ee/4049-log-cursor-runs-on-primary.yml
changelogs/unreleased-ee/4049-log-cursor-runs-on-primary.yml
+5
-0
lib/gitlab/geo/log_cursor/daemon.rb
lib/gitlab/geo/log_cursor/daemon.rb
+7
-0
spec/ee/support/geo_helpers.rb
spec/ee/support/geo_helpers.rb
+1
-1
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
+20
-0
No files found.
changelogs/unreleased-ee/4049-log-cursor-runs-on-primary.yml
0 → 100644
View file @
5289b2d9
---
title
:
Prevent the Geo log cursor from running on primary nodes
merge_request
:
3411
author
:
type
:
fixed
lib/gitlab/geo/log_cursor/daemon.rb
View file @
5289b2d9
...
@@ -4,6 +4,7 @@ module Gitlab
...
@@ -4,6 +4,7 @@ module Gitlab
class
Daemon
class
Daemon
VERSION
=
'0.2.0'
.
freeze
VERSION
=
'0.2.0'
.
freeze
BATCH_SIZE
=
250
BATCH_SIZE
=
250
SECONDARY_CHECK_INTERVAL
=
1
.
minute
attr_reader
:options
attr_reader
:options
...
@@ -17,6 +18,12 @@ module Gitlab
...
@@ -17,6 +18,12 @@ module Gitlab
trap_signals
trap_signals
until
exit
?
until
exit
?
# Prevent the node from processing events unless it's a secondary
unless
Geo
.
secondary?
sleep
(
SECONDARY_CHECK_INTERVAL
)
next
end
lease
=
Lease
.
try_obtain_with_ttl
{
run_once!
}
lease
=
Lease
.
try_obtain_with_ttl
{
run_once!
}
return
if
exit
?
return
if
exit
?
...
...
spec/ee/support/geo_helpers.rb
View file @
5289b2d9
...
@@ -2,7 +2,7 @@ module EE
...
@@ -2,7 +2,7 @@ module EE
module
GeoHelpers
module
GeoHelpers
def
stub_current_geo_node
(
node
)
def
stub_current_geo_node
(
node
)
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
node
)
allow
(
::
Gitlab
::
Geo
).
to
receive
(
:current_node
).
and_return
(
node
)
allow
(
node
).
to
receive
(
:current?
).
and_return
(
true
)
allow
(
node
).
to
receive
(
:current?
).
and_return
(
true
)
unless
node
.
nil?
end
end
end
end
end
end
spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
View file @
5289b2d9
...
@@ -42,6 +42,26 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared
...
@@ -42,6 +42,26 @@ describe Gitlab::Geo::LogCursor::Daemon, :postgresql, :clean_gitlab_redis_shared
daemon
.
run!
daemon
.
run!
end
end
it
'skips execution if not a Geo node'
do
stub_current_geo_node
(
nil
)
is_expected
.
to
receive
(
:exit?
).
and_return
(
false
,
true
)
is_expected
.
to
receive
(
:sleep
).
with
(
1
.
minute
)
is_expected
.
not_to
receive
(
:run_once!
)
daemon
.
run!
end
it
'skips execution if the current node is a primary'
do
stub_current_geo_node
(
primary
)
is_expected
.
to
receive
(
:exit?
).
and_return
(
false
,
true
)
is_expected
.
to
receive
(
:sleep
).
with
(
1
.
minute
)
is_expected
.
not_to
receive
(
:run_once!
)
daemon
.
run!
end
end
end
describe
'#run_once!'
do
describe
'#run_once!'
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