Comments (8)
PgHero creates a PgHero::Connection
model without a table. It's a bit of a hack but haven't found a better way to do it. Is it causing issues for your application?
from pghero.
Yes it does since I need to call ActiveRecord::Base.descendants
at one point and then it complaints about the missing table.
What is Connection
really needed for? It seems like establish_connection
, connection_config
and other methods can be called on ActiveRecord::Base
as well, or am I missing something?
from pghero.
The model allows you to set ENV["PGHERO_DATABASE_URL"]
to use a different user or database than your application. Does:
ActiveRecord::Base.descendants.reject{|d| d == PgHero::Connection }
do the trick?
from pghero.
Nope, that generates the same error. I think the solution is to not inherit from ActiveRecord::Base
but just include/extend the necessary modules like this:
class Connection
extend ActiveRecord::ConnectionHandling
include ActiveRecord::Core
end
(and maybe a few more are needed)
Then you would need to call Connection.establish_connection
explicitly before accessing the connection the first time.
Unfortunately I don't have a lot of time to test this out right now but I think it's the right direction. 😄
from pghero.
Hi @manuelmeurer and @ankane,
Do you have any sense why my rails production app on heroku is having a similar issue, which is causing severe memory leaks?
The following two SQL statements are consuming 99% of my apps memory in production app on heroku.
SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum WHERE a.attrelid = ?::regclass AND a.attnum > ? AND NOT a.attisdropped ORDER BY a.attnum
SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype FROM pg_type as t LEFT JOIN pg_range as r ON oid = rngtypid
My db:rake config file is as follows:
namespace :db do
desc "Fix 'database is being accessed by other users'"
task :terminate => :environment do
ActiveRecord::Base.connection.execute <<-SQL
SELECT
pg_terminate_backend(pid)
FROM
pg_stat_activity
WHERE
-- don't kill my own connection!
pid <> pg_backend_pid()
-- don't kill the connections to other databases
AND datname = '#{ActiveRecord::Base.connection.current_database}';
SQL
end
end
Rake::Task["db:drop"].enhance ["db:terminate"]
I think that what I need to do is create this new class, update my puma.rb file to explicitly point to it and then re-build my production app.
But... do you think I'm barking up the right tree?
Thanks much
from pghero.
@kmarshall008 what does this have to do with the issue I reported, let alone PgHero at all?
from pghero.
@manuelmeurer Can you try master? 3f1570c
gem 'pghero', github: 'ankane/pghero'
from pghero.
Works!
from pghero.
Related Issues (20)
- Error in SQL explain HOT 1
- Filter for user on queries tab
- [Idea] Show transaction duration on "Live Queries" page HOT 1
- Upgrade Alpine Linux image HOT 3
- [Idea] Allow sorting of tables on the Maintenance tab
- Issuing a new Release (e.g. v3.3.5) HOT 1
- Multi-architecture images for tags other than `latest` HOT 2
- pghero completed 500 internal error throwing plaintext password HOT 2
- GCP Cloud SQL System Stats not enable. HOT 1
- ArgumentError in `slow_queries` HOT 1
- Unable to show space graph on Azure Flexible Postgres Server if storage auto-growth is enabled HOT 1
- There are no graphs HOT 1
- Upgrading PGSQL Version HOT 3
- [Idea] Live queries parameters HOT 1
- Anonymize explain input
- Support for Debian12 HOT 2
- [Idea] Enable/Disable Option for "Kill" Button
- Unsolicited Email HOT 2
- `undefined method 'symbolize_keys'` when running on Rails' main branch HOT 2
- GCP stats not working anymore HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pghero.