Pre-commit hook debug

Geoff Simonds geoff.simonds at
Tue Dec 1 13:52:03 EST 2015

Good afternoon,

I am writing to ask for some help regarding a pre-commit hook in Riak
2.1.1.  I am locally running a 5 node Riak dev cluster ( on a Mac and am having trouble
with a pre-commit hook.  I have added the "add_paths" to my advanced.config:
 Riak KV config
    %% Paths to custom erlang modules.
    {add_paths, ["/tmp/ls/custom_modules"]}

and then copied the compiled beam to this directory.  I then issued a curl
PUT to add the pre-commit to the bucket props:

curl -XPUT -H "Content-Type: application/json" -d

and am able to confirm it worked when I do a GET on the bucket properties.
The bucket already had a single key stored in it and when I do another PUT
on that object (hoping to get the pre-commit to fire), I get the following


I am able to run the pre-commit function when I attach to the Riak
shell and add the paths manually (code:add_patha) but not when it
triggers via a PUT.  Also, in my pre-commit hook module/function I am
using the riak erlang client to access the object metadata.  Is this
module compiled into Riak or do I also need to add a path for this?

The pre-commit module/function is below:

set_process_datetime_index(Obj) ->
    case is_deleted(Obj) of
        true ->
        _ ->
          MD = riakc_obj:get_update_metadata(Obj),
          case riakc_obj:get_user_metadata_entry(MD,
<<"process_messagedate">>) of
            %% if user "process messagedate" metadata is not found
            notfound ->
              %% add it
              MD2 =
              %% and modify the message_date 2i index
              MD3 = riakc_obj:set_secondary_index(MD2,{{binary_index,
<<"messagedate">>}, [format_date_index(calendar:local_time())]}),
            _ ->
              %% otherwise, don't do anything as we have already
stored the process time


    case dict:find(<<"X-Riak-Deleted">>,riakc_obj:get_metadata(Obj)) of
        {ok,_} ->
        _ ->

Any help or advice is appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list