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

[DocDB] NULL tuples don't show up in unique secondary index scans in PgRegrIndex #17750

Closed
1 task done
tanujnay112 opened this issue Jun 13, 2023 · 0 comments
Closed
1 task done
Assignees
Labels
area/docdb YugabyteDB core features kind/bug This issue is a bug priority/highest Highest priority issue

Comments

@tanujnay112
Copy link
Contributor

tanujnay112 commented Jun 13, 2023

Jira Link: DB-6846

Description

Starting from commit 2bee5cf or after it appears that we are failing PgRegressIndex on the following set of queries:

CREATE TABLE usc_asc(k int, v int);
CREATE UNIQUE INDEX ON usc_asc(v ASC NULLS FIRST);
INSERT INTO usc_asc VALUES (44, NULL),(22, 20),(33, 30),(11, 10),(44, NULL);
SELECT * FROM usc_asc ORDER BY v DESC NULLS LAST;

On master, this query still yields the following incomplete result:

 k  | v  
----+----
 33 | 30
 22 | 20
 11 | 10
(3 rows)

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@tanujnay112 tanujnay112 added area/docdb YugabyteDB core features status/awaiting-triage Issue awaiting triage labels Jun 13, 2023
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Jun 13, 2023
@tanujnay112 tanujnay112 added priority/high High Priority and removed priority/medium Medium priority issue labels Jun 13, 2023
@yugabyte-ci yugabyte-ci added priority/highest Highest priority issue and removed priority/high High Priority status/awaiting-triage Issue awaiting triage labels Jun 13, 2023
spolitov added a commit that referenced this issue Jun 22, 2023
Summary:
Suppose table table does not have hash key columns, but has range colums.
We are trying to use shared prefix with 1 byte length, that contains value type of the first key column.

Previously we were relying on the flag - is_nullable for this column.
But is does not contain valid value and always true for key columns.
It works for table itself, because primary key columns cannot be NULL.
But for indexes it is incorrect, since index could have NULL in key column.

This diff switches logic from checking is_nullable of the first column, to checking whether table is index or not.

Test Plan: PgIndexText.NullKey

Reviewers: tnayak

Reviewed By: tnayak

Subscribers: bogdan, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D26271
jasonyb pushed a commit that referenced this issue Jun 22, 2023
Summary:
There is an optimization to avoid performing a scan when the condition
is unsatisfiable.  The logic for determining whether a condition is
unsatisfiable has flaws:

- It has an inverted condition: rather than looking for a row filter
  whose first key is null, it looks for a row filter where any key but
  the first is null.
- It reads data out-of-bounds from an array: it tries to read keys[-1].

Fix both issues.

To test, add a debug log when an unsatisfiable condition is found.  Also
add a psql variable YB_DISABLE_ERROR_PREFIX to avoid adding a prefix to
client messages when a file is being read because that prefix includes a
line number which can easily change over the course of edits to the
file.  Add test cases to exercise the unsatisfiable conditions.  Also
add DIST to the EXPLAINs for further assurance that RPCs are not sent.
Jira: DB-6953

Test Plan:
Expect the following to fail on only the yb_index_scan test due to
issue #17750.

    ./yb_build.sh fastdebug --gcc11 --java-test TestPgRegressIndex

Close: #17869

Reviewers: tnayak

Reviewed By: tnayak

Subscribers: kramanathan, yql

Differential Revision: https://phorge.dev.yugabyte.com/D26352
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docdb YugabyteDB core features kind/bug This issue is a bug priority/highest Highest priority issue
Projects
None yet
Development

No branches or pull requests

4 participants