update objects in precommit hooks

Damian Dobroczyński qoocku at gmail.com
Fri Apr 1 13:20:46 EDT 2011


W dniu 01.04.2011 15:23, Jon Meredith pisze:
> Hi Damian,
> 
> The put FSM is being overhauled at the moment.  The current 0.14.1 code
> does not apply the updated values in precommit hooks.  In my testing it
> worked ok, but I think that is probably because there were already
> values present in Riak and the changes were included at the vnode level.
> 
> You could try building from source on github, the branch the put FSM was
> refactored on has been pulled in now.  There is a QuickCheck test that
> executes code that looks very similar to yours.
> 
>     MD = riak_object:get_metadata(Obj),
>     UpdMD = dict:store(?MD_USERMETA, [{"X-Riak-Meta-PrecommitHook","was
> here"}], MD),
>     riak_object:update_metadata(Obj, UpdMD).
> 
> I'd be very interested to hear if it resolves your problem.
> 
> BR, Jon.
> Basho Technologies.
> 

Well, I have not applied this patch yet, but in meanwhile I looked into
the riak_object source code and found apply_updates/1. I simply called
this one as the last step in my hook function and it worked. Probably
this is not the correct way of solving this problem, is it?

-- D.


> 2011/4/1 Damian Dobroczyński <qoocku at gmail.com <mailto:qoocku at gmail.com>>
> 
>     Hi, list!
> 
>     I'm trying to update object metadata dictionary within my precommit hook
>     (in Erlang) using `riak_object:update_metadata/2' like this:
> 
>      Old = riak_object:get_metadata(O),
>      New = dict:store(<<"X-my-metadata-name">>, Value, Old),
>      NewObject = riak_object:update_metadata(O, New),
> 
>     Unfortunately, the retrieved object does not contain the new keys. Where
>     can be the problem?
> 
>     -- D.
> 
>     _______________________________________________
>     riak-users mailing list
>     riak-users at lists.basho.com <mailto:riak-users at lists.basho.com>
>     http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0x0CAE3AEB.asc
Type: application/pgp-keys
Size: 5071 bytes
Desc: not available
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20110401/b4b604c9/attachment.asc>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20110401/b4b604c9/attachment-0001.asc>


More information about the riak-users mailing list