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

roachtest/sqlsmith: error decoding 10 bytes: empty array #70767

Closed
yuzefovich opened this issue Sep 27, 2021 · 2 comments · Fixed by #72243
Closed

roachtest/sqlsmith: error decoding 10 bytes: empty array #70767

yuzefovich opened this issue Sep 27, 2021 · 2 comments · Fixed by #72243
Assignees
Labels
branch-master Failures and bugs on the master branch. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-roachtest T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) T-sql-queries SQL Queries Team

Comments

@yuzefovich
Copy link
Member

yuzefovich commented Sep 27, 2021

Extracted from #70666 (comment).

roachtest.sqlsmith/setup=empty/setting=no-ddl failed with artifacts on master @ ecaa4920192549af1418923648769ede3de1c9c8:

The test failed on branch=master, cloud=gce:
test artifacts and logs in: /home/agent/work/.go/src/github.com/cockroachdb/cockroach/artifacts/sqlsmith/setup=empty/setting=no-ddl/run_1
	sqlsmith.go:223,sqlsmith.go:256,test_runner.go:777: error: pq: internal error: unexpected error from the vectorized engine: error decoding 10 bytes: empty array
		stmt:
SELECT
  col
FROM
  (VALUES ((ARRAY[]:::RECORD[],)), ((ARRAY[()],)))
    AS t(col)
ORDER BY
  col ASC;
Reproduce

See: roachtest README

This test on roachdash | Improve this report!

@yuzefovich yuzefovich added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-roachtest branch-master Failures and bugs on the master branch. labels Sep 27, 2021
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Sep 27, 2021
@yuzefovich
Copy link
Member Author

I've debugged this a bit, and the issue is that we have two datums with slightly different types but are assuming that they have exactly the same types during the decoding process.

In the image below, it is a bit hard to see, but

  • the first datum is a tuple consisting of a single array element, with array's element being a tuple that itself has a single element (i.e. `len(TupleContents) == 1)
  • the second datum is a tuple consisting of a single array element, with array's element being a tuple that itself has no elements (i.e. `len(TupleContents) == 0)
  • during the decoding of the empty "inner" tuple in the second datum we get the decoding error.

Screen Shot 2021-10-05 at 2 59 07 PM

I'm not sure whether we want to simply prohibit such cases during the type checking or not. FWIW the postgres returns a syntax error for the reproduction in this issue.

I'll assign this to @rafiss given that in #63996 he touched the type checking of arrays of tuples.

@rafiss
Copy link
Collaborator

rafiss commented Oct 28, 2021

Postgres doesn't allow the empty tuple () in this context, but here's a case that it does handle, but CRDB errors with a similar stack trace as originally reported.

SELECT
  col
FROM
  (VALUES ((ARRAY[]::RECORD[])), ((ARRAY[(1,2)])))
    AS t(col)
ORDER BY
  col ASC;

The problem is that the first array is an array of AnyTuples. and AnyTuple has a TupleContents equal to {types.Any}. The decoding logic gets confused, since it just thinks the tuple it's decoding should always have 1 element in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch-master Failures and bugs on the master branch. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-roachtest T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants