Skip to content

Using Que in a multi-node environmentΒ #10

@odarriba

Description

@odarriba

We are trying to use Que to schedule jobs in a multi-node environment, allowing nodes to connect to each other and share mnesia information.

What I'm doing:

  1. Start iex console:
$ mix --sname node1 -S mix
$ mix --sname node2 -S mix
  1. Connect nodes (on node1 console)
iex> Node.connect(:node2@local_hostname)
  1. Check that they are connected with a Node.list() on both sides

  2. Spawn 100 jobs of my TestWorker(which puts a log message and waits one second)

for number <- 1..100 do
  Que.add(TestQue.TestWorker, number)
end

It works, but all jobs run only on one of the nodes (lets say node1), while on the other (node2) no job is executed.
Also, if I execute the same for on node2, all jobs are executed in node1 too.

is there anything we can do to:

  1. Run jobs on any node
  2. Ensure that if one node is down, the tasks in :mnesia remains in the rest of the cluster.

Thanks in advace!

PD: I have also tried executing the setup of mnesia persisted in disk, with this result:

iex(node1@patata)2> nodes = [node() | Node.list]
[:node1@patata, :node2@patata]
iex(node1@patata)3> Que.Persistence.Mnesia.setup!(nodes)
[info] Application mnesia exited: :stopped
** (Memento.MnesiaException) Mnesia operation failed
   :not_active
   Mnesia Error: {:not_active, Que.Persistence.Mnesia.DB.Jobs, :node2@patata}
    (memento) lib/memento/table/table.ex:274: Memento.Table.handle_for_bang!/1

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions