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

cli/dump: fails with column-less tables #37768

Closed
lopezator opened this issue May 23, 2019 · 10 comments · Fixed by #46406
Closed

cli/dump: fails with column-less tables #37768

lopezator opened this issue May 23, 2019 · 10 comments · Fixed by #46406
Labels
A-disaster-recovery C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. docs-done docs-known-limitation X-anchored-telemetry The issue number is anchored by telemetry references.

Comments

@lopezator
Copy link
Contributor

lopezator commented May 23, 2019

To Reproduce

Given an empty database:

CREATE DATABASE foo;
CREATE TABLE bar();
$> cockroach dump --insecure foo

Results in:

CREATE TABLE bar (,
	FAMILY "primary" (rowid)
);
Error: pq: syntax error at or near "from"
Failed running "dump"

Quite evident in the example but can very frustating in a large database.

CC \ @knz

@lopezator lopezator changed the title dump crashes whith column-less tables dump crashes with column-less tables May 23, 2019
@knz
Copy link
Contributor

knz commented May 23, 2019

Note for the reader: the problem is not create table accepting an empty column list.
(We could discuss that but it's not in scope.)

The problem is really in cockroach dump and it's possible to reproduce by creating a regular table, and using alter table drop column to remove all the visible columns.

(Such usage of alter is supported by postgres so we can't just disallow it)

@knz
Copy link
Contributor

knz commented May 23, 2019

cc #28948.

@knz knz changed the title dump crashes with column-less tables cli/dump: crashes with column-less tables May 23, 2019
@knz knz changed the title cli/dump: crashes with column-less tables cli/dump: fails with column-less tables May 23, 2019
@knz knz added A-disaster-recovery A-cli C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption. labels May 24, 2019
@knz knz added the X-anchored-telemetry The issue number is anchored by telemetry references. label Jul 8, 2019
knz added a commit to knz/cockroach that referenced this issue Jul 8, 2019
Before:

```
kena@kenax ~/cockroach % ./cockroach dump --insecure defaultdb
CREATE TABLE t (,
        FAMILY "primary" (rowid)
);
Error: pq: at or near "from": syntax error
Failed running "dump"
```

After:

```
kena@kenax ~/cockroach % ./cockroach dump --insecure defaultdb
CREATE TABLE t (,
        FAMILY "primary" (rowid)
);
Error: table "defaultdb.public.t" has no visible columns
HINT: To proceed with the dump, either omit this table from the list of tables to dump, drop the table, or add some visible columns.
--
See: cockroachdb#37768
Failed running "dump"
```

Release note (cli change): `cockroach dump` will now more clearly
refer to issue cockroachdb#37768 when it encounters a table with no visible
columns, which (currently) cannot be dumped successfully.
@knz knz removed the S-3-ux-surprise Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption. label Jul 8, 2019
@knz
Copy link
Contributor

knz commented Jul 8, 2019

Added clearer error in code in #38725, to remove the UX-surprise label.

craig bot pushed a commit that referenced this issue Jul 8, 2019
37199: storage: propagate errors from contentionQueue, catch stalls in roachtest r=nvanbenschoten a=nvanbenschoten

Informs #36089.

The PR is split into a series of commits. The first fixes part of a bug that was causing #36089  to fail (thanks to #36748) and the second improves the test to have a more obvious failure condition for this class of bug in the future. The third, fifth, and sixth clean up code. Finally, the fourth fixes another bug that could cause issues with #36089.

Before the first commit, requests could get stuck repeatedly attempting to push a transaction only to repeatedly find that they themselves were already aborted. The error would not propagate up to the transaction coordinator and the request would get stuck. This commit fixes this behavior by correctly propagating errors observed by the `contentionQueue`.

The second commit bumps the TxnLivenessThreshold for clusters running `kv/contention/nodes=4` to 10 minutes. This is sufficiently large such that if at any point a transaction is abandoned then all other transactions will begin waiting for it, throughput will drop to 0 for 10 straight minutes, and the test will fail to achieve its minimum QPS requirement.

The fourth commit instructs pushers in the `txnwait.Queue` to inform all other pushers that are waiting for the same transaction when it observes an ABORTED transaction. I never saw this cause issues with #36089, but it seems very possible that it could given frequent tscache rotations.

38397: sql: deflake TestLogic//crdb_internal/max_retry_counter r=knz a=knz

Fixes #38062.

Release note: None

38654: exec: Handle NULLS in TopK sorter r=rohany a=rohany

This commit fixes NULLs in the TopK sorter by avoiding use
of the vec copy method, which has a bug. Instead, we add
a set method to the vec comparator, and use the templatized
comparator to perform the sets that the TopK sorter needs.

To facilitate this, we add an UnsetNull method to the Nulls
object. However, use of this method results in HasNull()
maybe returning true even if the vector doesn't have nulls.
This behavior already occurs when selection vectors are used.
Based on discussions with @solongordon and @asubiotto, this behavior
is OK, and future PR's will attempt to make this behavior better, and address
the bugs within the Vec Copy method.

38725: cli/dump: more clearly inform the user upon tables with no visible columns r=knz a=knz

Informs #37768.
Informs #28948.
This is coming up quite often on support, lately again on gitter and forum https://forum.cockroachlabs.com/t/error-while-dumping-core-backup/2901/3.

This PR aims to lessen the burden on support and propose a clear "next action" for the user.

Before:

```
kena@kenax ~/cockroach % ./cockroach dump --insecure defaultdb
CREATE TABLE t (,
        FAMILY "primary" (rowid)
);
Error: pq: at or near "from": syntax error
Failed running "dump"
```

After:

```
kena@kenax ~/cockroach % ./cockroach dump --insecure defaultdb
CREATE TABLE t (,
        FAMILY "primary" (rowid)
);
Error: table "defaultdb.public.t" has no visible columns
HINT: To proceed with the dump, either omit this table from the list of tables to dump, drop the table, or add some visible columns.
--
See: #37768
Failed running "dump"
```

Release note (cli change): `cockroach dump` will now more clearly
refer to issue #37768 when it encounters a table with no visible
columns, which (currently) cannot be dumped successfully.

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
@jseldess
Copy link
Contributor

Known limitation documented in cockroachdb/docs#5671.

@C0rWin
Copy link
Contributor

C0rWin commented Mar 13, 2020

Hey,

I would like to take a look and address the issue described here. However, currently looking into this ticket I have few reservations with what should be expected outcome or behavior in such a case. Moreover, I do not really understand the use case or what is the rational behind columns less table.

Anyway, would it be correct to expect that given

CREATE DATABASE foo;
CREATE TABLE bar();

the output should be

CREATE TABLE bar (FAMILY "primary" (rowid)
);

INSERT INTO bar (rowid) VALUES
        (XXXXXXX),
        (YYYYYYY);
….
….
        (ZZZZZZZZ);

did I get it right?

@knz
Copy link
Contributor

knz commented Mar 14, 2020

I do not really understand the use case or what is the rational behind columns less table.

I think it's useful to think about "Column-less tables" as "tables with no visible columns" (but where they may be non-visible columns). Also, these are a regular feature of most SQL engines, so regardless of whether you can discern a purpose to them they're just a fact of life that crdb has to support well.

the output should be [...]

The INSERT part I agree with. In fact, I would even strongly recommend to make the hidden columns (incl rowid) explicit for all tables, not just column-less tables.

As to the CREATE part, it's definitely odd to see the rowid column mentioned in the FAMILY but not being defined explicitly.
On the other hand, it would be a mistake to emit CREATE TABLE ...(rowid INTEGER DEFAULT ... because then the column would flip from non-visible to visible when restoring a dump.

I think there are two steps here:

  1. make it possible to use the word HIDDEN in CREATE, to mark a column as non-visible. In essence this would be reviving PR sql: add proper support for hidden columns #26644

  2. use the new HIDDEN word when generating the CREATE statement in cockroach dump

What do you think?

@C0rWin
Copy link
Contributor

C0rWin commented Mar 14, 2020

I think there are two steps here:

1. make it possible to use the word `HIDDEN` in CREATE, to mark a column as non-visible. In essence this would be reviving PR #26644

2. use the new HIDDEN word when generating the CREATE statement in `cockroach dump`

What do you think?

Isn't it "too intrusive" change? Just to make sure I've got it correctly, you suggestions is to explicitly mention non-visible columns within CREATE statement, hence it will appear during the dump. E.g.

CREATE TABLE foo(rowid int HIDDEN,
FAMILY "primary" (rowid))

I'm not an expert but it seems quite intrusive change relatively to changing behavior of showFamilyClause to handle non-visible columns. For instance I've played a bit with code and got following change https://gist.github.com/C0rWin/90424d770de16cb0ec3c7ad8bc180a26.

Probably it might make sense to divide the effort and introduce a change where we change showFamiliyClause, then adding support to enhance CREATE statement with ability to specify hidden columns explicitly. Will something like this make sense?

@knz
Copy link
Contributor

knz commented Mar 15, 2020

I agree these two changes should be done in separate commits.
Also you can probably reuse some code from #26644.

(nit: perhaps NOT VISIBLE is the better syntax choice, rather than HIDDEN).

@C0rWin
Copy link
Contributor

C0rWin commented Mar 21, 2020

@knz create a PR#46406 which achieves functionality claimed in this ticket. Would something like this make sense?

@craig craig bot closed this as completed in 1a51a57 Apr 16, 2020
@lopezator
Copy link
Contributor Author

Thanks for addressing the issue @C0rWin !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-disaster-recovery C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. docs-done docs-known-limitation X-anchored-telemetry The issue number is anchored by telemetry references.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants