Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script/test: 51 on Reinitialize, error PG::ObjectInUse: ERROR: database "example_test_data" is being accessed by other users #16

Open
infews opened this issue Feb 23, 2024 · 2 comments

Comments

@infews
Copy link

infews commented Feb 23, 2024

Yes, I've allowed myself to get distracted by Rails 7.1 and sqlite support.

I'm getting small test failures due to 7.1 and have been fixing them in small commits. Now have gotten to [script/test: 51] and am failing here:

[script/test:51] $ bin/rake test_data:reinitialize
** Invoke test_data:reinitialize (first_time)
** Invoke test_data:verify_config (first_time)
** Execute test_data:verify_config
** Invoke environment (first_time)
** Execute environment
** Execute test_data:reinitialize
[test_data:warn] Your local test_data database 'example_test_data' is associated
with a SQL dump that was NEWER than the current dumps located in
'test/support/test_data':

  SQL Dump: 2024-02-22 16:38:47 -0800
  Database: 2024-02-22 16:38:54 -0800

If you're not intentionally resetting your local test_data database to an earlier
version, you may want to take a closer look before taking any destructive actions.

** Invoke test_data:drop_database (first_time)
** Invoke environment 
** Execute test_data:drop_database
PG::ObjectInUse: ERROR:  database "example_test_data" is being accessed by other users
DETAIL:  There is 1 other session using the database.
Couldn't drop database 'example_test_data'
rake aborted!
ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR:  database "example_test_data" is being accessed by other users (ActiveRecord::StatementInvalid)
DETAIL:  There is 1 other session using the database.

It looks like folks running into similar problems on drop_database and do some PG/kill foolery. Should I do this? Or is there some other spot where we should fix this?

@infews
Copy link
Author

infews commented Feb 23, 2024

For example, we could monkey patch (sorry) something like this?

http://simon.rentzke.com/force-rails-to-db-drop-postgres-db-when-there-are-other-session-using-the-database/

@infews
Copy link
Author

infews commented Feb 23, 2024

Ugh. I've tried flushing/closing connections at a bunch of places and can't get past this problem.

I've moved to Postgres v16, and that only seems to have made things worse as script/test is now crashing. :shakes_fist:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant