Hi Vitaliy,

That method 
(https://docs.datastax.com/en/latest-java-driver-api/com/datastax/driver/core/ExecutionInfo.html#getAchievedConsistencyLevel--)
is a bit confusing as it will return null when your desired
consistency level is achieved:

> If the query returned without achieving the requested consistency level due 
> to the RetryPolicy, this return the biggest consistency level that has been 
> actually achieved by the query.
>
> Note that the default RetryPolicy (DefaultRetryPolicy) will never allow a 
> query to be successful without achieving the initially requested consistency 
> level and hence with that default policy, this method will always return 
> null. However, it might occasionally return a non-null with say, 
> DowngradingConsistencyRetryPolicy.

As long as you are using a RetryPolicy that doesn't downgrade
Consistency Level on retry, you can expect this method to always
return null.  I heavily discourage downgrading consistency levels on
retry, you can read the driver team's rationale about it here
(https://docs.datastax.com/en/developer/java-driver/3.5/upgrade_guide/#3-5-0).

> Is it possible to make DataStax driver throw an exception in case
> desired consistency level was not achieved during the insert?

This is actually the default behavior.  If consistency level cannot be
met within Cassandra's configured timeouts, or if not enough replicas
are available to service the consistency level from the start, C* will
raise ReadTimeout, WriteTimeout or Unavailable exceptions
respectively.  The driver can be configured to retry on those errors
per RetryPolicy, although there is some nuance when it comes to it not
retrying statements that are non-idempotent
(https://docs.datastax.com/en/developer/java-driver/3.5/manual/retries/#retries-and-idempotence).
If the driver is not configured to retry, it will raise the exception
to the user.

In summary, as long as you aren't using some form of downgrading
consistency retry policy, if you get a successfully completed request,
you can assume the consistency level you have configured was met for
your operations.

Thanks,
Andy



On Fri, Aug 24, 2018 at 4:14 PM Vitaliy Semochkin <vitaliy...@gmail.com> wrote:
>
> HI,
>
> While using DataStax driver
> session.execute("some insert
> query")getExecutionInfo().getAchievedConsistencyLevel()
> is already returned as null, despite data is stored. Why could it be?
>
> Is it possible to make DataStax driver throw an exception in case
> desired consistency level was not achieved during the insert?
>
> Regards,
> Vitaliy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@cassandra.apache.org
> For additional commands, e-mail: user-h...@cassandra.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@cassandra.apache.org
For additional commands, e-mail: user-h...@cassandra.apache.org

Reply via email to