Skip to content

sql: bracket subquery results in wrong transaction status #22208

@espadrine

Description

@espadrine

BUG REPORT

Reproduction

CREATE TABLE foo (id INT);
UPDATE foo SET id = 2 WHERE id = (SELECT id FROM [INSERT INTO foo(id) VALUES (1) RETURNING id]);

Expected result: foo contains a single row with id 2.

Actual result: the following error.

pq: internal/client/txn.go:885: attempting to use transaction with wrong status or finalized: COMMITTED true

Potentially useful note: it seems like a bug in bracket subqueries, as the following simpler query has an incorrect result but no errors:

CREATE TABLE foo (id INT);
SELECT id FROM [INSERT INTO foo(id) VALUES (1) RETURNING id] LIMIT 1;
+----+
| id |
+----+
|  1 |
+----+
SELECT * FROM foo;
+----+
| id |
+----+
+----+

Configuration

$ grep -F '[config]' node0/logs/cockroach.log
I180126 15:25:11.916087 1 util/log/clog.go:1031  [config] file created at: 2018/01/26 15:25:11
I180126 15:25:11.916087 1 util/log/clog.go:1031  [config] running on machine: ip-192-168-1-157
I180126 15:25:11.916087 1 util/log/clog.go:1031  [config] binary: CockroachDB CCL v1.1.4 (darwin amd64, built 2018/01/08 18:25:09, go1.9.2)
I180126 15:25:11.916087 1 util/log/clog.go:1031  [config] arguments: [cockroach start --insecure --store node0]
benchmark master
$ grep -F '[config]' node1/logs/cockroach.log
I180129 14:45:35.336207 32031545 util/log/clog.go:928  [config] file created at: 2018/01/29 14:45:35
I180129 14:45:35.336207 32031545 util/log/clog.go:928  [config] running on machine: ip-192-168-1-157
I180129 14:45:35.336207 32031545 util/log/clog.go:928  [config] binary: CockroachDB CCL v1.1.4 (darwin amd64, built 2018/01/08 18:25:09, go1.9.2)
I180129 14:45:35.336207 32031545 util/log/clog.go:928  [config] arguments: [cockroach start --insecure --store node1 --port 26258 --http-port 8081 --join localhost:26257]
benchmark master
$ grep -F '[config]' node2/logs/cockroach.log
I180127 08:10:08.201495 49 util/log/clog.go:928  [config] file created at: 2018/01/27 08:10:08
I180127 08:10:08.201495 49 util/log/clog.go:928  [config] running on machine: ip-192-168-1-157
I180127 08:10:08.201495 49 util/log/clog.go:928  [config] binary: CockroachDB CCL v1.1.4 (darwin amd64, built 2018/01/08 18:25:09, go1.9.2)
I180127 08:10:08.201495 49 util/log/clog.go:928  [config] arguments: [cockroach start --insecure --store node2 --port 26259 --http-port 8082 --join localhost:26257]

Metadata

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.S-3-ux-surpriseIssue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions