basho / riak-erlang-client

The Riak client for Erlang.
Apache License 2.0
311 stars 188 forks source link

can't write data to a node. [JIRA: CLIENTS-1059] #341

Closed zkessin closed 7 years ago

zkessin commented 7 years ago

I am trying to write some basic data to a riak node (more or less a "Hello world") I have my node online, I ran riak test, and the ping works, but when I try to write data to the node I get an error in riak_kv_pb:encode/1, I tried running riak in a docker container as well as directly on my linux node

my code

riak_connect_test() ->
    {ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087),
    'pong' = riakc_pb_socket:ping(Pid),

    io:format("PING~n"),
    Object    = riakc_obj:new(<<"test">>,
                              <<"eunit-1">>,
                              <<"test">>),

    ok        = riakc_pb_socket:put(Pid, Object),
    ok.

What i get when I run it

** exception exit: undef
     in function  riak_kv_pb:encode/1
        called as riak_kv_pb:encode({rpbputreq,<<"test">>,<<"eunit-1">>,
                                     undefined,
                                     {rpbcontent,<<"test">>,undefined,
                                      undefined,undefined,undefined,[],
                                      undefined,undefined,[],[],undefined},
                                     undefined,undefined,undefined,undefined,
                                     undefined,undefined,undefined,undefined,
                                     undefined,undefined,undefined,undefined})
     in call from riak_pb_codec:encode/1 (/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riak_pb/src/riak_pb_codec.erl, line 94)
     in call from riakc_pb_socket:encode_request_message/1 (/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riakc/src/riakc_pb_socket.erl, line 2329)
     in call from riakc_pb_socket:send_request/2 (/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riakc/src/riakc_pb_socket.erl, line 2301)
     in call from riakc_pb_socket:handle_call/3 (/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riakc/src/riakc_pb_socket.erl, line 1355)
     in call from gen_server:try_handle_call/4 (gen_server.erl, line 615)
     in call from gen_server:handle_msg/5 (gen_server.erl, line 647)
     in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 247)
(wm-dataimport@local)13> 
=CRASH REPORT==== 29-Dec-2016::09:03:18 ===
  crasher:
    initial call: riakc_pb_socket:init/1
    pid: <0.19998.0>
    registered_name: []
    exception exit: {undef,
                        [{riak_kv_pb,encode,
                             [{rpbputreq,<<"test">>,<<"eunit-1">>,undefined,
                                  {rpbcontent,<<"test">>,undefined,undefined,
                                      undefined,undefined,[],undefined,
                                      undefined,[],[],undefined},
                                  undefined,undefined,undefined,undefined,
                                  undefined,undefined,undefined,undefined,
                                  undefined,undefined,undefined,undefined}],
                             []},
                         {riak_pb_codec,encode,1,
                             [{file,
                                  "/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riak_pb/src/riak_pb_codec.erl"},
                              {line,94}]},
                         {riakc_pb_socket,encode_request_message,1,
                             [{file,
                                  "/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riakc/src/riakc_pb_socket.erl"},
                              {line,2329}]},
                         {riakc_pb_socket,send_request,2,
                             [{file,
                                  "/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riakc/src/riakc_pb_socket.erl"},
                              {line,2301}]},
                         {riakc_pb_socket,handle_call,3,
                             [{file,
                                  "/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riakc/src/riakc_pb_socket.erl"},
                              {line,1355}]},
                         {gen_server,try_handle_call,4,
                             [{file,"gen_server.erl"},{line,615}]},
                         {gen_server,handle_msg,5,
                             [{file,"gen_server.erl"},{line,647}]},
                         {proc_lib,init_p_do_apply,3,
                             [{file,"proc_lib.erl"},{line,247}]}]}
      in function  gen_server:terminate/7 (gen_server.erl, line 812)
    ancestors: [<0.9488.0>]
    messages: []
    links: [<0.9488.0>,#Port<0.542262>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 1598
    stack_size: 27
    reductions: 751
  neighbours:
    neighbour: [{pid,<0.9488.0>},
                  {registered_name,[]},
                  {initial_call,{erlang,apply,2}},
                  {current_function,{gen,do_call,4}},
                  {ancestors,[]},
                  {messages,[]},
                  {links,[<0.2135.0>,<0.19998.0>]},
                  {dictionary,[]},
                  {trap_exit,false},
                  {status,waiting},
                  {heap_size,987},
                  {stack_size,39},
                  {reductions,3037}]
(wm-dataimport@local)13> 09:03:18.270 [error] gen_server <0.19998.0> terminated with reason: {'module could not be loaded',[{riak_kv_pb,encode,[{rpbputreq,<<"test">>,<<"eunit-1">>,undefined,{rpbcontent,<<"test">>,undefined,undefined,undefined,undefined,[],undefined,undefined,[],[],undefined},undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined,undefined}],[]},{riak_pb_codec,encode,1,[{file,"/home/zkessin/Documents/Atidot/DataImportProject/_build/default/lib/riak_pb/src/riak_pb_codec.erl"},{line,94}]},{riakc_pb_socket,encode_request_message,...},...]}
(wm-dataimport@local)13> 09:03:18.270 [error] CRASH REPORT Process <0.19998.0> with 1 neighbours exited with reason: call to undefined function riak_kv_pb:encode({rpbputreq,<<"test">>,<<"eunit-1">>,undefined,{rpbcontent,<<"test">>,undefined,undefined,undefined,...},...}) in gen_server:terminate/7 line 812
lukebakken commented 7 years ago

Could you please provide more information:

alexmoore commented 7 years ago

Hi Zach,

Also, how are you building/loading the libraries when running this test?

The error log line:

exception exit: undef
     in function  riak_kv_pb:encode/1

looks like it can't find the riak_kv_pb.beam file, which is generated from riak_kv.proto. The system does find riak_pb_codec.beam, which is the next line down and in the same project.

(Love the podcast by the way)

lukebakken commented 7 years ago

@zkessin -

I created a repository containing code that will build your code via rebar and execute tests:

https://github.com/lukebakken/riak-erlang-client_341

Please re-open this issue if you have questions.

If you want to run your test function manually, you need to compile your code and dependencies (in deps/ in this example) and run erl like this:

erl -pa ./ebin -pa ./deps/*/ebin
zkessin commented 7 years ago

Just for the record, building the code with rebar3, erlang 19 erts 8.1 i was using the most recent version of riak based on both the docker image and with an apt install

run the code with both eunit and from the erlang repl

lukebakken commented 7 years ago

@zkessin - the problem is that the plugin used to compile the .proto files in riak_pb is not rebar3 compatible.

If you use the latest develop code of riak-erlang-client, I switched the protobuf library to gpb and changed how the generated code is used (we commit it now, instead of building all the time). This should enable the code to work with rebar3.

If you'd provide the complete set of code and related files you're working with I could give it a try, too.

Basho-JIRA commented 7 years ago

Fixed, or closed via GitHub issues.

[posted via JIRA by Alexander Moore]