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

Database couldn't be dropped #114

Open
cospin opened this issue Jan 25, 2020 · 10 comments
Open

Database couldn't be dropped #114

cospin opened this issue Jan 25, 2020 · 10 comments

Comments

@cospin
Copy link

cospin commented Jan 25, 2020

Hello, I get this error:

$ mix test.watch

Running tests...
** (Mix) The database for App.Repo couldn't be dropped:
ERROR 55006 (object_in_use): database "app_test" is
being accessed by other users

There are 10 other sessions using the database.

mix test works fine. Do you know what could it be?

@lpil
Copy link
Owner

lpil commented Jan 26, 2020

Could you share a minimal preproduction of the issue please? Thanks.

@anzaika
Copy link

anzaika commented Jan 30, 2020

@cristianospina take a look at this article, maybe it will help solve your problem

https://medium.com/@a4word/continuous-testing-with-elixir-ddc1107c5cc0

@cospin
Copy link
Author

cospin commented Jan 31, 2020

Sorry for the delay @lpil, for now is hard to know how to reproduce. Tried to isolate some things but the problem still persist.

With one workaround in the article that @anzaika give me (thanks!) it works fine. Jus needed to reeplace the mix alias "test" for "test.once" (or anything). This made the "test" command to not clean the database, something that I really need to do for the tests, but can live with it for now.

So the issue seems to be that somewhere in my app the database is starting before test.watch runs the test command, any advice on how to debug this?

@lpil
Copy link
Owner

lpil commented Jan 31, 2020

Could you share your mix.exs file please? Hard to help without any of the details. Thank you.

@cospin
Copy link
Author

cospin commented Jan 31, 2020

Sure:
mix.exs
application.ex

@lpil
Copy link
Owner

lpil commented Jan 31, 2020

Can you share the bits of your config.exs where you configure your database? Thanks

@cospin
Copy link
Author

cospin commented Jan 31, 2020

Here

@lpil
Copy link
Owner

lpil commented Jan 31, 2020

I can't obviously see the problem I'm afraid. Perhaps someone with more familiarity with ecto may be able to help.

@dyyce
Copy link

dyyce commented Mar 25, 2020

facing the same issue as described by @cristianospina

@cristianospina
Could you please explain how you meant to use test.once as a workaround?

@cospin
Copy link
Author

cospin commented Mar 25, 2020

Hey @dyyce, in your mix.exs (example here) add this to project: preferred_cli_env: ["test.once": :test]. Then in aliases duplicate the test alias, comment the original and replace the name in the second one for: "test.once". Now you can use mix test.watch, and if you want to test as always you need to use mix test.once insted of mix test. You can change test.once for whatever string you want.

As this workaround is for dev, I haven't commited those changes to the repo, they are just local. It will break CI/CD etc.

Btw, could you also post your mix.exs and application.ex to compare and try to get some clue about this error?

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

4 participants