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

sqlsmith: optimizer stack overflow with virtual PK columns #75147

Closed
mgartner opened this issue Jan 19, 2022 · 1 comment · Fixed by #75898
Closed

sqlsmith: optimizer stack overflow with virtual PK columns #75147

mgartner opened this issue Jan 19, 2022 · 1 comment · Fixed by #75898
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team

Comments

@mgartner
Copy link
Collaborator

Sqlsmith found a query that causes a stack overflow. I've only been able to reproduce with VIRTUAL columns in the PK, which has only been allowed since #73928, so this bug is not present in any releases.

CREATE TABLE t (
  a INT,
  b INT,
  c INT,
  v1 INT AS (c) VIRTUAL,
  v2 INT AS (c) VIRTUAL,
  PRIMARY KEY (b, v1, v2),
  INDEX (a)
);


SELECT 'foo'
FROM t AS t1
JOIN t AS t2 ON
  t1.v2 = t2.v2
  AND t1.v1 = t2.v1
  AND t1.b = t2.b
JOIN t AS t3 ON t1.a = t3.a;
CREATE TABLE
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc025bd0380 stack=[0xc025bd0000, 0xc045bd0000]
fatal error: stack overflow

runtime stack:
runtime.throw({0x868939d, 0xc2ea780})
	/usr/local/opt/go/libexec/src/runtime/panic.go:1198 +0x71
runtime.newstack()
	/usr/local/opt/go/libexec/src/runtime/stack.go:1088 +0x5ac
runtime.morestack()
	/usr/local/opt/go/libexec/src/runtime/asm_amd64.s:461 +0x8b

goroutine 5983 [running]:
runtime.getitab(0x812bee0, 0x8578e40, 0x0)
	/usr/local/opt/go/libexec/src/runtime/iface.go:33 +0x2da fp=0xc025bd0390 sp=0xc025bd0388 pc=0x400d93a
runtime.convI2I(0x0, {0x9aae690, 0xc0044bdd60})
	/usr/local/opt/go/libexec/src/runtime/iface.go:445 +0x4a fp=0xc025bd03c0 sp=0xc025bd0390 pc=0x400e7aa
