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

How to properly shutdown app with Mnesia backed queue #6

Open
raulintosh opened this issue Oct 9, 2017 · 10 comments
Open

How to properly shutdown app with Mnesia backed queue #6

raulintosh opened this issue Oct 9, 2017 · 10 comments

Comments

@raulintosh
Copy link

Hello @sheharyarn, I have an phoenix app that use a lot of Que Workers to process events data.
I has configured Mnesia to store the queue, every time that I need to restart the app I need to delete the mnesia tables and run Que.Persistence.Mnesia.setup! again.
Do yo know which procedure I must follow to stop Que properly.

Elixir 1.5.1
Phoenix 1.3.0
Que 0.4.1

Best regards.
Raul

@sheharyarn
Copy link
Owner

Hi @raulintosh,
This sounds like a weird issue since this shouldn't happen at all. Is this happening on dev or prod? Can you give more details about your environment (like OS name and version, erlang version, release manager that you're using, etc.)?

Also, are you able to reproduce this issue on a fresh phoenix app keeping all the other things same?

@carterbryden
Copy link

carterbryden commented Jan 19, 2018

I'm having what I believe is the same issue, in that if the application isn't shut down properly I get this error on attempting to restart it. Removing the mnesia tables and running setup again will fix the problem, but concerns me because I could potentially lose failed jobs.

** (Mix) Could not start application que: Que.start(:normal, []) returned an error: shutdown: failed to start child: Que.ServerSupervisor
    ** (EXIT) an exception was raised:
        ** (Protocol.UndefinedError) protocol Enumerable not implemented for :badarg
            (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
            (elixir) lib/enum.ex:116: Enumerable.reduce/3
            (elixir) lib/enum.ex:1776: Enum.map/2
            (que) lib/que/server_supervisor.ex:73: Que.ServerSupervisor.resume_queued_jobs/0
            (que) lib/que/server_supervisor.ex:24: Que.ServerSupervisor.start_link/0
            (stdlib) supervisor.erl:365: :supervisor.do_start_child/2
            (stdlib) supervisor.erl:348: :supervisor.start_children/3
            (stdlib) supervisor.erl:314: :supervisor.init_children/2
            (stdlib) gen_server.erl:328: :gen_server.init_it/6
            (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

That line 73 on the server supervisor is trying to enumerate over the incomplete jobs but something's going wrong there.

@sheharyarn
Copy link
Owner

sheharyarn commented Jan 19, 2018 via email

@carterbryden
Copy link

Elixir 1.5.1
Phoenix 1.3.0
Que 0.4.1
Dev environment
ubuntu 14.04

The easiest way is to ctrl-c then ctrl-k after mix phx.server, but I also had the issue when a config file was changed while phoenix was running (it errors out, saying you need to restart).

I did just find that if I start a separate iex -S mix on the same project, and run Que.ServerSupervisor.start_link it returns:

iex(1)> Que.ServerSupervisor.start_link
[info] [Que] Booting Server Supervisor for Workers
{:error, {:already_started, #PID<0.386.0>}}

And then the next time I try running mix phx.server it will start up OK. Not sure why.

@AsharDweedar
Copy link

AsharDweedar commented Jul 31, 2018

having same problem on start:

    ** (EXIT) an exception was raised:
        ** (Amnesia.TableExistsError) Table Que.Persistence.Mnesia.DB already exists
            (amnesia) lib/amnesia/table.ex:138: Amnesia.Table.create!/2
            (que) lib/que/persistence/mnesia.ex:128: Que.Persistence.Mnesia.DB.create!/1
            (que) lib/que/persistence/mnesia.ex:107: Que.Persistence.Mnesia.setup!/1

if i add to the configurations of my app:
config :mnesia, dir: '#{:os.system_time :second}/path/to/some/folder''
problem will be solved since another folder will be created, but old folder will never be used again with all it's content

@sheharyarn
Copy link
Owner

Hi @AsharDweedar, your issue seems different. What Elixir/OTP/OS versions are you on?

@AsharDweedar
Copy link

Elixir (1.6.6) , Erlang/OTP 20, ubuntu 16.04

@sheharyarn
Copy link
Owner

@AsharDweedar it looks like you're calling either mix que.setup or Que.Persistence.Mnesia.setup! multiple times. Just once is enough to create the database.

@AsharDweedar
Copy link

AsharDweedar commented Aug 2, 2018

i have this in my application.ex:

  Que.Persistence.Mnesia.setup!()

I have to remove the file at each start of the App

@sheharyarn
Copy link
Owner

sheharyarn commented Aug 2, 2018 via email

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

No branches or pull requests

4 participants