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
98d6eb28
Commit
98d6eb28
authored
Mar 04, 2021
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update query to retreive database WAL position
The new query specify conditions to match primary and standy leaders
parent
ed0fe440
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
lib/gitlab/database.rb
lib/gitlab/database.rb
+9
-1
No files found.
lib/gitlab/database.rb
View file @
98d6eb28
...
@@ -260,7 +260,15 @@ module Gitlab
...
@@ -260,7 +260,15 @@ module Gitlab
# @return [String]
# @return [String]
def
self
.
get_write_location
(
ar_connection
)
def
self
.
get_write_location
(
ar_connection
)
row
=
ar_connection
row
=
ar_connection
.
select_all
(
'SELECT CASE WHEN pg_is_in_recovery() = true THEN pg_last_wal_replay_lsn()::text ELSE pg_current_wal_insert_lsn()::text END AS location;'
)
.
select_all
(
<<~
SQL
)
SELECT CASE
WHEN pg_is_in_recovery() = true AND EXISTS (SELECT 1 FROM pg_stat_get_wal_senders())
THEN pg_last_wal_replay_lsn()::text
WHEN pg_is_in_recovery() = false
THEN pg_current_wal_insert_lsn()::text
ELSE NULL
END AS location;
SQL
.
first
.
first
row
[
'location'
]
if
row
row
[
'location'
]
if
row
...
...
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