github.com/cockroachdb/cockroach/pkg/sql/opt/memo.(*LookupJoinExpr).Child(0x0, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/memo/expr.og.go:3135 +0x49 fp=0xc025bd0400 sp=0xc025bd03c0 pc=0x5adcd69
github.com/cockroachdb/cockroach/pkg/sql/opt/ordering.lookupOrIndexJoinBuildChildReqOrdering({0x9aaec30, 0xc002bbc840}, 0x0, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/ordering/lookup_join.go:58 +0x6d fp=0xc025bd0538 sp=0xc025bd0400 pc=0x69a126d
github.com/cockroachdb/cockroach/pkg/sql/opt/ordering.BuildChildRequired({0x9aaec30, 0xc002bbc840}, 0xc0044bdd60, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/ordering/ordering.go:40 +0xa2 fp=0xc025bd05d8 sp=0xc025bd0538 pc=0x69a2582
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.BuildChildPhysicalProps(0xc004b334a0, {0x9aaec30, 0xc002bbc840}, 0xc751200, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/physical_props.go:87 +0x407 fp=0xc025bd0700 sp=0xc025bd05d8 pc=0x69e1207
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:508 +0xcd fp=0xc025bd0770 sp=0xc025bd0700 pc=0x69df16d
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd0808 sp=0xc025bd0770 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd0880 sp=0xc025bd0808 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd08f0 sp=0xc025bd0880 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd0988 sp=0xc025bd08f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd0a00 sp=0xc025bd0988 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd0a70 sp=0xc025bd0a00 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd0b08 sp=0xc025bd0a70 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd0b80 sp=0xc025bd0b08 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd0bf0 sp=0xc025bd0b80 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd0c88 sp=0xc025bd0bf0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd0d00 sp=0xc025bd0c88 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd0d70 sp=0xc025bd0d00 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd0e08 sp=0xc025bd0d70 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd0e80 sp=0xc025bd0e08 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd0ef0 sp=0xc025bd0e80 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd0f88 sp=0xc025bd0ef0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1000 sp=0xc025bd0f88 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd1070 sp=0xc025bd1000 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1108 sp=0xc025bd1070 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1180 sp=0xc025bd1108 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd11f0 sp=0xc025bd1180 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1288 sp=0xc025bd11f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1300 sp=0xc025bd1288 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd1370 sp=0xc025bd1300 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1408 sp=0xc025bd1370 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1480 sp=0xc025bd1408 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd14f0 sp=0xc025bd1480 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1588 sp=0xc025bd14f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1600 sp=0xc025bd1588 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd1670 sp=0xc025bd1600 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1708 sp=0xc025bd1670 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1780 sp=0xc025bd1708 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd17f0 sp=0xc025bd1780 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1888 sp=0xc025bd17f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1900 sp=0xc025bd1888 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd1970 sp=0xc025bd1900 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1a08 sp=0xc025bd1970 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1a80 sp=0xc025bd1a08 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd1af0 sp=0xc025bd1a80 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1b88 sp=0xc025bd1af0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1c00 sp=0xc025bd1b88 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd1c70 sp=0xc025bd1c00 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1d08 sp=0xc025bd1c70 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1d80 sp=0xc025bd1d08 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd1df0 sp=0xc025bd1d80 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd1e88 sp=0xc025bd1df0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd1f00 sp=0xc025bd1e88 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd1f70 sp=0xc025bd1f00 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2008 sp=0xc025bd1f70 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2080 sp=0xc025bd2008 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd20f0 sp=0xc025bd2080 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2188 sp=0xc025bd20f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2200 sp=0xc025bd2188 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd2270 sp=0xc025bd2200 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2308 sp=0xc025bd2270 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2380 sp=0xc025bd2308 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd23f0 sp=0xc025bd2380 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2488 sp=0xc025bd23f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2500 sp=0xc025bd2488 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd2570 sp=0xc025bd2500 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2608 sp=0xc025bd2570 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2680 sp=0xc025bd2608 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd26f0 sp=0xc025bd2680 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2788 sp=0xc025bd26f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2800 sp=0xc025bd2788 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd2870 sp=0xc025bd2800 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2908 sp=0xc025bd2870 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2980 sp=0xc025bd2908 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd29f0 sp=0xc025bd2980 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2a88 sp=0xc025bd29f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2b00 sp=0xc025bd2a88 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd2b70 sp=0xc025bd2b00 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2c08 sp=0xc025bd2b70 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2c80 sp=0xc025bd2c08 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd2cf0 sp=0xc025bd2c80 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2d88 sp=0xc025bd2cf0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2e00 sp=0xc025bd2d88 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd2e70 sp=0xc025bd2e00 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd2f08 sp=0xc025bd2e70 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd2f80 sp=0xc025bd2f08 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd2ff0 sp=0xc025bd2f80 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd3088 sp=0xc025bd2ff0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd3100 sp=0xc025bd3088 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd3170 sp=0xc025bd3100 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd3208 sp=0xc025bd3170 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd3280 sp=0xc025bd3208 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd32f0 sp=0xc025bd3280 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd3388 sp=0xc025bd32f0 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0044bdd60}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd3400 sp=0xc025bd3388 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394cb0, {0x9aaec30, 0xc002bbc840}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd3470 sp=0xc025bd3400 pc=0x69df1a5
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroup(0xc004b334a0, {0x9aae690, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:456 +0x325 fp=0xc025bd3508 sp=0xc025bd3470 pc=0x69df025
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeExpr(0xc004b334a0, {0x9a1cd38, 0xc0026b21e0}, 0xc751200)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:256 +0x11e fp=0xc025bd3580 sp=0xc025bd3508 pc=0x69dec3e
github.com/cockroachdb/cockroach/pkg/sql/opt/xform.(*Optimizer).optimizeGroupMember(0xc004b334a0, 0xc005394af0, {0x9aaf1d0, 0xc005549810}, 0x0)
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/opt/xform/optimizer.go:511 +0x105 fp=0xc025bd35f0 sp=0xc025bd3580 pc=0x69df1a5
...additional frames elided...
created by github.com/cockroachdb/cockroach/pkg/sql/pgwire.(*conn).processCommandsAsync
	/Users/marcus/go/src/github.com/cockroachdb/cockroach/pkg/sql/pgwire/conn.go:594 +0x273
@mgartner mgartner added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jan 19, 2022
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Jan 19, 2022
@mgartner mgartner changed the title sqlsmith: optimizer stack overflow sqlsmith: optimizer stack overflow with virtual PK columns Jan 19, 2022
@mgartner
Copy link
Collaborator Author

mgartner commented Feb 2, 2022

We're planning on reverting the change that allows virtual columns in PKs. That should prevent this from happening. I'll confirm once the revert is complete.

mgartner added a commit to mgartner/cockroach that referenced this issue Feb 2, 2022
Allowing virtual primary key columns created a contradiction of two
hard-coded assumptions of the optimizer:

  1. Primary key columns are written to the primary index (and all
     secondary indexes).
  2. Virtual columns are not written to the primary index.

To prevent this contradiction from causing bugs while planning, the opt
catalog presents columns that are marked as virtual PK columns in the
descriptor as stored columns to the optimizer. This is valid because
virtual computed PK columns behave exactly like stored computed PK
columns: they are written to all indexes.

The test catalog has been updated to mimic this behavior.

Fixes cockroachdb#75147

Release note (bug fix): A bug has been fixed that caused internal errors
when querying tables with virtual columns in the primary key. This bug
was only present since version 22.1.0-alpha.1 and does not appear in any
production releases.
mgartner added a commit to mgartner/cockroach that referenced this issue Feb 3, 2022
Allowing virtual primary key columns created a contradiction of two
hard-coded assumptions of the optimizer:

  1. Primary key columns are written to the primary index (and all
     secondary indexes).
  2. Virtual columns are not written to the primary index.

To prevent this contradiction from causing bugs while planning, the opt
catalog presents columns that are marked as virtual PK columns in the
descriptor as stored columns to the optimizer. This is valid because
virtual computed PK columns behave exactly like stored computed PK
columns: they are written to all indexes.

The test catalog has been updated to mimic this behavior.

Fixes cockroachdb#75147

Release note (bug fix): A bug has been fixed that caused internal errors
when querying tables with virtual columns in the primary key. This bug
was only present since version 22.1.0-alpha.1 and does not appear in any
production releases.
mgartner added a commit to mgartner/cockroach that referenced this issue Feb 3, 2022
Allowing virtual primary key columns created a contradiction of two
hard-coded assumptions of the optimizer:

  1. Primary key columns are written to the primary index (and all
     secondary indexes).
  2. Virtual columns are not written to the primary index.

To prevent this contradiction from causing bugs while planning, the opt
catalog presents columns that are marked as virtual PK columns in the
descriptor as stored columns to the optimizer. This is valid because
virtual computed PK columns behave exactly like stored computed PK
columns: they are written to all indexes.

The test catalog has been updated to mimic this behavior.

Fixes cockroachdb#75147

Release note (bug fix): A bug has been fixed that caused internal errors
when querying tables with virtual columns in the primary key. This bug
was only present since version 22.1.0-alpha.1 and does not appear in any
production releases.
craig bot pushed a commit that referenced this issue Feb 8, 2022
…76205

75541: rfc: kv lock observability via `crdb_locks` r=AlexTalks a=AlexTalks

_Link to [RFC text](https://github.com/AlexTalks/cockroach/blob/rfc_crdb_locks/docs/RFCS/20220104_crdb_locks.md)._

This RFC proposes a feature for observing locks (and contention on
locks) via a new virtual table called `crdb_internal.crdb_locks`.

Release note: None

75738: roachtest/follower_reads: unskip follower-reads/mixed-version/single-region r=andreimatei a=andreimatei

It should have been unskipped with the rest of the follower reads tests
when #69817 was closed.

Release note: None

75898: sql: consider virtual PK columns as stored in the optimizer r=mgartner a=mgartner

Allowing virtual primary key columns created a contradiction of two
hard-coded assumptions of the optimizer:

  1. Primary key columns are written to the primary index (and all
     secondary indexes).
  2. Virtual columns are not written to the primary index.

To prevent this contradiction from causing bugs while planning, the opt
catalog presents columns that are marked as virtual PK columns in the
descriptor as stored columns to the optimizer. This is valid because
virtual computed PK columns behave exactly like stored computed PK
columns: they are written to all indexes.

The test catalog has been updated to mimic this behavior.

Fixes #75147
Fixes #75874

Release note (bug fix): A bug has been fixed that caused internal errors
when querying tables with virtual columns in the primary key. This bug
was only present since version 22.1.0-alpha.1 and does not appear in any
production releases.

75912: util/tracing: don't return recordings for non-recording spans r=andreimatei a=andreimatei

This patch makes sp.GetRecording() return nil if the span was not
recording. This is already what the documentation on GetRecording() was
implying, but the actual behavior was different: a non-recording span
(that's not a no-op span) would return a non-nil recording consisting
only of the the span's metadata. This behavior is not necessarily
unreasonable, but it turns out it's a bit dangerous from a performance
perspective - there's a cost (e.g. some allocations) for generating this
recording, and it was too easy for unsuspecting callers to pay that when
they didn't want to. In particular, DistSQL was indiscriminently calling
GetRecording() (through its GetTraceData* utilities), and paying this
measurable cost unintentionally.

Eliminating this cost is particularly important when the Tracer is
configured in the "active spans registry" tracing mode; when not in that
mode, all the spans would be no-ops and the GetRecording calls were
shortcircuited anyway. This is seen in BenchmarkTracing//trace=on,
particularly on "3node/scan" which was the benchmark with the bigest
difference between tracing on and off.

name                              old time/op    new time/op    delta
Tracing/1node/scan/trace=on-32       214µs ± 4%     206µs ± 5%    ~     (p=0.222 n=5+5)
Tracing/1node/insert/trace=on-32     338µs ± 5%     334µs ± 4%    ~     (p=0.690 n=5+5)
Tracing/3node/scan/trace=on-32       515µs ± 3%     484µs ± 3%  -6.11%  (p=0.008 n=5+5)
Tracing/3node/insert/trace=on-32     635µs ± 1%     627µs ± 1%    ~     (p=0.095 n=5+5)

name                              old alloc/op   new alloc/op   delta
Tracing/1node/scan/trace=on-32      27.2kB ± 2%    25.6kB ± 2%  -5.94%  (p=0.008 n=5+5)
Tracing/1node/insert/trace=on-32    45.2kB ± 2%    45.5kB ± 2%    ~     (p=0.690 n=5+5)
Tracing/3node/scan/trace=on-32      83.2kB ± 3%    79.7kB ± 5%    ~     (p=0.095 n=5+5)
Tracing/3node/insert/trace=on-32     102kB ± 2%     103kB ± 1%    ~     (p=0.548 n=5+5)

name                              old allocs/op  new allocs/op  delta
Tracing/1node/scan/trace=on-32         242 ± 1%       229 ± 0%  -5.37%  (p=0.000 n=5+4)
Tracing/1node/insert/trace=on-32       338 ± 1%       339 ± 1%    ~     (p=0.563 n=5+5)
Tracing/3node/scan/trace=on-32         819 ± 1%       788 ± 6%    ~     (p=0.135 n=5+5)
Tracing/3node/insert/trace=on-32       871 ± 0%       880 ± 0%  +0.99%  (p=0.016 n=4+5)

Release note: None

75981: kvserver: clean-up the interaction between the mergeQueue and `AdminRelocateRange` r=aayushshah15 a=aayushshah15

This commit makes it such that the `mergeQueue` no longer has to take special
care to avoid a lease transfer when calling into `AdminRelocateRange`. This was
enabled by #75676.

Release note: None


75999: kvserver: stop reconciling lease count imbalances in the `StoreRebalancer` r=aayushshah15 a=aayushshah15

Generally, the `StoreRebalancer` doesn't try to attempt lease transfers for
replicas that account for less than 0.1% of the store's total QPS. However, it
allows such lease transfers if the store has a higher than average number of
leases. This is fraught because of the following reasons:

1. It doesn't adhere to any padding. It will do these tiny lease transfers
until the store has less than or equal to the average number of leases.
2. Additionally, "average" here means the average across the cluster, not just
the stores that have replicas for the range. This is clearly not good, as this
doesn't translate well to heterogeneously loaded clusters.
3. These lease transfers also don't adhere to
`kv.allocator.min_lease_transfer_interval`. This means they are not rate
limited like the lease transfers done by the replicateQueue.

This patch fixes this behavior. This patch is similar to #64559.

Noticed while running a tpcc workload on a multi-region cluster, but on a
database constrained to a single region. This was done to simulate a
"heterogeneously loaded cluster".

Release note: None


76078: opt: plan inner lookup joins on virtual column indexes in more cases r=mgartner a=mgartner

ExtractJoinEqualities now reuses computed columns instead of
synthesizing new columns when it creates projections that exactly match
a computed column expression of a base table. This allows
GenerateLookupJoinsWithVirtualCols to generate lookup joins in more
cases. This also paves the way for exploring  anti- and semi-lookup
joins on indexes with virtual columns and expression indexes.

Fixes #75872

Release note (performance improvement): The optimizer now plans inner
lookup joins using expression indexes in more cases, resulting in more
efficient query plans.

76193: optbuilder: do not create invalid casts when building CASE expressions r=mgartner a=mgartner

The optbuilder no longer creates invalid casts when building CASE
expressions that have branches of different types. CASE expressions that
previously caused internal errors now result in user-facing errors. A
similar change was made recently to UNION expressions in #75219.

Note that there is more work to be done to be fully consistent with
Postgres's CASE typing behavior, see #75365.

Fixes #75365

Release note (bug fix): CASE expressions with branches that result in
types that cannot be cast to a common type now result in a user-facing
error instead of an internal error.

76200: cloud: bump orchestrator to v21.2.5 r=celiala a=Azhng

Release note: None

76205: roachtest: update 22.1 version map to v21.2.5 r=celiala a=Azhng

Release note: None

Co-authored-by: Alex Sarkesian <[email protected]>
Co-authored-by: Andrei Matei <[email protected]>
Co-authored-by: Marcus Gartner <[email protected]>
Co-authored-by: Aayush Shah <[email protected]>
Co-authored-by: Azhng <[email protected]>
@craig craig bot closed this as completed in 37d08ab Feb 8, 2022
RajivTS pushed a commit to RajivTS/cockroach that referenced this issue Mar 6, 2022
Allowing virtual primary key columns created a contradiction of two
hard-coded assumptions of the optimizer:

  1. Primary key columns are written to the primary index (and all
     secondary indexes).
  2. Virtual columns are not written to the primary index.

To prevent this contradiction from causing bugs while planning, the opt
catalog presents columns that are marked as virtual PK columns in the
descriptor as stored columns to the optimizer. This is valid because
virtual computed PK columns behave exactly like stored computed PK
columns: they are written to all indexes.

The test catalog has been updated to mimic this behavior.

Fixes cockroachdb#75147

Release note (bug fix): A bug has been fixed that caused internal errors
when querying tables with virtual columns in the primary key. This bug
was only present since version 22.1.0-alpha.1 and does not appear in any
production releases.
@mgartner mgartner moved this to Done in SQL Queries Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant