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

opt: failed automatic stats attempts on JSON columns with inverted index #35764

Closed
thoszhang opened this issue Mar 14, 2019 · 3 comments · Fixed by #35915
Closed

opt: failed automatic stats attempts on JSON columns with inverted index #35764

thoszhang opened this issue Mar 14, 2019 · 3 comments · Fixed by #35915
Assignees
Labels
A-sql-table-stats Table statistics (and their automatic refresh). C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.

Comments

@thoszhang
Copy link
Contributor

I had a table with a JSON column where the automatic stats runs were all successful. After adding an inverted index to the column, the automatic stats run that happens after a schema change attempted to compute stats for the JSON column and failed with a unable to encode table key: *tree.DJSON error, similarly to #35150. Subsequent runs (which may have been retries of the first one that failed?) also failed with the same error. When I dropped the index, the resulting automatic stats run was successful again.

I took a quick look, and I'm not sure why #35212 doesn't cover this. When I try to manually add statistics to the JSON column with the inverted index, I do get the correct error (CREATE STATISTICS is not supported for JSON columns).

@thoszhang thoszhang added C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior. A-sql-table-stats Table statistics (and their automatic refresh). labels Mar 14, 2019
@knz
Copy link
Contributor

knz commented Mar 18, 2019

The check is done while planning the CREATE STATS statement; no such check is present in the auto stats code.

@rytaft maybe it needs to be added there as well.

(Also please add a link to #35844 with pgerror.UnimplementedWithIssue...)

@awoods187
Copy link
Contributor

Good idea @knz --I think we should add this to make it easy for our users to understand what is happening.

@rytaft
Copy link
Collaborator

rytaft commented Mar 18, 2019

Thanks for filing this issue, @lucy-zhang!

@knz, Looks like you beat me to it on adding the issue to the existing error. Thanks for fixing that!

rytaft added a commit to rytaft/cockroach that referenced this issue Mar 18, 2019
This commit fixes an issue in which the default columns for
CREATE STATISTICS included inverted index columns. Since we
cannot create statistics on JSON columns, running automatic
statistics on a table with an inverted index resulted in the
error "unable to encode table key: *tree.DJSON". This commit
fixes the issue by skipping over inverted indexes when
determining the default columns for CREATE STATISTICS.

Fixes cockroachdb#35764

Release note (bug fix): Fixed an error that occurred when
creating statistics on tables with an inverted index.
craig bot pushed a commit that referenced this issue Mar 19, 2019
35915: sql: do not create stats on inverted index columns r=rytaft a=rytaft

This commit fixes an issue in which the default columns for
`CREATE STATISTICS` included inverted index columns. Since we
cannot create statistics on JSON columns, running automatic
statistics on a table with an inverted index resulted in the
error "unable to encode table key: *tree.DJSON". This commit
fixes the issue by skipping over inverted indexes when
determining the default columns for `CREATE STATISTICS`.

Fixes #35764

Release note (bug fix): Fixed an error that occurred when
creating statistics on tables with an inverted index.

Co-authored-by: Rebecca Taft <[email protected]>
rytaft added a commit to rytaft/cockroach that referenced this issue Mar 19, 2019
This commit fixes an issue in which the default columns for
CREATE STATISTICS included inverted index columns. Since we
cannot create statistics on JSON columns, running automatic
statistics on a table with an inverted index resulted in the
error "unable to encode table key: *tree.DJSON". This commit
fixes the issue by skipping over inverted indexes when
determining the default columns for CREATE STATISTICS.

Fixes cockroachdb#35764

Release note (bug fix): Fixed an error that occurred when
creating statistics on tables with an inverted index.
craig bot pushed a commit that referenced this issue Mar 19, 2019
35912: roachtest: begin the release qualification roachtest whitelist r=nvanbenschoten a=danhhz

Starting with `tpcc/nodes=3/w=max` for now so I can get the teamcity
plumbing done. This test verifies that running our claimed max TPCC
warehouses works. The max depends on the hardware configuration:
currently 1450 on a 3-node GCE n1-standard-1 cluster or 2200 on a 3-node
AWS c5d.4xlarge cluster.

Release note: None

35915: sql: do not create stats on inverted index columns r=rytaft a=rytaft

This commit fixes an issue in which the default columns for
`CREATE STATISTICS` included inverted index columns. Since we
cannot create statistics on JSON columns, running automatic
statistics on a table with an inverted index resulted in the
error "unable to encode table key: *tree.DJSON". This commit
fixes the issue by skipping over inverted indexes when
determining the default columns for `CREATE STATISTICS`.

Fixes #35764

Release note (bug fix): Fixed an error that occurred when
creating statistics on tables with an inverted index.

35944: distsqlpb,importccl: fix a regression in IMPORT r=RaduBerinde a=knz

Fixes #35943.

This patch ensures that the full error message (pre-unwrap) is
included for errors that flow out of distsql process towards the
gateway.

This is important because some other internal mechanisms inside
CockroachDB are expecting to see the prefixes introduced by
errors.Wrap to decide other things (a bad idea, but not fixable in the
short term), for example see issue #35942.

Release note: None

Co-authored-by: Daniel Harrison <[email protected]>
Co-authored-by: Rebecca Taft <[email protected]>
Co-authored-by: Raphael 'kena' Poss <[email protected]>
@craig craig bot closed this as completed in #35915 Mar 19, 2019
rytaft added a commit to rytaft/cockroach that referenced this issue Mar 20, 2019
This commit fixes an issue in which the default columns for
CREATE STATISTICS included inverted index columns. Since we
cannot create statistics on JSON columns, running automatic
statistics on a table with an inverted index resulted in the
error "unable to encode table key: *tree.DJSON". This commit
fixes the issue by skipping over inverted indexes when
determining the default columns for CREATE STATISTICS.

Fixes cockroachdb#35764

Release note (bug fix): Fixed an error that occurred when
creating statistics on tables with an inverted index.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-table-stats Table statistics (and their automatic refresh). C-cleanup Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants