On Mon, Jan 19, 2015 at 2:29 AM, Kevin Burton <bur...@spinn3r.com> wrote:

> So ConsistencyLevel.ONE and if not exists are essentially mutually
> incompatible and shouldn’t the driver throw an exception if the user
> requests this configuration?
>

 The subtlety is that this consistency level (CL.ONE in your case) is
actually
used by conditional operations (aka CAS operations, i.e. any insert/update
with
a 'IF'). For those operations there is in fact 2 consistency level that is
taken into account: the serial consistency level, that your driver should
allow
you to set and for which there is really only a choice between SERIAL and
LOCAL_SERIAL, and the usual consistency level, the one you've set to ONE.
There
is 2 phases (I'm simplifying) to CAS operations and each CL apply to one of
them: the first phase is the serial phase and the so-called serial
consistency
applies to it.  For that phase you basically need a quorum of nodes (or a
local quorum if you use LOCAL_SERIAL) and it's because this phase couldn't
be
achieved that you got your exception. After this phase, the write has
been decided (nodes have agreed on committing it if you will) but it may
not be
visible to non-serial reads just yet because the actual write may not have
been
committed to all nodes. It's to this 2nd "committing" phase that the
"normal"
consistency level applies. Concretely, it means that if you do a CAS write
with
a normal CL of ONE, and you then do a read with CL.ONE, you're not
guaranteed
to see your write right away. But if you use QUORUM, then a QORUM read
guarantees you to see that write.

Anyway, my point being that it wouldn't make sense for the driver to throw
an
exception since there is nothing wrong in practice. But it is true that
users
needs to understand how conditional updates differ from normal updates to
avoid
surprises.

--
Sylvain

Reply via email to