Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YCQL batch writes to unique indexes fail with incorrect error message - causing loads to stop #14163

Closed
yugabyte-ci opened this issue Sep 23, 2022 · 1 comment
Assignees
Labels
area/docdb YugabyteDB core features jira-originated kind/bug This issue is a bug priority/high High Priority

Comments

@yugabyte-ci
Copy link
Contributor

yugabyte-ci commented Sep 23, 2022

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

@yugabyte-ci yugabyte-ci added jira-originated kind/bug This issue is a bug priority/low Low priority status/awaiting-triage Issue awaiting triage labels Sep 23, 2022
@tedyu tedyu self-assigned this Sep 24, 2022
@yugabyte-ci yugabyte-ci added area/ycql Yugabyte CQL (YCQL) and removed status/awaiting-triage Issue awaiting triage labels Sep 27, 2022
@yugabyte-ci yugabyte-ci changed the title Misleading error message when YCQL batch writes to unique indexes fail YCQL batch writes to unique indexes fail with incorrect error message - causing loads to stop Sep 29, 2022
@tedyu tedyu removed their assignment Sep 29, 2022
@yugabyte-ci yugabyte-ci added priority/high High Priority area/docdb YugabyteDB core features and removed priority/low Low priority labels Sep 29, 2022
robertsami added a commit to robertsami/yugabyte-db that referenced this issue Oct 11, 2022
…ndex read error

Summary:
Previously we would show the same error message indicating a unique constraint error any time a
unique index operation failed. This revision improves the logging and error message surfaced by
including the remove error to the client.

Test Plan: Jenkins

Reviewers: pjain, amitanand

Differential Revision: http://phabricator.dev.yugabyte.com/D20063
@yugabyte-ci yugabyte-ci removed the area/ycql Yugabyte CQL (YCQL) label Oct 12, 2022
robertsami added a commit that referenced this issue Oct 19, 2022
Summary: We show the client the same error message indicating a unique constraint error any time a unique index operation failed and the response explicitly set applied=false. While these conditions would only be met in the case of a duplicate value error, the code here invited speculation that we might be masking the true error which may be different. This revision provides an improved explanation of why this branch is ok to assume this is a unique index constraint error and adds additional VLOGs in case the doubt ever rises in production.

Test Plan: Jenkins

Reviewers: pjain, amitanand

Reviewed By: amitanand

Subscribers: kannan

Differential Revision: https://phabricator.dev.yugabyte.com/D20063
@rthallamko3
Copy link
Contributor

Instrumentation has been added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docdb YugabyteDB core features jira-originated kind/bug This issue is a bug priority/high High Priority
Projects
None yet
Development

No branches or pull requests

4 participants