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

more descriptive test failure issues #34

Merged
merged 1 commit into from
Dec 15, 2015
Merged

more descriptive test failure issues #34

merged 1 commit into from
Dec 15, 2015

Conversation

tbg
Copy link
Owner

@tbg tbg commented Dec 15, 2015

the issues will now have a list of failed tests in the subject.
each failing test has a bright red label created and assigned to
its issues.

the issues will now have a list of failed tests in the subject.
each failing test has a bright red label created and assigned to
its issues.
@tbg tbg merged this pull request into master Dec 15, 2015
@tbg tbg deleted the better_failures branch December 15, 2015 18:16
tbg added a commit that referenced this pull request Aug 31, 2016
We have been seeing long startup times which disappear spontaneously. During a
restart of the beta cluster, the following goroutine was observed, which suggests
that we were spending a lot of time GCing replicas on startup.

    engine              ??:0                     _Cfunc_DBIterNext(cockroachdb#324, cockroachdb#323, 0, 0, 0, 0, 0, 0, 0)
    engine              rocksdb.go:1135          (*rocksDBIterator).Next(cockroachdb#235)
    storage             replica_data_iter.go:104 (*ReplicaDataIterator).Next(cockroachdb#316)
    storage             store.go:1748            (*Store).destroyReplicaData(#109, cockroachdb#317, 0, 0)
    storage             store.go:841             (*Store).Start.func2(0x101b, cockroachdb#300, 0x36, 0x40, cockroachdb#301, 0x36, 0x40, cockroachdb#315, 0x3, 0x4, ...)
    storage             store.go:734             IterateRangeDescriptors.func1(cockroachdb#306, 0x40, 0x41, cockroachdb#307, 0x92, 0x92, cockroachdb#341, 0, 0x186c, 0x4000, ...)
    engine              mvcc.go:1593             MVCCIterate(cockroachdb#329, #68, #47, #81, cockroachdb#232, 0x9, 0x10, cockroachdb#233, 0xb, 0x10, ...)
    storage             store.go:738             IterateRangeDescriptors(cockroachdb#330, cockroachdb#196, #47, #81, cockroachdb#195, #179, #110)
    storage             store.go:867             (*Store).Start(#109, cockroachdb#330, cockroachdb#196, #179, cockroachdb#185, 0x1)
    server              node.go:405              (*Node).initStores(#78, cockroachdb#330, cockroachdb#196, #98, 0x1, 0x1, #179, 0, #55)
    server              node.go:330              (*Node).start(#78, cockroachdb#330, cockroachdb#196, #42, #129, #98, 0x1, 0x1, 0, 0, ...)
    server              server.go:431            (*Server).Start(#5, cockroachdb#330, cockroachdb#196, #95, 0x1)
    cli                 start.go:368             runStart(#34, #178, 0, 0x9, 0, 0)
    cobra               command.go:599           (*Command).execute(#34, #177, 0x9, 0x9, #34, #177)
    cobra               command.go:689           (*Command).ExecuteC(#33, #70, cockroachdb#343, #72)
    cobra               command.go:648           (*Command).Execute(#33, #71, cockroachdb#343)
    cli                 cli.go:96                Run(#64, 0xa, 0xa, 0, 0)
    main                main.go:37               main()
tbg added a commit that referenced this pull request Aug 31, 2016
We have been seeing long startup times which disappear spontaneously. During a
restart of the beta cluster, the following goroutine was observed, which suggests
that we were spending a lot of time GCing replicas on startup.

    engine              ??:0                     _Cfunc_DBIterNext(cockroachdb#324, cockroachdb#323, 0, 0, 0, 0, 0, 0, 0)
    engine              rocksdb.go:1135          (*rocksDBIterator).Next(cockroachdb#235)
    storage             replica_data_iter.go:104 (*ReplicaDataIterator).Next(cockroachdb#316)
    storage             store.go:1748            (*Store).destroyReplicaData(#109, cockroachdb#317, 0, 0)
    storage             store.go:841             (*Store).Start.func2(0x101b, cockroachdb#300, 0x36, 0x40, cockroachdb#301, 0x36, 0x40, cockroachdb#315, 0x3, 0x4, ...)
    storage             store.go:734             IterateRangeDescriptors.func1(cockroachdb#306, 0x40, 0x41, cockroachdb#307, 0x92, 0x92, cockroachdb#341, 0, 0x186c, 0x4000, ...)
    engine              mvcc.go:1593             MVCCIterate(cockroachdb#329, #68, #47, #81, cockroachdb#232, 0x9, 0x10, cockroachdb#233, 0xb, 0x10, ...)
    storage             store.go:738             IterateRangeDescriptors(cockroachdb#330, cockroachdb#196, #47, #81, cockroachdb#195, #179, #110)
    storage             store.go:867             (*Store).Start(#109, cockroachdb#330, cockroachdb#196, #179, cockroachdb#185, 0x1)
    server              node.go:405              (*Node).initStores(#78, cockroachdb#330, cockroachdb#196, #98, 0x1, 0x1, #179, 0, #55)
    server              node.go:330              (*Node).start(#78, cockroachdb#330, cockroachdb#196, #42, #129, #98, 0x1, 0x1, 0, 0, ...)
    server              server.go:431            (*Server).Start(#5, cockroachdb#330, cockroachdb#196, #95, 0x1)
    cli                 start.go:368             runStart(#34, #178, 0, 0x9, 0, 0)
    cobra               command.go:599           (*Command).execute(#34, #177, 0x9, 0x9, #34, #177)
    cobra               command.go:689           (*Command).ExecuteC(#33, #70, cockroachdb#343, #72)
    cobra               command.go:648           (*Command).Execute(#33, #71, cockroachdb#343)
    cli                 cli.go:96                Run(#64, 0xa, 0xa, 0, 0)
    main                main.go:37               main()
tbg pushed a commit that referenced this pull request May 17, 2017
**tl;dr** use `\set display_format raw` before a query to get the strings unmodified

Background
----------

One of the inconveniences of SHOW CREATE TABLE is that its output, by
default, encloses the generated CREATE TABLE statement in an ASCII art
table, like this:

````
root@:26257/> SHOW CREATE TABLE t.kv;
+-------+------------------------------------------------+
| Table |                  CreateTable                   |
+-------+------------------------------------------------+
| t.kv  | CREATE TABLE kv (␤                             |
|       |     k INT NOT NULL,␤                           |
|       |     v INT NULL,␤                               |
|       |     CONSTRAINT "primary" PRIMARY KEY (k ASC),␤ |
|       |     FAMILY "primary" (k, v)␤                   |
|       | )                                              |
+-------+------------------------------------------------+
(1 row)
```

This prevents copy-pasting the output directly onto some other
shell or text file.

Meanwhile, our SQL CLI shell *does* provide alternative ways to print
out the results, that can be selected with `\set display_format ...`;
however, none of the formats defined so far are able to print out the
above CREATE TABLE statement **in a way that can be copy-pasted
elsewhere**; for example:

```
root@:26257/> \set display_format html
root@:26257/> SHOW CREATE TABLE t.kv;
<table>
<thead><tr><th>Table</th><th>CreateTable</th></tr></head>
<tbody>
<tr><td>t.kv</td><td>CREATE TABLE kv (<br/>     k INT NOT NULL,<br/>    v INT NULL,<br/>
    CONSTRAINT &#34;primary&#34; PRIMARY KEY (k ASC),<br/>  FAMILY &#34;primary&#34; (k, v)<br/>)</td></tr>
</tbody>
</table>
```

(This replaces all special characters)

```
root@:26257/> \set display_format csv
root@:26257/> SHOW CREATE TABLE t.kv;
1 row
Table,CreateTable
t.kv,"CREATE TABLE kv (
        k INT NOT NULL,
        v INT NULL,
        CONSTRAINT ""primary"" PRIMARY KEY (k ASC),
        FAMILY ""primary"" (k, v)
)"
```

(This escapes the double quotes by doubling them, which renders the SQL invalid)

And so forth.

Solution: new display format
----------------------------

The `cockroach sql` CLI shell (as well as any built-in command that
emits tables) can use a custom display format configurable either with
`--format` on the command-line, or `\set display_format` in the shell.

This patch adds a new format `raw` which causes the string
representation of every record to be printed as-is, starting on its
own line, so that it can be copy-pasted from a terminal.

This format makes an extra mile to ensure the data can be further
processed: each record is prefixed by an annotation of the form `# N`
followed by a newline character, where *N* is the number of characters
in the record, starting with the first character following the
newline. A subsequent automated processing tool can use this
information to determine record boundaries.

Application
-----------

```
root@:26257/> select createtable from [show create table t.kv];
...
CREATE TABLE kv (
        k INT NOT NULL,
        v INT NULL,
        CONSTRAINT "primary" PRIMARY KEY (k ASC),
        FAMILY "primary" (k, v)
)
...
```

Tada!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant