aweber / rabbitmq-autocluster

This project is now maintained by the RabbitMQ Team, visit the official repo @
https://github.com/rabbitmq/rabbitmq-autocluster
BSD 3-Clause "New" or "Revised" License
336 stars 120 forks source link

autocluster does not work properly with RabbitMQ 3.7.0 #120

Closed Gsantomaggio closed 7 years ago

Gsantomaggio commented 7 years ago

Hi,

With RabbitMQ 3.7.0 the plugin does not work properly.

I am trying to use etcd as backend and I get the following error:

BOOT FAILED
===========

Error description:
    init:do_boot/3
    init:start_em/1
    rabbit:start_it/1 line 436
    rabbit:broker_start/0 line 314
    rabbit:start_apps/1 line 513
    app_utils:manage_applications/6 line 113
    lists:foldl/3 line 1263
    rabbit:'-handle_app_error/1-fun-0-'/3 line 600
throw:{could_not_start,rabbit,
          {undef,
              [{rabbit_misc,json_decode,
                   ["{\"action\":\"get\",\"node\":{\"key\":\"/rabbitmq/default\",\"dir\":true,\"modifiedIndex\":40660,\"createdIndex\":40660}}\n"],
                   []},
               {autocluster_httpc,decode_body,2,
                   [{file,"src/autocluster_httpc.erl"},{line,184}]},
               {autocluster_httpc,parse_response,1,
                   [{file,"src/autocluster_httpc.erl"},{line,208}]},
               {autocluster_etcd,nodelist,0,
                   [{file,"src/autocluster_etcd.erl"},{line,53}]},
               {autocluster,ensure_registered,2,
                   [{file,"src/autocluster.erl"},{line,97}]},
               {autocluster,init,0,[{file,"src/autocluster.erl"},{line,33}]},
               {rabbit_boot_steps,'-run_step/2-lc$^1/1-1-',1,
                   [{file,"src/rabbit_boot_steps.erl"},{line,49}]},
               {rabbit_boot_steps,run_step,2,
                   [{file,"src/rabbit_boot_steps.erl"},{line,49}]}]}}
Log file(s) (may contain more information):
   <stdout>

15:04:26.160 [error]
Error description:
    init:do_boot/3
    init:start_em/1
    rabbit:start_it/1 line 436
    rabbit:broker_start/0 line 314
    rabbit:start_apps/1 line 513
    app_utils:manage_applications/6 line 113
    lists:foldl/3 line 1263
    rabbit:'-handle_app_error/1-fun-0-'/3 line 600
throw:{could_not_start,rabbit,
          {undef,
              [{rabbit_misc,json_decode,
                   ["{\"action\":\"get\",\"node\":{\"key\":\"/rabbitmq/default\",\"dir\":true,\"modifiedIndex\":40660,\"createdIndex\":40660}}\n"],
                   []},
               {autocluster_httpc,decode_body,2,
                   [{file,"src/autocluster_httpc.erl"},{line,184}]},
               {autocluster_httpc,parse_response,1,
                   [{file,"src/autocluster_httpc.erl"},{line,208}]},
               {autocluster_etcd,nodelist,0,
                   [{file,"src/autocluster_etcd.erl"},{line,53}]},
               {autocluster,ensure_registered,2,
                   [{file,"src/autocluster.erl"},{line,97}]},
               {autocluster,init,0,[{file,"src/autocluster.erl"},{line,33}]},
               {rabbit_boot_steps,'-run_step/2-lc$^1/1-1-',1,
                   [{file,"src/rabbit_boot_steps.erl"},{line,49}]},
               {rabbit_boot_steps,run_step,2,
                   [{file,"src/rabbit_boot_steps.erl"},{line,49}]}]}}
Log file(s) (may contain more information):
   <stdout>
{"init terminating in do_boot",{could_not_start,rabbit,{undef,[{rabbit_misc,json_decode,["{\"action\":\"get\",\"node\":{\"key\":\"/rabbitmq/default\",\"dir\":true,\"modifiedIndex\":40660,\"createdIndex\":40660}}\n"],[]},{autocluster_httpc,decode_body,2,[{file,"src/autocluster_httpc.erl"},{line,184}]},{autocluster_httpc,parse_response,1,[{file,"src/autocluster_httpc.erl"},{line,208}]},{autocluster_etcd,nodelist,0,[{file,"src/autocluster_etcd.erl"},{line,53}]},{autocluster,ensure_registered,2,[{file,"src/autocluster.erl"},{line,97}]},{autocluster,init,0,[{file,"src/autocluster.erl"},{line,33}]},{rabbit_boot_steps,'-run_step/2-lc$^1/1-1-',1,[{file,"src/rabbit_boot_steps.erl"},{line,49}]},{rabbit_boot_steps,run_step,2,[{file,"src/rabbit_boot_steps.erl"},{line,49}]}]}}}

Crash dump is being written to: erl_crash.dump...init terminating in do_boot ()
Gsantomaggio commented 7 years ago

Starting from 3.7.0 version the json functions have been moved to the rabbit_json module and removed from rabbit_misc.

I fixed it see https://github.com/aweber/rabbitmq-autocluster/compare/master...Gsantomaggio:rabbitmq-autocluster-120 ( I am going to test it)

I won't PR for now, because it breaks the compatibility with the version 3.6.x.

cc @michaelklishin

Gsantomaggio commented 7 years ago

I fixed the problem, but I had to rewrite some JSON functions.

The current RabbitMQ JSON module supports only jsx:decode(JSON, [return_maps]).

Had to add on src/autocluster_util.erl these JSON functions that don't use [return_maps]

Note: This is WIP, and I tested it only using etcd

screen shot 2017-01-24 at 17 19 38

michaelklishin commented 7 years ago

@Gsantomaggio if there are reasons to expland the API in 3.7.0, let us know.

Gsantomaggio commented 7 years ago

@michaelklishin it would be useful to add these functions in rabbit_json:

  1. decode
  2. try_decode
michaelklishin commented 7 years ago

@Gsantomaggio go ahead and submit a PR (and link to this issue).

Gsantomaggio commented 7 years ago

Closed here https://github.com/rabbitmq/rabbitmq-autocluster/pull/1