So, I've had a weekend plagued of reduce function errors and general
weirdness, probably due to my ignorance on the subject.

Functions seem to be cached, which makes total sense. But it happened
to me several times sending a *different* function yet Riak would
completely ignore it and keep on running an older version (i started
noticing when using ejsLog). Is there a way of disabling caching? Hope
i'm missing something big here cause that's super annoying.

(I've also noticed strange behaviour when executing map/reduce jobs in
parallel and getting results mixed up... *sometimes* (possibly race
conditions) -- but first I want to make sure it's not the client. And
no, there's no global leakage.).

Then... what's wrong with this reduce function? It used to run fine,
but now it doesn't anymore. Oh, wait - yes it does again now that I
restarted Riak:

function(values) {
          return [
            values.reduce(function(acc, value) {
              return acc + (value.fleet || value || 0);
            }, 0)
          ];
        }

What can explain this behaviour? ( * error logs attached)


I'm well aware of
http://github.com/basho/riak_kv/blob/master/priv/mapred_builtins.js
and the few blog posts on the matter. Are there any docs in-between
the basic examples and the source code? (i will delve into it once I
get enough Erlang-fu, promise :)

I mean, when and how reduces (and re-reduces) are invoked and what you
should expect will be fed to your function, how are they cached and
what should programmers know about, what can/can't be done, more
advanced examples (how do "commutative, associative, and idempotent"
functions reflect in practical terms), etc.

I'd love to help with whatever I can (might be good material for a blog post).

Thanks,
Francisco

(*) These are the logs:

=SUPERVISOR REPORT==== 19-Sep-2010::18:10:32 ===
     Supervisor: {local,luke_phase_sup}
     Context:    child_terminated
     Reason:     {error,failed_reduce}
     Offender:   [{pid,<0.5424.22>},
                  {name,undefined},
                  {mfa,
                   {luke_phase,start_link,
                    [riak_kv_reduce_phase,1,
                     [accumulate,converge],
                     undefined,<0.5421.22>,66000,
                     [{javascript,
                       {reduce,
                        {jsanon,
                         <<"function (values) {\n          return [\n
          values.reduce(function(acc, value) {\n              return
acc + (value.fleet || value || 0);\n            }, 0)\n          ];\n
      }">>},
                        none,true}}]]}},
                  {restart_type,temporary},
                  {shutdown,brutal_kill},
                  {child_type,worker}]


=SUPERVISOR REPORT==== 19-Sep-2010::18:10:32 ===
     Supervisor: {local,luke_phase_sup}
     Context:    child_terminated
     Reason:     {error,failed_reduce}
     Offender:   [{pid,<0.5425.22>},
                  {name,undefined},
                  {mfa,
                   {luke_phase,start_link,
                    [riak_kv_reduce_phase,1,
                     [accumulate,converge],
                     undefined,<0.5421.22>,66000,
                     [{javascript,
                       {reduce,
                        {jsanon,
                         <<"function (values) {\n          return [\n
          values.reduce(function(acc, value) {\n              return
acc + (value.fleet || value || 0);\n            }, 0)\n          ];\n
      }">>},
                        none,true}}]]}},
                  {restart_type,temporary},
                  {shutdown,brutal_kill},
                  {child_type,worker}]

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to