Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
26e522ac
Unverified
Commit
26e522ac
authored
1 year ago
by
Eugen Rochko
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix not actually connecting to the configured replica (#25977)
parent
b923a4c7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/helpers/database_helper.rb
+2
-2
2 additions, 2 deletions
app/helpers/database_helper.rb
app/models/application_record.rb
+2
-0
2 additions, 0 deletions
app/models/application_record.rb
config/database.yml
+30
-12
30 additions, 12 deletions
config/database.yml
with
34 additions
and
14 deletions
app/helpers/database_helper.rb
+
2
−
2
View file @
26e522ac
...
...
@@ -2,10 +2,10 @@
module
DatabaseHelper
def
with_read_replica
(
&
block
)
ApplicationRecord
.
connected_to
(
role: :read
,
prevent_writes:
true
,
&
block
)
ApplicationRecord
.
connected_to
(
role: :read
ing
,
prevent_writes:
true
,
&
block
)
end
def
with_primary
(
&
block
)
ApplicationRecord
.
connected_to
(
role: :
p
ri
mary
,
&
block
)
ApplicationRecord
.
connected_to
(
role: :
w
ri
ting
,
&
block
)
end
end
This diff is collapsed.
Click to expand it.
app/models/application_record.rb
+
2
−
0
View file @
26e522ac
...
...
@@ -5,6 +5,8 @@ class ApplicationRecord < ActiveRecord::Base
include
Remotable
connects_to
database:
{
writing: :primary
,
reading: :read
}
class
<<
self
def
update_index
(
_type_name
,
*
_args
,
&
_block
)
super
if
Chewy
.
enabled?
...
...
This diff is collapsed.
Click to expand it.
config/database.yml
+
30
−
12
View file @
26e522ac
...
...
@@ -8,23 +8,41 @@ default: &default
application_name
:
'
'
development
:
<<
:
*default
database
:
<%= ENV['DB_NAME'] || 'mastodon_development' %>
username
:
<%= ENV['DB_USER'] %>
password
:
<%= (ENV['DB_PASS'] || '').to_json %>
host
:
<%= ENV['DB_HOST'] %>
port
:
<%= ENV['DB_PORT'] %>
primary
:
<<
:
*default
database
:
<%= ENV['DB_NAME'] || 'mastodon_development' %>
username
:
<%= ENV['DB_USER'] %>
password
:
<%= (ENV['DB_PASS'] || '').to_json %>
host
:
<%= ENV['DB_HOST'] %>
port
:
<%= ENV['DB_PORT'] %>
read
:
<<
:
*default
database
:
<%= ENV['DB_NAME'] || 'mastodon_development' %>
username
:
<%= ENV['DB_USER'] %>
password
:
<%= (ENV['DB_PASS'] || '').to_json %>
host
:
<%= ENV['DB_HOST'] %>
port
:
<%= ENV['DB_PORT'] %>
replica
:
true
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test
:
<<
:
*default
database
:
<%= ENV['DB_NAME'] || 'mastodon' %>_test<%= ENV['TEST_ENV_NUMBER'] %>
username
:
<%= ENV['DB_USER'] %>
password
:
<%= (ENV['DB_PASS'] || '').to_json %>
host
:
<%= ENV['DB_HOST'] %>
port
:
<%= ENV['DB_PORT'] %>
primary
:
<<
:
*default
database
:
<%= ENV['DB_NAME'] || 'mastodon' %>_test<%= ENV['TEST_ENV_NUMBER'] %>
username
:
<%= ENV['DB_USER'] %>
password
:
<%= (ENV['DB_PASS'] || '').to_json %>
host
:
<%= ENV['DB_HOST'] %>
port
:
<%= ENV['DB_PORT'] %>
read
:
<<
:
*default
database
:
<%= ENV['DB_NAME'] || 'mastodon' %>_test<%= ENV['TEST_ENV_NUMBER'] %>
username
:
<%= ENV['DB_USER'] %>
password
:
<%= (ENV['DB_PASS'] || '').to_json %>
host
:
<%= ENV['DB_HOST'] %>
port
:
<%= ENV['DB_PORT'] %>
replica
:
true
production
:
primary
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment