Write FSM
Created by: davecromberge
It appears as if the Write FSM module is not being used by DalmatinerDB, at least at my cursory inspection. Confusingly, the metric API to the VNode is non-symmetrical for R/W in terms of co-ordinating responses, and can lead to confusion. For example, when reading from Dalmatiner, the Metric module delegates the read to the read FSM, whose responsible it is to ensure a proper quorum read:
get(Bucket, Metric, PPF, Time, Count) when
Time div PPF =:= (Time + Count - 1) div PPF->
folsom_metrics:histogram_timed_update(
get, dalmatiner_read_fsm, start,
[{metric_vnode, metric}, get, {Bucket, {Metric, Time div PPF}},
{Time, Count}]).
For writes, I do not see a similar delegating call to the write FSM:
put(Bucket, Metric, Time, Value) ->
{ok, N} = application:get_env(dalmatiner_db, n),
{ok, W} = application:get_env(dalmatiner_db, w),
PPF = dalmatiner_opt:ppf(Bucket),
folsom_metrics:histogram_timed_update(
put,
fun() ->
put(Bucket, Metric, PPF, Time, Value, N, W)
end).
Confusingly, the quorum consistency check on W occurs in metric.erl itself:
do_wait(0, _ReqID) ->
ok;
do_wait(W, ReqID) ->
receive
{ReqID, ok} ->
do_wait(W - 1, ReqID)
after
5000 ->
{error, timeout}
end.
@Licenser, I would like to know what I am missing, or if there is a special reason for the "exclusion" of the write FSM at this point? I can submit a PR correcting this or add to the documentation if that will help, but I would like to make sure that I am not missing something first. Thanks.