YCQL batch writes to unique indexes fail with incorrect error message - causing loads to stop #14163
Labels
area/docdb
YugabyteDB core features
jira-originated
kind/bug
This issue is a bug
priority/high
High Priority
When performing a batch write in YCQL, if a row fails to insert into a unique index, the following error message will be reported:
Duplicate value disallowed by unique index <index_name>
This message will be reported for any write failure, not just failures due to violation of the uniqueness constraint. For example, this message referring to duplicate values will be reported if the index table has lost consensus, even though the issue is not due to violation of the constraint.
The batch write code can be found in write_query.cc, in method void WriteQuery::CompleteQLWriteBatch(const Status& status) which is currently on line 682 in master. The actual check that's failing is:
if (is_unique_index &&
ql_write_op->request().type() == QLWriteRequestPB::QL_STMT_INSERT &&
ql_write_op->response()>has_applied() && !ql_write_op>response()->applied()) {
I believe the relevant portion of the condition is only checking whether we've tried to apply the write and whether or not that attempt was successful, not the underlying cause of the failure.
This potentially misleading error message should be corrected. Ideally, we would improve the code to report distinct error messages for each failure mode.
Jira Link: DB-3635
The text was updated successfully, but these errors were encountered: