Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
cockroachdb/cockroach
AALEKH/cockroach
Abioy/cockroach
AflenChen/cockroach
Arifur794/cockroach
CodEnFisH/cockroach
DilipLukose/cockroach
El-Coder/cockroach
Frank-Jin/cockroach
GavinHwa/cockroach
GokulSrinivas/cockroach
GrayMissing/cockroach
HanumathRao/cockroach
HengWang/cockroach
HunterChen/cockroach
InsaneYoungStunner/cockroach
Kevin-GuanJian/cockroach
Linicks/cockroach
PragashSiva/cockroach
RaduBerinde/cockroach
SandyZeng/cockroach
Viewtiful/cockroach
XuWanHong/cockroach-1
Zemnmez/cockroach
a-robinson/cockroach
abhishekgahlot/cockroach
alex/cockroach
alisheikh/cockroach
anchal-agrawal/cockroach
andradeandrey/cockroach
angel1991521/cockroach
ansonism/cockroach
axfcampos/cockroach
banks/cockroach
bdarnell/cockroach
bdotdub/cockroach
bigrats/cockroach
bigxing/cockroach
bobpattersonjr/cockroach
bowlofstew/cockroach
brandenyoon/cockroach
briliant1991/cockroach
bussiere/cockroach
bydsky/cockroach
cDoru/cockroach
cainiao1989/cockroach
cdsalmons/cockroach
chagge/cockroach
chunshengster/cockroach
cleverdeng/cockroach
clm971910/cockroach
cn15810092493/cockroach
connecteev/cockroach
dallasmarlow/cockroach
darkseed/cockroach
db-production/cockroach
dfrsg/cockroach
diegode/cockroach
domluna/cockroach
eagle518/cockroach
easyfmxu/cockroach
eclectice/cockroach
elvin-du/cockroach
embark/cockroach
erriapo/cockroach
es-chow/cockroach
esaul/cockroach
flyingliang/cockroach
gaowenbin/cockroach
ghostsun/cockroach
gqf2008/cockroach
grimreaper/cockroach
gstarnberger/cockroach
gude/cockroach
guiquanz/cockroach
hannibalhuang/cockroach
hanshenu/cockroach
hanwoody/cockroach
hcxiong/cockroach
hollis/cockroach
hubt/cockroach
hunslater/cockroach
iamima/cockroach
icattlecoder/cockroach
ikarzali/cockroach
ilovejs/cockroach
jackylk/cockroach
jamesgraves/cockroach
jamiepg1/cockroach
jay23jack/cockroach
jess-edwards/cockroach
jinguoxing/cockroach
jmank88/cockroach
joezxy/cockroach
joliny/cockroach
jonathanmarvens/cockroach
josephwinston/cockroach
josephyzhou/cockroach
joshuawatson/cockroach
jrcjc123/cockroach
jsanc623/cockroach
kanasite/cockroach
kebohiki/cockroach
kkaneda/cockroach
kortschak/cockroach
kritivasas/cockroach
kuguobing/cockroach
lemonhall/cockroach
leomzhong/cockroach
lessc0de/cockroach
lianhuiwang/cockroach
liuzongquan/cockroach
lostz/cockroach
lshmouse/cockroach
luan-cestari/cockroach
lupengfeige/cockroach
mabdullah353/cockroach
mackjoner/cockroach
maniksurtani/cockroach
manithnuon/cockroach
markreg/cockroach
matadorhong/cockroach
meshileya/cockroach
mindis/cockroach
mixiong/cockroach
mjibson/cockroach
mobilipia/cockroach
mohae/cockroach
mrunix/cockroach
msmakhlouf/cockroach
nanderoo/cockroach
neuroradiology/cockroach
neutony/cockroach
nikelius/cockroach
nimishzynga/cockroach
nkgfirecream/cockroach
nmarasoiu/cockroach
ofonimefrancis/cockroach
oldmantaiter/cockroach
ollyblue/cockroach
petermattis/cockroach
picolonet/storage
pinterb/cockroach
pramendra/cockroach
putaozhuose/cockroach
r00tjimmy/cockroach
ramgtv/cockroach
rayleyva/cockroach
sandeepmukho/cockroach
sawanoboly/cockroach
scrooph/cockroach
sdboyer/cockroach
shafiahmed/cockroach
shanyechen/cockroach
shilezi/cockroach
silky/cockroach
slavau/cockroach
sunya123/cockroach
superneo/cockroach
swarbiv/cockroach
sxhao/cockroach
tamird/cockroach
therob3000/cockroach
timwee/cockroach
tml/cockroach
tomzhang/cockroach
toshisam/cockroach
trebogeer/cockroach
treemantris/cockroach
tristartom/cockroach
truthwzl/cockroach
tschottdorf/cockroach
udybrill/cockroach
umegaya/cockroach
vikram/cockroach
vivekmenezes/cockroach
vvydier/cockroach
waderly/cockroach
walkingsparrow/cockroach
wangtuanjie/cockroach
wheelcomplex/cockroach
willmadison/cockroach
wulinjun4/cockroach
wuyu201321060203/cockroach
wycg1984/cockroach
xiaoyulei/cockroach
yacki/cockroach
yananzhi/cockroach
yangyaoweng/cockroach
yanniyang/cockroach
yekeqiang/cockroach
yemaocheng/cockroach
yonglehou/cockroach
zeeshanali/cockroach
zhaixuezhong/cockroach
zhangchn/cockroach
zhanglei/cockroach
zhonghai/cockroach
zimmermamc/cockroach
zofuthan/cockroach
Nothing to show
Choose a Head Repository
cockroachdb/cockroach
AALEKH/cockroach
Abioy/cockroach
AflenChen/cockroach
Arifur794/cockroach
CodEnFisH/cockroach
DilipLukose/cockroach
El-Coder/cockroach
Frank-Jin/cockroach
GavinHwa/cockroach
GokulSrinivas/cockroach
GrayMissing/cockroach
HanumathRao/cockroach
HengWang/cockroach
HunterChen/cockroach
InsaneYoungStunner/cockroach
Kevin-GuanJian/cockroach
Linicks/cockroach
PragashSiva/cockroach
RaduBerinde/cockroach
SandyZeng/cockroach
Viewtiful/cockroach
XuWanHong/cockroach-1
Zemnmez/cockroach
a-robinson/cockroach
abhishekgahlot/cockroach
alex/cockroach
alisheikh/cockroach
anchal-agrawal/cockroach
andradeandrey/cockroach
angel1991521/cockroach
ansonism/cockroach
axfcampos/cockroach
banks/cockroach
bdarnell/cockroach
bdotdub/cockroach
bigrats/cockroach
bigxing/cockroach
bobpattersonjr/cockroach
bowlofstew/cockroach
brandenyoon/cockroach
briliant1991/cockroach
bussiere/cockroach
bydsky/cockroach
cDoru/cockroach
cainiao1989/cockroach
cdsalmons/cockroach
chagge/cockroach
chunshengster/cockroach
cleverdeng/cockroach
clm971910/cockroach
cn15810092493/cockroach
connecteev/cockroach
dallasmarlow/cockroach
darkseed/cockroach
db-production/cockroach
dfrsg/cockroach
diegode/cockroach
domluna/cockroach
eagle518/cockroach
easyfmxu/cockroach
eclectice/cockroach
elvin-du/cockroach
embark/cockroach
erriapo/cockroach
es-chow/cockroach
esaul/cockroach
flyingliang/cockroach
gaowenbin/cockroach
ghostsun/cockroach
gqf2008/cockroach
grimreaper/cockroach
gstarnberger/cockroach
gude/cockroach
guiquanz/cockroach
hannibalhuang/cockroach
hanshenu/cockroach
hanwoody/cockroach
hcxiong/cockroach
hollis/cockroach
hubt/cockroach
hunslater/cockroach
iamima/cockroach
icattlecoder/cockroach
ikarzali/cockroach
ilovejs/cockroach
jackylk/cockroach
jamesgraves/cockroach
jamiepg1/cockroach
jay23jack/cockroach
jess-edwards/cockroach
jinguoxing/cockroach
jmank88/cockroach
joezxy/cockroach
joliny/cockroach
jonathanmarvens/cockroach
josephwinston/cockroach
josephyzhou/cockroach
joshuawatson/cockroach
jrcjc123/cockroach
jsanc623/cockroach
kanasite/cockroach
kebohiki/cockroach
kkaneda/cockroach
kortschak/cockroach
kritivasas/cockroach
kuguobing/cockroach
lemonhall/cockroach
leomzhong/cockroach
lessc0de/cockroach
lianhuiwang/cockroach
liuzongquan/cockroach
lostz/cockroach
lshmouse/cockroach
luan-cestari/cockroach
lupengfeige/cockroach
mabdullah353/cockroach
mackjoner/cockroach
maniksurtani/cockroach
manithnuon/cockroach
markreg/cockroach
matadorhong/cockroach
meshileya/cockroach
mindis/cockroach
mixiong/cockroach
mjibson/cockroach
mobilipia/cockroach
mohae/cockroach
mrunix/cockroach
msmakhlouf/cockroach
nanderoo/cockroach
neuroradiology/cockroach
neutony/cockroach
nikelius/cockroach
nimishzynga/cockroach
nkgfirecream/cockroach
nmarasoiu/cockroach
ofonimefrancis/cockroach
oldmantaiter/cockroach
ollyblue/cockroach
petermattis/cockroach
picolonet/storage
pinterb/cockroach
pramendra/cockroach
putaozhuose/cockroach
r00tjimmy/cockroach
ramgtv/cockroach
rayleyva/cockroach
sandeepmukho/cockroach
sawanoboly/cockroach
scrooph/cockroach
sdboyer/cockroach
shafiahmed/cockroach
shanyechen/cockroach
shilezi/cockroach
silky/cockroach
slavau/cockroach
sunya123/cockroach
superneo/cockroach
swarbiv/cockroach
sxhao/cockroach
tamird/cockroach
therob3000/cockroach
timwee/cockroach
tml/cockroach
tomzhang/cockroach
toshisam/cockroach
trebogeer/cockroach
treemantris/cockroach
tristartom/cockroach
truthwzl/cockroach
tschottdorf/cockroach
udybrill/cockroach
umegaya/cockroach
vikram/cockroach
vivekmenezes/cockroach
vvydier/cockroach
waderly/cockroach
walkingsparrow/cockroach
wangtuanjie/cockroach
wheelcomplex/cockroach
willmadison/cockroach
wulinjun4/cockroach
wuyu201321060203/cockroach
wycg1984/cockroach
xiaoyulei/cockroach
yacki/cockroach
yananzhi/cockroach
yangyaoweng/cockroach
yanniyang/cockroach
yekeqiang/cockroach
yemaocheng/cockroach
yonglehou/cockroach
zeeshanali/cockroach
zhaixuezhong/cockroach
zhangchn/cockroach
zhanglei/cockroach
zhonghai/cockroach
zimmermamc/cockroach
zofuthan/cockroach
Nothing to show
Commits on Oct 07, 2018
knz
sql: properly support CTEs inside views
Release note (sql change): CockroachDB now supports CTEs inside views.
Commits on Oct 10, 2018
Revert "Merge #30924"
This reverts commit 472d36f, reversing
changes made to 6b912fa.

Release note: None
Commits on Oct 11, 2018
sqlbase: ShouldSplitAtIDHook should return false for unknown IDs
If descriptor value is not found for a given ID, the hook
should immediately say that it shouldn't be considered for a split.

Release note: None
sql: add EXPLAIN(DISTSQL) support for subqueries
This currently does not provide the plans for the subqueries
themselves, just the outer query. But this no longer pops up the old
error message of "subqueries not supported", preventing a UX problem
where some queries are explainable and some are not.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
ui: scope table padding under debug index panel section class
...so it doesn't apply to the jobs page and other pages.

Release note: None
craig[bot] and vilterp
Merge #31244
31244: ui: scope table padding under debug index panel section class r=vilterp a=vilterp

...so it doesn't apply to the jobs page and other pages.

This styling for the debug pages also applied to the jobs page (and the custom graph page), but the debug index and jobs page changes were both on master.

|             | Before                                                                                                     | After                                                                                                      | Expectation |
|-------------|------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|-------------|
| Jobs Page   | ![image](https://user-images.githubusercontent.com/7341/46781401-6fd0b900-ccef-11e8-9a8d-a85e36f00cd6.png) | ![image](https://user-images.githubusercontent.com/7341/46781383-50399080-ccef-11e8-9c1a-05af81a026c8.png) | Fix vertical line that shows up in expanded area |
| Debug Index | ![image](https://user-images.githubusercontent.com/7341/46781426-90990e80-ccef-11e8-8f7d-d4d1ebec6fbe.png) | ![image](https://user-images.githubusercontent.com/7341/46781367-41eb7480-ccef-11e8-814f-8897d6734b2f.png) | Same        |

Release note: None

Co-authored-by: Pete Vilter <vilterp@cockroachlabs.com>
sql: fix flaky TestShowQueries
There was a potential data race, and an incorrect check for a common
query (it's SHOW CLUSTER SETTING version, not capital VERSION).

Release note: None
sql: delete db zone config after GC TTL
Previously the database's zone config would be deleted immediately when
a DROP DATABASE is initiated, including if there are tables that the
drop cascades down to. This causes dropped tables waiting for the GC
period without a table zone config to have values from the default
config to be applied (which can cause unnecessary data movement).

This change removes the database's zone config once all the cascaded
table data is completely removed, using the dropped table status in the
job details.

Release note: None
craig[bot] and eriktrinh
Merge #30666
30666: sql: delete db zone config after GC TTL r=eriktrinh a=eriktrinh

Previously the database's zone config would be deleted immediately when
a DROP DATABASE is initiated, including if there are tables that the
drop cascades down to. This causes dropped tables waiting for the GC
period without a table zone config to have values from the default
config to be applied (which can cause unnecessary data movement).

This change removes the database's zone config once all the cascaded
table data is completely removed, using the dropped table status in the
job details.

Fixes #24179.

Co-authored-by: Erik Trinh <erik@cockroachlabs.com>
craig[bot] and ridwanmsharif
Merge #31230
31230: sqlbase: ShouldSplitAtIDHook should return false for unknown IDs r=ridwanmsharif a=ridwanmsharif

If descriptor value is not found for a given ID, the hook
should immediately say that it shouldn't be considered for a split.

I think this resolves #31128.

Release note: None

Co-authored-by: Ridwan Sharif <ridwan@cockroachlabs.com>
craig[bot] and jordanlewis
Merge #31241
31241: sql: fix flaky TestShowQueries r=jordanlewis a=jordanlewis

There was a potential data race, and an incorrect check for a common
query (it's SHOW CLUSTER SETTING version, not capital VERSION).

Closes #29628.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
sql: add merge joiner benchmark and memory account shrinking optimiza…
…tion

Merge joiner benchmark comparison against `release-2.1`

```
name                           old time/op    new time/op    delta
MergeJoiner/InputSize=0-8        4.31µs ±10%    4.33µs ±15%      ~     (p=0.968 n=10+9)
MergeJoiner/InputSize=4-8        8.34µs ± 3%    8.10µs ± 4%      ~     (p=0.074 n=8+9)
MergeJoiner/InputSize=16-8       16.3µs ± 2%    11.1µs ± 5%   -31.87%  (p=0.000 n=9+9)
MergeJoiner/InputSize=256-8       190µs ± 2%      85µs ± 2%   -55.04%  (p=0.000 n=10+8)
MergeJoiner/InputSize=4096-8     2.96ms ± 2%    1.28ms ± 2%   -56.86%  (p=0.000 n=10+10)
MergeJoiner/InputSize=65536-8    49.0ms ± 5%    20.6ms ± 1%   -57.88%  (p=0.000 n=10+10)

name                           old alloc/op   new alloc/op   delta
MergeJoiner/InputSize=0-8        6.42kB ± 0%    6.65kB ± 0%    +3.49%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4-8        9.50kB ± 0%    9.72kB ± 0%    +2.36%  (p=0.000 n=10+10)
MergeJoiner/InputSize=16-8       9.50kB ± 0%    9.72kB ± 0%    +2.36%  (p=0.000 n=10+10)
MergeJoiner/InputSize=256-8      32.5kB ± 0%    32.8kB ± 0%    +0.69%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4096-8      401kB ± 0%     401kB ± 0%    +0.06%  (p=0.000 n=9+10)
MergeJoiner/InputSize=65536-8    6.30MB ± 0%    6.30MB ± 0%    +0.00%  (p=0.000 n=9+10)

name                           old allocs/op  new allocs/op  delta
MergeJoiner/InputSize=0-8          14.0 ± 0%      15.0 ± 0%    +7.14%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4-8          16.0 ± 0%      17.0 ± 0%    +6.25%  (p=0.000 n=10+10)
MergeJoiner/InputSize=16-8         16.0 ± 0%      17.0 ± 0%    +6.25%  (p=0.000 n=10+10)
MergeJoiner/InputSize=256-8        46.0 ± 0%      47.0 ± 0%    +2.17%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4096-8        526 ± 0%       527 ± 0%    +0.19%  (p=0.000 n=10+10)
MergeJoiner/InputSize=65536-8     8.21k ± 0%     8.21k ± 0%    +0.01%  (p=0.000 n=10+10)

name                           old speed      new speed      delta
MergeJoiner/InputSize=4-8      7.67MB/s ± 3%  7.91MB/s ± 4%      ~     (p=0.070 n=8+9)
MergeJoiner/InputSize=16-8     15.7MB/s ± 2%  23.0MB/s ± 5%   +46.89%  (p=0.000 n=9+9)
MergeJoiner/InputSize=256-8    21.6MB/s ± 2%  48.0MB/s ± 2%  +122.41%  (p=0.000 n=10+8)
MergeJoiner/InputSize=4096-8   22.1MB/s ± 2%  51.3MB/s ± 2%  +131.81%  (p=0.000 n=10+10)
MergeJoiner/InputSize=65536-8  21.4MB/s ± 5%  50.8MB/s ± 1%  +137.16%  (p=0.000 n=10+10)
```

Release note: None
craig[bot] and a-robinson
Merge #31227
31227: storage: Jitter the StoreRebalancer loop's timing r=a-robinson a=a-robinson

Release note: None

Just as a best practice. It may make failures like #31006 even less likely, although it's hard to say for sure.

Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
sql: run show cluster setting in a restartable txn
Previously, SHOW CLUSTER SETTING would run in the parent txn. This was
troublesome because if it misses a KV update once (due to an older txn
timestamp), it'll miss it in perpetuity.

Now, we make a fresh transaction for the kv read, and allow it to
restart.

Release note: None
craig[bot] and jordanlewis
Merge #30721
30721: sql: run show cluster setting in a restartable txn r=jordanlewis a=jordanlewis

Previously, SHOW CLUSTER SETTING would run in the parent txn. This was
troublesome because if it misses a KV update once (due to an older txn
timestamp), it'll miss it in perpetuity.

Now, we make a fresh transaction for the kv read, and allow it to
restart.

Closes #30225.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
knz
sql: capture internal/assertion errors
Prior to this patch, assertion/internal errors were "merely" reported
to the client with pg error code CodeInternalError and nothing would
happen further. This was causing 2 problems:

- it was unclear for the user what to do with this information.
- the occurrences were not further collected and could not be used to
  track bugs automatically.

This patch improves the situation as follows:

- a new constructor `pgerror.NewAssertionErrorf` is introduced, which:
  - gives a hint to the user about submitting the error as a bug with
    details.
  - populates the InternalCommand with a shortened stack trace.

- the new constructor is used instead of
  `pgerror.NewErrorf(pgerror.CodeInternalError` throughout the SQL
  layer.

- the reporting mechanism now detects CodeInternalError errors,
  collects then reports them with other node statistics.

Before:

```
root@127.0.0.1:56399/defaultdb> select crdb_internal.force_assertion_error('woo');
pq: crdb_internal.force_assertion_error(): programming error: woo
```

After:

```
root@127.0.0.1:63733/defaultdb> select crdb_internal.force_Assertion_error('woo');
pq: crdb_internal.force_assertion_error(): programming error: woo
DETAIL: builtins.go:2805,eval.go:3547,expr.go:194,processors.go:378,processors.go:745,values.go:125,base.go:170,processors.go:768,flow.go:596,distsql_running.go:261,distsql_running.go:768,conn_executor_exec.go:983,conn_executor_exec.go:825,conn_executor_exec.go:403,conn_executor_exec.go:95,conn_executor.go:1189,conn_executor.go:466,conn.go:309
HINT: You have encountered an error inside CockroachDB. Don't worry! Your data is likely safe.

Please report this error with details at:
    https://github.com/cockroachdb/cockroach/issues/new/choose
or
    support@cockroachlabs.com

Thank you!
```

Release note (sql change): CockroachDB will now hint that internal
errors should be reported as bugs by users. Additionally, internal
errors are now collected internally and submitted (anonymized) with
other node statistics when statistic collection is enabled.
craig[bot] and knz
Merge #31261
31261: sql: capture and report internal/assertion errors r=knz a=knz

Requested by @petermattis. Desired by @awoods187. Inspired by @tschottdorf.

Prior to this patch, assertion/internal errors were "merely" reported
to the client with pg error code CodeInternalError and nothing would
happen further. This was causing 2 problems:

- it was unclear for the user what to do with this information.
- the occurrences were not further collected and could not be used to
  track bugs automatically.

This patch improves the situation as follows:

- a new constructor `pgerror.NewAssertionErrorf` is introduced, which:
  - gives a hint to the user about submitting the error as a bug with
    details.
  - populates the InternalCommand with a shortened stack trace.

- the new construct is used instead of
  `pgerror.NewErrorf(pgerror.CodeInternalError` throughout the SQL
  layer.

- the reporting mechanism now detects CodeInternalError errors,
  collects then reports them with other node statistics.

Before:

```
root@127.0.0.1:56399/defaultdb> select crdb_internal.force_assertion_error('woo');
pq: crdb_internal.force_assertion_error(): programming error: woo
```

After:

```
root@127.0.0.1:63733/defaultdb> select crdb_internal.force_Assertion_error('woo');
pq: crdb_internal.force_assertion_error(): programming error: woo
DETAIL: builtins.go:2805,eval.go:3547,expr.go:194,processors.go:378,processors.go:745,values.go:125,base.go:170,processors.go:768,flow.go:596,distsql_running.go:261,distsql_running.go:768,conn_executor_exec.go:983,conn_executor_exec.go:825,conn_executor_exec.go:403,conn_executor_exec.go:95,conn_executor.go:1189,conn_executor.go:466,conn.go:309
HINT: You have encountered an error inside CockroachDB. Don't worry! Your data is likely safe.

Please report this error with details at:
    https://github.com/cockroachdb/cockroach/issues/new/choose
or
    support@cockroachlabs.com

Thank you!
```

Release note (sql change): CockroachDB will now hint that internal
errors should be reported as bugs by users. Additionally, internal
errors are now collected internally and submitted (anonymized) with
other node statistics when statistic collection is enabled.

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
craig[bot] and a-robinson
Merge #31270
31270: sqlmigrations: Downgrade log message from error to info r=a-robinson a=a-robinson

Fixes #31269

Release note: None

Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
knz
sql: fix the schema type check for INSERT/UPSERT
The types of the input data for a mutation (the data source clause for
INSERT/UPSERT, the result of SET RHS for UPDATE) must match the types
of the columns being mutated.

Prior to this patch, this check was properly done early by UPDATE,
however it was not done at the right time for INSERT/UPSERT.

The code for INSERT/UPSERT was relying on an assertion check very deep
down in the encoding of datums to KV values. This assertion check was
never meant to be an input validation check, but because Go does not
really give us semantic assertions nobody noticed the check was
abused.

This patch clarifies the situation by introducing
`pgerror.NewAssertionErrorf` and using it there as appropriate. Later
patches can introduce more uses of pgerror.NewAssertionErrorf where
appropriate (e.g. everywhere we already use CodeInternalError).

In addition, the proper check for INSERT/UPSERT is introduced at the
right place, early during semantic analysis.

Release note (bug fix): CockroachDB will no longer fail in unexpected
ways or write invalid data when the type of input values provided to
INSERT/UPSERT does not match the type of the target columns.
knz
sql: ensure UPDATE checks column constraints before CHECK constraints
This is required for postgres compatibility: the CHECK expressions
must be able to assume that the column data is already valid according
to the column type and nullability constraint.

The code for INSERT/UPSERT was already valid, only UPDATE needed to be
fixed. However this patch provides the corresponding test for all 3
mutations.

Release note (bug fix): UPDATE now verifies the column constraints
before CHECK constraints, for compatibility with PostgreSQL.
knz
sql: add missing mutation check tests
The mutations must validate column constraints before they perform FK
checks. There were no clear tests for this. This patch adds the
missing tests.

Release note: None
knz
sql: prevent UPDATE RETURNING from seeing non-public columns
Prior to this patch, it was possible to use a newly added but not yet
visible column in UPDATE RETURNING. This patch fixes it.

INSERT/UPSERT/DELETE were not affected, however this patch adds the
corresponding tests for all 4 mutation statements -- this aspect
was not tested before.

Release note (bug fix): It is not possible any more to use
not-fully-added-yet columns in the RETURNING clause of UPDATE
statements.
knz
sql: add a missing comment
Release note: None
knz
sql: prevent INSERT DO UPDATE from silently setting computed columns
Release note (bug fix): CockroachDB does no longer incorrectly and
silently accept a computed column on the left side of the assignment
in a ON CONFLICT DO UPDATE SET clause.
knz
sql: prevent INSERT DO UPDATE SET from assigning mutation columns
This is a band aid, a refactoring of the upsert pipeline is required
for a more robust solution.

Release note (bug fix): CockroachDB does no longer incorrectly and
silently accept a not-fully-added-yet column on the left side of the
assignment in a ON CONFLICT DO UPDATE SET clause.
craig[bot] and arjunravinarayan
Merge #30857
30857: sql: add EXPLAIN(DISTSQL) support for subqueries r=jordanlewis a=arjunravinarayan

This currently does not provide the plans for the subqueries
themselves, just the outer query. But this no longer pops up the old
error message of "subqueries not supported", preventing a UX problem
where some queries are explainable and some are not.

Fixes #28729.

Release note: None

Co-authored-by: Arjun Narayan <arjun@cockroachlabs.com>
sql: make DISTSQL option to EXPLAIN ANALYZE optional
Reduce user surprise by not requiring a DISTSQL option in EXPLAIN
ANALYZE.

Release note (sql change): EXPLAIN ANALYZE <statement> is now a valid
equivalent of EXPLAIN ANALYZE (DISTSQL) <statement>
craig[bot] and asubiotto
Merge #31277
31277: sql: make DISTSQL option to EXPLAIN ANALYZE optional r=asubiotto a=asubiotto

Reduce user surprise by not requiring a DISTSQL option in EXPLAIN
ANALYZE.

Release note (sql change): EXPLAIN ANALYZE <statement> is now a valid
equivalent of EXPLAIN ANALYZE (DISTSQL) <statement>

Co-authored-by: Alfonso Subiotto Marqués <alfonso@cockroachlabs.com>
craig[bot] and knz
Merge #31007 #31222
31007: sql: properly support CTEs inside views r=knz a=knz

Fixes #23833.


31222: sql: assorted mutation fixes r=knz a=knz

Fixes #25742.
Fixes #26106.
Fixes #29494.
Fixes #31255.
Fixes #29497.

~This may even full address #26106 but I have a couple more checks to add first to confirm this.~ edit: it does



Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
roachtest: move cmd/zerosum to a roachtest
see: 29486

Release note: None
3 authors
Merge #31216 #31219
31216: sql: add merge joiner benchmark and bytes usage optimization r=changangela a=changangela

Reverted #30924 for now to compare different approaches (discussed in #31191). This PR is mainly for adding some merge joiner benchmarks as well a small change in `BoundAccount.Shrink()` that significantly improves the merge joiner performance. This way, we can safely backport this change.

MergeJoinerBenchmark against `release-2.1`:

```
name                           old time/op    new time/op    delta
MergeJoiner/InputSize=0-8        4.31µs ±10%    4.33µs ±15%      ~     (p=0.968 n=10+9)
MergeJoiner/InputSize=4-8        8.34µs ± 3%    8.10µs ± 4%      ~     (p=0.074 n=8+9)
MergeJoiner/InputSize=16-8       16.3µs ± 2%    11.1µs ± 5%   -31.87%  (p=0.000 n=9+9)
MergeJoiner/InputSize=256-8       190µs ± 2%      85µs ± 2%   -55.04%  (p=0.000 n=10+8)
MergeJoiner/InputSize=4096-8     2.96ms ± 2%    1.28ms ± 2%   -56.86%  (p=0.000 n=10+10)
MergeJoiner/InputSize=65536-8    49.0ms ± 5%    20.6ms ± 1%   -57.88%  (p=0.000 n=10+10)

name                           old alloc/op   new alloc/op   delta
MergeJoiner/InputSize=0-8        6.42kB ± 0%    6.65kB ± 0%    +3.49%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4-8        9.50kB ± 0%    9.72kB ± 0%    +2.36%  (p=0.000 n=10+10)
MergeJoiner/InputSize=16-8       9.50kB ± 0%    9.72kB ± 0%    +2.36%  (p=0.000 n=10+10)
MergeJoiner/InputSize=256-8      32.5kB ± 0%    32.8kB ± 0%    +0.69%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4096-8      401kB ± 0%     401kB ± 0%    +0.06%  (p=0.000 n=9+10)
MergeJoiner/InputSize=65536-8    6.30MB ± 0%    6.30MB ± 0%    +0.00%  (p=0.000 n=9+10)

name                           old allocs/op  new allocs/op  delta
MergeJoiner/InputSize=0-8          14.0 ± 0%      15.0 ± 0%    +7.14%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4-8          16.0 ± 0%      17.0 ± 0%    +6.25%  (p=0.000 n=10+10)
MergeJoiner/InputSize=16-8         16.0 ± 0%      17.0 ± 0%    +6.25%  (p=0.000 n=10+10)
MergeJoiner/InputSize=256-8        46.0 ± 0%      47.0 ± 0%    +2.17%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4096-8        526 ± 0%       527 ± 0%    +0.19%  (p=0.000 n=10+10)
MergeJoiner/InputSize=65536-8     8.21k ± 0%     8.21k ± 0%    +0.01%  (p=0.000 n=10+10)

name                           old speed      new speed      delta
MergeJoiner/InputSize=4-8      7.67MB/s ± 3%  7.91MB/s ± 4%      ~     (p=0.070 n=8+9)
MergeJoiner/InputSize=16-8     15.7MB/s ± 2%  23.0MB/s ± 5%   +46.89%  (p=0.000 n=9+9)
MergeJoiner/InputSize=256-8    21.6MB/s ± 2%  48.0MB/s ± 2%  +122.41%  (p=0.000 n=10+8)
MergeJoiner/InputSize=4096-8   22.1MB/s ± 2%  51.3MB/s ± 2%  +131.81%  (p=0.000 n=10+10)
MergeJoiner/InputSize=65536-8  21.4MB/s ± 5%  50.8MB/s ± 1%  +137.16%  (p=0.000 n=10+10)
```

MergeJoinerBenchmark compared with `master` (`master` already has this exact optimization, we want to ensure that the performance did not deteriorate)
```
name                                          old time/op    new time/op    delta
MergeJoiner/InputSize=0-8                       4.61µs ± 9%    4.45µs ± 5%     ~     (p=0.060 n=10+10)
MergeJoiner/InputSize=4-8                       8.34µs ± 6%    8.00µs ±10%   -4.09%  (p=0.037 n=9+10)
MergeJoiner/InputSize=16-8                      11.6µs ± 4%    11.4µs ± 5%     ~     (p=0.123 n=10+10)
MergeJoiner/InputSize=256-8                     88.3µs ± 3%    89.8µs ± 6%     ~     (p=0.258 n=9+9)
MergeJoiner/InputSize=4096-8                    1.33ms ± 4%    1.27ms ± 5%   -4.67%  (p=0.001 n=9+10)
MergeJoiner/InputSize=65536-8                   22.4ms ± 6%    21.3ms ±10%     ~     (p=0.052 n=10+10)
MergeJoiner/OneSideRepeatInputSize=0-8          4.57µs ±15%    4.38µs ± 6%     ~     (p=0.353 n=10+10)
MergeJoiner/OneSideRepeatInputSize=4-8          7.71µs ±10%    7.71µs ± 4%     ~     (p=0.549 n=10+9)
MergeJoiner/OneSideRepeatInputSize=16-8         11.8µs ±29%    10.5µs ± 6%  -10.77%  (p=0.043 n=10+10)
MergeJoiner/OneSideRepeatInputSize=256-8        82.8µs ± 4%    80.3µs ± 5%   -2.93%  (p=0.004 n=10+10)
MergeJoiner/OneSideRepeatInputSize=4096-8       1.25ms ± 2%    1.54ms ±13%  +23.09%  (p=0.000 n=9+10)
MergeJoiner/OneSideRepeatInputSize=65536-8      24.2ms ± 3%    26.7ms ± 9%  +10.08%  (p=0.000 n=10+9)
MergeJoiner/BothSidesRepeatInputSize=0-8        4.60µs ±10%    4.36µs ±10%     ~     (p=0.063 n=10+10)
MergeJoiner/BothSidesRepeatInputSize=4-8        7.13µs ± 4%    7.62µs ±17%   +6.84%  (p=0.005 n=9+10)
MergeJoiner/BothSidesRepeatInputSize=16-8       8.66µs ±14%    8.24µs ± 3%     ~     (p=0.549 n=10+9)
MergeJoiner/BothSidesRepeatInputSize=256-8      22.1µs ± 5%    23.2µs ± 9%   +5.06%  (p=0.004 n=9+10)
MergeJoiner/BothSidesRepeatInputSize=4096-8      219µs ± 4%     240µs ±25%     ~     (p=0.065 n=9+10)
MergeJoiner/BothSidesRepeatInputSize=65536-8    1.19ms ± 3%    1.17ms ± 1%   -2.18%  (p=0.001 n=10+9)

name                                          old alloc/op   new alloc/op   delta
MergeJoiner/InputSize=0-8                       6.66kB ± 0%    6.65kB ± 0%   -0.24%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4-8                       9.74kB ± 0%    9.72kB ± 0%   -0.16%  (p=0.000 n=10+10)
MergeJoiner/InputSize=16-8                      9.74kB ± 0%    9.72kB ± 0%   -0.16%  (p=0.000 n=10+10)
MergeJoiner/InputSize=256-8                     32.8kB ± 0%    32.8kB ± 0%   -0.05%  (p=0.000 n=10+10)
MergeJoiner/InputSize=4096-8                     401kB ± 0%     401kB ± 0%   -0.00%  (p=0.000 n=10+10)
MergeJoiner/InputSize=65536-8                   6.30MB ± 0%    6.30MB ± 0%   -0.00%  (p=0.000 n=10+10)
MergeJoiner/OneSideRepeatInputSize=0-8          6.66kB ± 0%    6.65kB ± 0%   -0.24%  (p=0.000 n=10+10)
MergeJoiner/OneSideRepeatInputSize=4-8          9.74kB ± 0%    9.72kB ± 0%   -0.16%  (p=0.000 n=10+10)
MergeJoiner/OneSideRepeatInputSize=16-8         9.74kB ± 0%    9.72kB ± 0%   -0.16%  (p=0.000 n=10+10)
MergeJoiner/OneSideRepeatInputSize=256-8        42.0kB ± 0%    42.0kB ± 0%   -0.04%  (p=0.000 n=10+10)
MergeJoiner/OneSideRepeatInputSize=4096-8        751kB ± 0%     751kB ± 0%   -0.00%  (p=0.000 n=10+10)
MergeJoiner/OneSideRepeatInputSize=65536-8      15.5MB ± 0%    15.5MB ± 0%   -0.00%  (p=0.000 n=10+10)
MergeJoiner/BothSidesRepeatInputSize=0-8        6.66kB ± 0%    6.65kB ± 0%   -0.24%  (p=0.000 n=10+10)
MergeJoiner/BothSidesRepeatInputSize=4-8        9.74kB ± 0%    9.72kB ± 0%   -0.16%  (p=0.000 n=10+10)
MergeJoiner/BothSidesRepeatInputSize=16-8       9.74kB ± 0%    9.72kB ± 0%   -0.16%  (p=0.000 n=10+10)
MergeJoiner/BothSidesRepeatInputSize=256-8      9.74kB ± 0%    9.72kB ± 0%   -0.16%  (p=0.000 n=10+10)
MergeJoiner/BothSidesRepeatInputSize=4096-8     14.3kB ± 0%    14.3kB ± 0%   -0.11%  (p=0.000 n=10+10)
MergeJoiner/BothSidesRepeatInputSize=65536-8    38.9kB ± 0%    38.9kB ± 0%   -0.04%  (p=0.000 n=10+10)

name                                          old allocs/op  new allocs/op  delta
MergeJoiner/InputSize=0-8                         15.0 ± 0%      15.0 ± 0%     ~     (all equal)
MergeJoiner/InputSize=4-8                         17.0 ± 0%      17.0 ± 0%     ~     (all equal)
MergeJoiner/InputSize=16-8                        17.0 ± 0%      17.0 ± 0%     ~     (all equal)
MergeJoiner/InputSize=256-8                       47.0 ± 0%      47.0 ± 0%     ~     (all equal)
MergeJoiner/InputSize=4096-8                       527 ± 0%       527 ± 0%     ~     (all equal)
MergeJoiner/InputSize=65536-8                    8.21k ± 0%     8.21k ± 0%     ~     (all equal)
MergeJoiner/OneSideRepeatInputSize=0-8            15.0 ± 0%      15.0 ± 0%     ~     (all equal)
MergeJoiner/OneSideRepeatInputSize=4-8            17.0 ± 0%      17.0 ± 0%     ~     (all equal)
MergeJoiner/OneSideRepeatInputSize=16-8           17.0 ± 0%      17.0 ± 0%     ~     (all equal)
MergeJoiner/OneSideRepeatInputSize=256-8          49.0 ± 0%      49.0 ± 0%     ~     (all equal)
MergeJoiner/OneSideRepeatInputSize=4096-8          536 ± 0%       536 ± 0%     ~     (all equal)
MergeJoiner/OneSideRepeatInputSize=65536-8       8.23k ± 0%     8.23k ± 0%     ~     (all equal)
MergeJoiner/BothSidesRepeatInputSize=0-8          15.0 ± 0%      15.0 ± 0%     ~     (all equal)
MergeJoiner/BothSidesRepeatInputSize=4-8          17.0 ± 0%      17.0 ± 0%     ~     (all equal)
MergeJoiner/BothSidesRepeatInputSize=16-8         17.0 ± 0%      17.0 ± 0%     ~     (all equal)
MergeJoiner/BothSidesRepeatInputSize=256-8        17.0 ± 0%      17.0 ± 0%     ~     (all equal)
MergeJoiner/BothSidesRepeatInputSize=4096-8       23.0 ± 0%      23.0 ± 0%     ~     (all equal)
MergeJoiner/BothSidesRepeatInputSize=65536-8      49.0 ± 0%      49.0 ± 0%     ~     (all equal)

name                                          old speed      new speed      delta
MergeJoiner/InputSize=4-8                     7.68MB/s ± 6%  8.02MB/s ± 9%   +4.43%  (p=0.037 n=9+10)
MergeJoiner/InputSize=16-8                    22.2MB/s ± 4%  22.6MB/s ± 5%     ~     (p=0.123 n=10+10)
MergeJoiner/InputSize=256-8                   46.4MB/s ± 3%  45.6MB/s ± 5%     ~     (p=0.231 n=9+9)
MergeJoiner/InputSize=4096-8                  49.2MB/s ± 4%  51.6MB/s ± 5%   +4.93%  (p=0.001 n=9+10)
MergeJoiner/InputSize=65536-8                 46.8MB/s ± 6%  49.3MB/s ± 9%     ~     (p=0.052 n=10+10)
MergeJoiner/OneSideRepeatInputSize=4-8        8.32MB/s ± 9%  8.31MB/s ± 4%     ~     (p=0.549 n=10+9)
MergeJoiner/OneSideRepeatInputSize=16-8       22.1MB/s ±24%  24.3MB/s ± 6%  +10.32%  (p=0.037 n=10+10)
MergeJoiner/OneSideRepeatInputSize=256-8      49.5MB/s ± 4%  51.0MB/s ± 5%   +3.03%  (p=0.003 n=10+10)
MergeJoiner/OneSideRepeatInputSize=4096-8     52.5MB/s ± 2%  42.8MB/s ±12%  -18.43%  (p=0.000 n=9+10)
MergeJoiner/OneSideRepeatInputSize=65536-8    43.3MB/s ± 3%  39.4MB/s ± 9%   -8.94%  (p=0.000 n=10+9)
MergeJoiner/BothSidesRepeatInputSize=4-8      8.98MB/s ± 4%  8.45MB/s ±15%   -5.96%  (p=0.005 n=9+10)
MergeJoiner/BothSidesRepeatInputSize=16-8     29.7MB/s ±13%  31.1MB/s ± 3%     ~     (p=0.549 n=10+9)
MergeJoiner/BothSidesRepeatInputSize=256-8     186MB/s ± 5%   177MB/s ± 8%   -4.73%  (p=0.004 n=9+10)
MergeJoiner/BothSidesRepeatInputSize=4096-8    299MB/s ± 3%   276MB/s ±21%     ~     (p=0.065 n=9+10)
MergeJoiner/BothSidesRepeatInputSize=65536-8   878MB/s ± 3%   898MB/s ± 1%   +2.22%  (p=0.001 n=10+9)
```

31219: kubernetes: Update request-cert image version to include recent fix r=a-robinson a=a-robinson

See cockroachdb/k8s#14

Release note: None

Co-authored-by: changangela <angelachang27@gmail.com>
Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
craig[bot] and m-schneider
Merge #31011
31011: roachtest: move cmd/zerosum to a roachtest r=m-schneider a=m-schneider

closes: 29486

Release note: None

Co-authored-by: Masha Schneider <masha@cockroachlabs.com>
kv,storage: annotate context cancellation errors
Previously, errors retrieved from cancelled context were frequently
passed up the stack without annotation, making it very difficult to
understand later what cancelled a context.

This commit annotates several potential context cancellation errors that
can occur on the synchronous query path with more context (no pun
intended).

Release note: None
sql, config: make zone configs cascade
Very much a WIP. Modifies the `ZoneConfig` struct to
make fields optional now. If fields are not set, they
are looked for in the heirarchy. Refer to the RFC for
more details.

Issue: #28901
Implements most of RFC: #30426

Release note: None
sql, config: set default values for constraints
Modify the Zone config structure so that the inheritance flag
for constraints and lease preferences are off by default for
backwards compatibility purposes

Release note: None
Commits on Oct 12, 2018
knz
sql: enable client to override index selection for DELETE and UPDATE
Prior to this patch, if the automatic index selection for DELETE or
UPDATE was inadequate, there was no way to override it like it is
possible for SELECT/INSERT/UPSERT.

This patch fixes this by extending and supporting the syntax for
DELETE and UPDATE:

```
DELETE FROM tbl@idx ...
UPDATE tbl@idx SET ...
```

Release note (sql change): it is now possible to force a specific
index for DELETE or UPDATE.
craig[bot] and knz
Merge #31012
31012: sql: enable client to override index selection for DELETE and UPDATE r=knz a=knz

Informs #30734.

Prior to this patch, if the automatic index selection for DELETE or
UPDATE was inadequate, there was no way to override it like it is
possible for SELECT/INSERT/UPSERT.

This patch fixes this by extending and supporting the syntax for
DELETE and UPDATE:

```
DELETE FROM tbl@idx ...
UPDATE tbl@idx SET ...
```

Release note (sql change): it is now possible to force a specific
index for DELETE or UPDATE.

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
dt
importccl: parse zero mysql dates as null
these nonsense values are permitted by older / less strict mysql
versions but have no cockroach counterpart -- a date is either null, or
an actual date, which cannot have a zero day or month. Mapping these
values to null is the closest we can get them, and in schemas that allow
null values, hopefully makes migration easier. In schemas that do not
allow nulls these will of course produce errors but we do not really
have another option in those cases.

Fixes #29298.

Release note: none.
*: move RowFetcher and co to a new package, row
This was purely mechanical renaming. The purpose is to lessen the width
of the sqlbase package, which is imported in many places.

The new package now depends on sqlbase, but far fewer packages consume
it than sqlbase.

Major changes:

RowFetcher -> row.Fetcher
RowUpdater -> row.Updater
RowDeleter -> row.Deleter

FK and cascade stuff -> row package

The only unfortunate thing here is that the FK enums all begin with
`row` now (e.g. `row.CheckDeletes`). It would be better if those got a
different package name, like `fk`, but I'll leave that refactor for
another time.

Release note: None
craig[bot] and dt
Merge #31288
31288: importccl: parse zero mysql dates as null r=dt a=dt

these nonsense values are permitted by older / less strict mysql versions but have no cockroach counterpart -- a date is either null, or an actual date, which cannot have a zero day or month. Mapping these values to null is the closest we can get them, and in schemas that allow null values, hopefully makes migration easier. In schemas that do not allow nulls these will of course produce errors but we do not really have another option in those cases.

Release note: none.

Co-authored-by: David Taylor <tinystatemachine@gmail.com>
craig[bot] and jordanlewis
Merge #31292
31292: *: move RowFetcher and co to a new package, row r=jordanlewis a=jordanlewis

This was purely mechanical renaming. The purpose is to lessen the width
of the sqlbase package, which is imported in many places.

The new package now depends on sqlbase, but far fewer packages consume
it than sqlbase.

Major changes:

RowFetcher -> row.Fetcher
RowUpdater -> row.Updater
RowDeleter -> row.Deleter

FK and cascade stuff -> row package

The only unfortunate thing here is that the FK enums all begin with
`row` now (e.g. `row.CheckDeletes`). It would be better if those got a
different package name, like `fk`, but I'll leave that refactor for
another time.

Somewhat related to #30001.

cc @dt, @benesch 

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
knz
deps: bump go-libedit
Release note (build change): CockroachDB can now be built from source
on macOS 10.14 (Mojave).
craig[bot] and knz
Merge #31306
31306: deps: bump go-libedit r=knz a=knz

Fixes #30765.

Release note (build change): CockroachDB can now be built from source
on macOS 10.14 (Mojave).

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
ccl/storageccl/engineccl: properly handle intents which straddle ssta…
…bles

An intent which straddles an sstable can lead an incremental iterator to
incorrectly ignore an sstable. In order to fix this, when an intent
straddles an sstable (i.e. the metadata key is the last key in the
sstable) we need to include the intent's timestamp in the timestamp
bounds. We don't need to do this for interior intents because we'll
already be including the intent's timestamp as it is contained in the
next key following the intent. Add
`TestMVCCIncrementalIteratorIntentStraddlesSStables` which demonstrates
the problem.

Fixes #28358

Release note (bug fix): Fix a rare scenario where a backup could
incorrectly include a key for a transaction which was aborted.
sql: Align timestamp math with PostgreSQL
Our implementation of time+duration math delegates to golang's
time.Time.AddDate(), which has different normalization semantics when compared
to PostgreSQL when normalizing invalid month-of-day values.

The most likely input case is that the duration will have no month component
and we can fall back to go's implementation.  Another fast-path of checking the
day-of-month allows us to skip the special-case logic for start dates that
aren't the 29th, 30th, or 31st of a month.

```
name                                      old time/op    new time/op    delta
Add/fast-path-by-no-months-in-duration-8    63.2ns ± 4%    64.8ns ± 1%      ~     (p=0.151 n=5+5)
Add/fast-path-by-day-number-8               70.5ns ± 5%    87.5ns ± 0%   +24.12%  (p=0.008 n=5+5)
Add/no-adjustment-8                         70.6ns ± 3%   196.4ns ± 0%  +178.11%  (p=0.008 n=5+5)
Add/with-adjustment-8                       68.1ns ± 3%   218.2ns ± 1%  +220.60%  (p=0.008 n=5+5)

(No difference in allocations)
```

Resolves #30976

Release note (backward-incompatible change): The normalized results of
certain timestamp + duration operations involving year or month durations have
been adjusted to agree with the values returned by PostgreSQL.

Release note (sql change): In cases such as '2018-01-31'::TIMESTAMP + '1
month', where an intermediate result of February 31st needs to be normalized,
previous versions of CockroachDB would advance to March 3.  Instead, we would
now "round down" to February 28th to agree with the values returned by
PostgreSQL.  This change also affects the results of `generate_sequence()` when
used with timestamps.
craig[bot] and bobvawter
Merge #31146
31146: sql: Align timestamp math with PostgreSQL r=bobvawter a=bobvawter

Our implementation of time+duration math delegates to golang's
time.Time.AddDate(), which has different rounding semantics when compared to
PostgreSQL when normalizing invalid month-of-day values.

The most likely input case is that the duration will have no month component
and we can fall back to go's implementation.  Another fast-path of checking the
day-of-month allows us to skip the special-case logic for start dates that
aren't the 29th, 30th, or 31st of a month.

```
name                                      old time/op    new time/op    delta
Add/fast-path-by-no-months-in-duration-8    63.2ns ± 4%    66.2ns ± 1%    +4.75%  (p=0.016 n=5+5)
Add/fast-path-by-day-number-8               70.5ns ± 5%    91.1ns ± 1%   +29.20%  (p=0.008 n=5+5)
Add/no-adjustment-8                         70.6ns ± 3%   206.8ns ± 1%  +192.83%  (p=0.008 n=5+5)
Add/with-adjustment-8                       68.1ns ± 3%   228.4ns ± 1%  +235.59%  (p=0.008 n=5+5)

(No difference in allocations)
```

Resolves #30976

Release note (sql change): The normalized results of certain timestamp +
duration operations involving year or month durations have been adjusted to
agree with the values returned by PostgreSQL.  In cases such as
'2018-01-31'::TIMESTAMP + '1 month', where an intermediate result of February
31st needs to be normalized, previous versions of CockroachDB would "round up"
to March 1.  Instead, we would now "round down" to February 28th to agree with
the values returned by PostgreSQL.  This change also affects the results of
`generate_sequence()` when used with timestamps.

Co-authored-by: Bob Vawter <bob@cockroachlabs.com>
craig[bot] and petermattis
Merge #31290
31290: ccl/storageccl/engineccl: properly handle intents which straddle sstables r=danhhz a=petermattis

An intent which straddles an sstable can lead an incremental iterator to
incorrectly ignore an sstable. In order to fix this, when an intent
straddles an sstable (i.e. the metadata key is the last key in the
sstable) we need to include the intent's timestamp in the timestamp
bounds. We don't need to do this for interior intents because we'll
already be including the intent's timestamp as it is contained in the
next key following the intent. Add
`TestMVCCIncrementalIteratorIntentStraddlesSStables` which demonstrates
the problem.

Fixes #28358

Release note (bug fix): Fix a rare scenario where a backup could
incorrectly include a key for a transaction which was aborted.

Co-authored-by: Peter Mattis <petermattis@gmail.com>
sql: remove dependency on storage.NodeLiveness
DistSQLPlanner needed to know about it, but just a single IsLive method.
Avoid the dependency by adding a small package-local interface.

Release note: None
storage: Avoid using different qps measurements in StoreRebalancer
It's better to use the same measurement for everything, especially
because it's the one that was used to compute the store's total QPS.

Fixes #31303

Release note: None
roachtest: Stop rebalance test as soon as it succeeds
Previously it would always run for the entire test duration even after
it achieved success, which was pretty annoying when stressing it.

There may be a more idiomatic way to do this. If so, I'd love to know.

Release note: None
craig[bot] and a-robinson
Merge #31323
31323: roachtest: Slightly increase timeout in rebalance-leases-by-load r=a-robinson a=a-robinson

Touches #31303

Release note: None

Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
craig[bot] and a-robinson
Merge #31289
31289: roachtest: Stop rebalance test as soon as it succeeds r=a-robinson a=a-robinson

Previously it would always run for the entire test duration even after
it achieved success, which was pretty annoying when stressing it.

There may be a more idiomatic way to do this. If so, I'd love to know.

Release note: None

Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
roachtest: allow running roachtests on AWS
Add a `--cloud` flag (default "gce") which allows running roachtests on
"aws". Refactor some of the GCE specific code to also support AWS.

Fixes #29334

Release note: None
craig[bot] and jordanlewis
Merge #31291
31291: kv,storage: annotate context cancellation errors r=jordanlewis a=jordanlewis

Previously, errors retrieved from cancelled context were frequently
passed up the stack without annotation, making it very difficult to
understand later what cancelled a context.

This commit annotates several potential context cancellation errors that
can occur on the synchronous query path with more context (no pun
intended).

Hopefully informs #30886, #31094, #30659, etc.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
sql, settings: add a version for CascadingZoneConfigs
This is meant for the 2.1-1 version. It updates the version file
and some tests that rely on it. When the cluster version is higher,
then and only then will the cascading zone configs take hold.
Also changes output of the `SHOW ZONE CONFIGURATIONS` command
to only show explicitly set fields.

Release note (sql change): Changes the result for `show all zone
configurations` and `show zone configuration for ...`. Also
changes how zone configuration changes behave.
craig[bot] and ridwanmsharif
Merge #30611
30611: sql, config: make zone configs cascade r=ridwanmsharif a=ridwanmsharif

Modifies the `ZoneConfig` struct to
make fields optional now. If fields are not set, they
are looked for in the heirarchy. Refer to the RFC for
more details.

Issue: #28901
Implements most of RFC: #30426

TODO:
- [x] Update `set_zone_config` to use the new structure and validate them
- [x] Exhaustively test cascading zone configs

Release note: Changes behavior of Zone Configs.

Co-authored-by: Ridwan Sharif <ridwan@cockroachlabs.com>
craig[bot] and petermattis
Merge #31314
31314: roachtest: allow running roachtests on AWS r=andreimatei a=petermattis

Add a `--cloud` flag (default "gce") which allows running roachtests on
"aws". Refactor some of the GCE specific code to also support AWS.

Fixes #29334

Release note: None

Co-authored-by: Peter Mattis <petermattis@gmail.com>
storage: move storage TestingKnobs to storagebase
... to permit users of TestingKnobs not to have to import all of
storage.

Also, move batcheval.TestingKnobs to storagebase.BatchEvalTestingKnobs
to avoid the import cycle of storagebase -> batcheval -> storagebase.

Also, delete an unused TestingKnob that accepted Replica as a parameter.

Release note: None
roachtest: cluster ctors no longer take a test
The divorcing of clusters from tests is now unavoidable, and this patch
is another step in that direction.
This patch changes the cluster ctors to not take a test at all. Instead,
c.setTest() needs to be called later to set c.t. The idea is that it can
be called multiple times on the same cluster (and also that eventually
it will not be needed at all).

Release note: None
roachtest: add CREATE INDEX on tpcc 1000 cluster
The roachtest creates an index against a table with
30M rows on a tpcc cluster with a 1000 warehouses.

The test takes around 3 hours to run.

Release note: None
craig[bot] and a-robinson
Merge #31324
31324: storage: Avoid using different qps measurements in StoreRebalancer r=a-robinson a=a-robinson

It's better to use the same measurement for everything, especially
because it's the one that was used to compute the store's total QPS.

Fixes #31303

Release note: None

Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
craig[bot] and jordanlewis
Merge #31317
31317: storage: move TestingKnobs to storagebase r=jordanlewis a=jordanlewis

... to permit users of TestingKnobs not to have to import all of
storage.

Also, delete an unused TestingKnob that accepted Replica as a parameter.

Updates #30001.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
Commits on Oct 13, 2018
*: move server/status -> server/status/statuspb
This allows dependents of the protobufs in server/status to not have to
depend on server/status.

Release note: None
sql: remove dependency on server/status
We were importing server/status to get the MetricsRecorder struct, but
we only use one method on it. Remove that edge by adding a narrowed
interface, local to sql.

Release note: None
storage: move protos to storagepb
This is a mechanical change that moves the protobufs that used to live
in storage to a new package, storagepb. The purpose of this change is to
permit packages (such as sql) that need just protobuf definitions in
storage to not have to depend on the whole storage package.

Release note: None
storage: move protos from storagebase to storagepb
... to be like other packages in CockroachDB, which keep their protos in
a "foopb" package.

Release note: None
craig[bot] and jordanlewis
Merge #31322
31322: storage: move protos to storagepb r=jordanlewis a=jordanlewis

This is a mechanical change that moves the protobufs that used to live
in storage to a new package, storagepb. The purpose of this change is to
permit packages (such as sql) that need just protobuf definitions in
storage to not have to depend on the whole storage package.

First 2 commits are #31309.

Updates #30001.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
storage: move MergeQueueEnabled to storagebase
... to avoid dependency edge from sql to storage.

Release note: None
craig[bot] and jordanlewis
Merge #31312
31312: storage: move MergeQueueEnabled to storagebase r=jordanlewis a=jordanlewis

... to avoid dependency edge from sql to storage.

Updates #30001.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
knz
sql/parser: annotate unimplemented features with suitable errors
This patch recognizes more syntax from PostgreSQL for the purpose of
reporting more fine grained "unimplemented feature" errors.

- new:
  - CREATE/DROP
    AGGREGATE / CAST / COLLATION / CONVERSION / DOMAIN / EXTENSION /
    FOREIGN TABLE / FOREIGN DATA (WRAPPER) / FUNCTION / LANGUAGE /
    OPERATOR / PUBLICATION / RULE / SERVER / SUBSCRIPTION /
    TEXT (SEARCH) / TRIGGER / MATERIALIZED VIEW.
  - CREATE OR REPLACE VIEW
  - CREATE RECURSIVE VIEW
  - CREATE TEMP TABLE / VIEW / SEQUENCE and variants
  - CREATE INDEX USING GIST / HASH / SPGIST / BRIN
  - CREATE INDEX ... WHERE ... (partial indexes)
  - CREATE INDEX ON ... (<complex expr>)   (computed indexes)
  - CREATE GROUP is really an alias for CREATE USER and is not "unsupported"
  - type names point/circle/etc   (unsupported pg data types)
  - INTERVAL SECONDS / MINUTES / etc  (interval type with unit qualifier)
  - SELECT .. FOR UPDATE (and other locks)
  - Geometric types: POINT, CIRCLE etc
  - Other predefined pg types: XML, MACADDR, etc
  - Full text search: CREATE TEXT SEARCH, types TSVECTOR, TSQUERY, etc

- modified:
  - COMMENT ON accounting split in "table", "column" and other
  - TIMETZ support accounting split in "data type" and "current_time"
  - WITH RECURSIVE gets an issue number

Additionally unimplemented feature errors that stem during parsing
will now be prefixed with `syntax.` to ease integration in the feature
count hierarchy.

Release note: None
Commits on Oct 14, 2018
distsqlrun: fix tablereader microbenchmark
It wasn't doing any work besides the initial fetch by accident. Oops!
Numbers look much more realistic now.

```
name                      old time/op    new time/op    delta
TableReader/rows=16-8       68.1µs ± 2%    77.7µs ± 1%    +14.20%
(p=0.000 n=10+10)
TableReader/rows=256-8       139µs ± 3%     243µs ±11%    +75.45%
(p=0.000 n=10+10)
TableReader/rows=4096-8      745µs ± 1%    2172µs ± 1%   +191.62%
(p=0.000 n=10+9)
TableReader/rows=65536-8    9.94ms ± 2%   33.45ms ± 1%   +236.60%
(p=0.000 n=10+10)

name                      old speed      new speed      delta
TableReader/rows=16-8     3.76MB/s ± 2%  3.29MB/s ± 1%    -12.44%
(p=0.000 n=10+10)
TableReader/rows=256-8    29.5MB/s ± 3%  16.9MB/s ±10%    -42.89%
(p=0.000 n=10+10)
TableReader/rows=4096-8   88.0MB/s ± 1%  30.2MB/s ± 1%    -65.71%
(p=0.000 n=10+9)
TableReader/rows=65536-8   106MB/s ± 2%    31MB/s ± 1%    -70.29%
(p=0.000 n=10+10)

name                      old alloc/op   new alloc/op   delta
TableReader/rows=16-8       9.60kB ± 2%   10.06kB ± 2%     +4.78%
(p=0.000 n=10+10)
TableReader/rows=256-8      9.50kB ± 1%   17.93kB ± 2%    +88.67%
(p=0.000 n=9+9)
TableReader/rows=4096-8     9.58kB ± 2%  142.82kB ± 3%  +1390.41%
(p=0.000 n=8+10)
TableReader/rows=65536-8    20.8kB ±93%  2090.0kB ± 1%  +9924.14%
(p=0.000 n=10+9)

name                      old allocs/op  new allocs/op  delta
TableReader/rows=16-8         78.6 ± 1%      79.7 ± 1%     +1.40%
(p=0.001 n=10+10)
TableReader/rows=256-8        79.0 ± 0%      80.0 ± 0%     +1.27%
(p=0.000 n=9+8)
TableReader/rows=4096-8       79.0 ± 0%      83.7 ±12%     +5.95%
(p=0.000 n=8+10)
TableReader/rows=65536-8       100 ±45%       453 ± 3%   +354.81%
(p=0.000 n=10+9)
```

Release note: None
Commits on Oct 15, 2018
exec: add interface skeletons
Add the interface skeletons for column vector operators.

Release note: None
craig[bot] and jordanlewis
Merge #31185
31185: exec: add interface skeletons r=jordanlewis a=jordanlewis

Add the interface skeletons for column vector operators.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
exec: add physical types enum
An exec physical type corresponds to a particular type's bytes
representation, from the perspective of exec.

Release note: None
storage: de-race TestMergeQueue
It was mutating memory passed to the running cluster.

Fixes #31331.

Release note: None
roachtest: apply timeouts to import tests
These are generous based on passing runs observed during nightlies.

Release note: None
status: fix a comment
Passing `true` here gives results for each NIC. If `false` were passed,
things would be summed up and a single result returned.

Release note: None
craig[bot] and knz
Merge #31335
31335: sql/parser: annotate unimplemented features with suitable errors r=knz a=knz

Requested by @awoods187.
Fixes #28301.
Fixes #28304.
Fixes #28302.
Fixes #28300.
Fixes #28297.
Fixes #28295.
Fixes #28294.
Fixes #28292.

This patch recognizes more syntax from PostgreSQL for the purpose of
reporting more fine grained "unimplemented feature" errors.

- new:
  - CREATE/DROP
    AGGREGATE / CAST / COLLATION / CONVERSION / DOMAIN / EXTENSION /
    FOREIGN TABLE / FOREIGN DATA (WRAPPER) / FUNCTION / LANGUAGE /
    OPERATOR / PUBLICATION / RULE / SERVER / SUBSCRIPTION /
    TEXT (SEARCH) / TRIGGER / MATERIALIZED VIEW.
  - CREATE OR REPLACE VIEW
  - CREATE RECURSIVE VIEW
  - CREATE TEMP TABLE / VIEW / SEQUENCE and variants
  - CREATE INDEX USING GIST / HASH / SPGIST / BRIN
  - CREATE INDEX ... WHERE ... (partial indexes)
  - CREATE INDEX ON ... (<complex expr>)   (computed indexes)
  - CREATE GROUP is really an alias for CREATE USER and is not "unsupported"
  - type names point/circle/etc   (unsupported pg data types)
  - INTERVAL SECONDS / MINUTES / etc  (interval type with unit qualifier)
  - SELECT .. FOR UPDATE (and other locks)
  - Geometric types: POINT, CIRCLE etc
  - Other predefined pg types: XML, MACADDR, etc
  - Full text search: CREATE TEXT SEARCH, types TSVECTOR, TSQUERY, etc

- modified:
  - COMMENT ON accounting split in "table", "column" and other
  - TIMETZ support accounting split in "data type" and "current_time"
  - WITH RECURSIVE gets an issue number

Additionally unimplemented feature errors that stem during parsing
will now be prefixed with `syntax.` to ease integration in the feature
count hierarchy.

Release note: None

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
knz
sql: make heuristic planner bail on HAVING without FROM
The heuristic planner is unable to plan HAVING without FROM
properly. Instead of silently and incorrectly accepting this
construct, this patch makes it error out.

Release note (bug fix): CockroachDB does not any more silently and
incorrectly ignore the HAVING clause on SELECT without FROM.
storage: avoid merge deadlock when concurrent split wins
When merging two adjacent ranges P and Q, we need to be careful to
delete Q's range descriptor with a conditional put, or we can deadlock
with a concurrent split. See the comments and test case within for
details. This commit fixes the last issue that is blocking merges from
being turned on by default.

Release note: None
craig[bot] and benesch
Merge #31294
31294: storage: avoid merge deadlock when concurrent split wins r=tschottdorf,bdarnell a=benesch

@bdarnell, in a stroke of luck, the existing conditional put API supports deleting the existing value when you pass nil.

---

When merging two adjacent ranges P and Q, we need to be careful to
delete Q's range descriptor with a conditional put, or we can deadlock
with a concurrent split. See the comments and test case within for
details. This commit fixes the last issue that is blocking merges from
being turned on by default.

Release note: None

Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
craig[bot] and jordanlewis
Merge #31318
31318: sql: remove dependency on storage.NodeLiveness r=jordanlewis a=jordanlewis

DistSQLPlanner needed to know about it, but just a single IsLive method.
Avoid the dependency by adding a small package-local interface.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
craig[bot] and knz
Merge #31346
31346: sql: make heuristic planner bail on HAVING without FROM r=knz a=knz

Informs #26349.

The heuristic planner is unable to plan HAVING without FROM
properly. Instead of silently and incorrectly accepting this
construct, this patch makes it error out.

Release note (bug fix): CockroachDB does not any more silently and
incorrectly ignore the HAVING clause on SELECT without FROM.

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
craig[bot] and andreimatei
Merge #31267
31267: roachtest: cluster ctors no longer take a test r=andreimatei a=andreimatei

The divorcing of clusters from tests is now unavoidable, and this patch
is another step in that direction.
This patch changes the cluster ctors to not take a test at all. Instead,
c.setTest() needs to be called later to set c.t. The idea is that it can
be called multiple times on the same cluster (and also that eventually
it will not be needed at all).

Release note: None

Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
knz
sql: fold unimplemented/error telemetry into feature counters
This was discussed with @dt: use the feature counter machinery
instead of using separate maps. This simplifies the code.

Release note: None
knz
pgerror: hint what to do upon encountering unimplemented errors
Before:

```
root@127.0.0.1:28070/defaultdb> select * from information_schema.view_table_usage;
pq: virtual schema table not implemented: information_schema.view_table_usage
```

After:

```
root@127.0.0.1:28070/defaultdb> select * from information_schema.view_table_usage;
pq: virtual schema table not implemented: information_schema.view_table_usage
HINT: This feature is not yet implemented in CockroachDB.

Please check https://github.com/cockroachdb/cockroach/issues to check
whether this feature is already tracked. If you cannot find it there,
please report this error with example query at:

    https://github.com/cockroachdb/cockroach/issues/new/choose

If you would rather not post publicly, please contact us directly at:

    support@cockroachlabs.com

The Cockroach Labs team appreciates your feedback.
```

Release note: None
knz
sql: report unimplemented vtables in telemetry
Release note (sql change): CockroachDB will now collect references to
tables in `information_schema` and `pg_catalog` which are not yet
implemented, and report them as telemetry if statistics reporting is
enabled. This will help determine which features should be implemented
next for compatibility.
ui: Have the range debug page correctly handle missing lease times
Before this change, the value was always assumed to be not-null and it was null
would crash. It will now correctly handled the missing value and display a
`no timestamp` warning.

Fixes #31260.

Release note (bug fix): The range debug page will now correctly handle cases in
which there is no lease start or expiration time.
craig[bot] and knz
Merge #31333 #31356
31333: pgerror: hint what to do upon encountering unimplemented errors r=knz a=knz

Requested by @awoods187 . Inspired by @tschottdorf 

Before:

```
root@127.0.0.1:28070/defaultdb> select * from information_schema.view_table_usage;
pq: virtual schema table not implemented: information_schema.view_table_usage
```

After:

```
root@127.0.0.1:28070/defaultdb> select * from information_schema.view_table_usage;
pq: virtual schema table not implemented: information_schema.view_table_usage
HINT: This feature is not yet implemented in CockroachDB.

Please check https://github.com/cockroachdb/cockroach/issues to check
whether this feature is already tracked. If you cannot find it there,
please report this error with example query at:

    https://github.com/cockroachdb/cockroach/issues/new/choose

If you would rather not post publicly, please contact us directly at:

    support@cockroachlabs.com

The Cockroach Labs team appreciates your feedback.
```

Release note: None

31356: sql,telemetry: fold unimplemented/error telemetry into feature counters r=knz a=knz

Forked off  #31332.


Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
3 authors
Merge #31325 #31337 #31362
31325: sql: assert no dependencies on storage or CGo r=jordanlewis a=jordanlewis

No longer necessary for sql to depend on either storage or CGo - let's keep it that way!

All commits but last one from dependent PRs.

Closes #30001.

31337: distsqlrun: fix tablereader microbenchmark r=jordanlewis a=jordanlewis

It wasn't doing any work besides the initial fetch by accident. Oops!
Numbers look much more realistic now.

```
name                      old time/op    new time/op    delta
TableReader/rows=16-8       68.1µs ± 2%    77.7µs ± 1%    +14.20%
(p=0.000 n=10+10)
TableReader/rows=256-8       139µs ± 3%     243µs ±11%    +75.45%
(p=0.000 n=10+10)
TableReader/rows=4096-8      745µs ± 1%    2172µs ± 1%   +191.62%
(p=0.000 n=10+9)
TableReader/rows=65536-8    9.94ms ± 2%   33.45ms ± 1%   +236.60%
(p=0.000 n=10+10)

name                      old speed      new speed      delta
TableReader/rows=16-8     3.76MB/s ± 2%  3.29MB/s ± 1%    -12.44%
(p=0.000 n=10+10)
TableReader/rows=256-8    29.5MB/s ± 3%  16.9MB/s ±10%    -42.89%
(p=0.000 n=10+10)
TableReader/rows=4096-8   88.0MB/s ± 1%  30.2MB/s ± 1%    -65.71%
(p=0.000 n=10+9)
TableReader/rows=65536-8   106MB/s ± 2%    31MB/s ± 1%    -70.29%
(p=0.000 n=10+10)

name                      old alloc/op   new alloc/op   delta
TableReader/rows=16-8       9.60kB ± 2%   10.06kB ± 2%     +4.78%
(p=0.000 n=10+10)
TableReader/rows=256-8      9.50kB ± 1%   17.93kB ± 2%    +88.67%
(p=0.000 n=9+9)
TableReader/rows=4096-8     9.58kB ± 2%  142.82kB ± 3%  +1390.41%
(p=0.000 n=8+10)
TableReader/rows=65536-8    20.8kB ±93%  2090.0kB ± 1%  +9924.14%
(p=0.000 n=10+9)

name                      old allocs/op  new allocs/op  delta
TableReader/rows=16-8         78.6 ± 1%      79.7 ± 1%     +1.40%
(p=0.001 n=10+10)
TableReader/rows=256-8        79.0 ± 0%      80.0 ± 0%     +1.27%
(p=0.000 n=9+8)
TableReader/rows=4096-8       79.0 ± 0%      83.7 ±12%     +5.95%
(p=0.000 n=8+10)
TableReader/rows=65536-8       100 ±45%       453 ± 3%   +354.81%
(p=0.000 n=10+9)
```

Release note: None

31362: ui: Have the range debug page correctly handle missing lease times r=BramGruneir a=BramGruneir

Before this change, the value was always assumed to be not-null and it was null
would crash. It will now correctly handled the missing value and display a
`no timestamp` warning.

Fixes #31260.

Release note (bug fix): The range debug page will now correctly handle cases in
which there is no lease start or expiration time.

![screen shot 2018-10-15 at 10 35 07](https://user-images.githubusercontent.com/1614265/46958094-08a46300-d067-11e8-92cb-182882f8dd19.png)


Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
Co-authored-by: Bram Gruneir <bram@cockroachlabs.com>
knz
storage: fix typo in comment
Release note: None
craig[bot] and knz
Merge #31332
31332: sql: report unimplemented vtables in telemetry r=knz a=knz

Requested by @awoods187 
First two commits from  #31356.

Release note (sql change): CockroachDB will now collect references to
tables in `information_schema` and `pg_catalog` which are not yet
implemented, and report them as telemetry if statistics reporting is
enabled. This will help determine which features should be implemented
next for compatibility.

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
testcluster: fully disable the merge queue in manual replication mode
The merge queue needs to be disabled via cluster setting (and not
testing knob) in order for ALTER TABLE ... SPLIT AT to work.

Release note: None
storage: deflake TestLogMerges
This test needs the merge queue disabled.

Fix #31061.

Release note: None
storage: deflake TestStoreSetRangesMaxBytes
TestStoreSetRangesMaxBytes creates manual splits (using a horrendously
outdated function, but that's a problem for another day), so it can't
tolerate the merge queue.

Release note: None
distsqlplan: deflake TestMixedDirections and TestSpanResolver
These tests both need the merge queue to be disabled.

Fix #29321.
Fix #31060.

Release note: None
3 authors
Merge #31344 #31364
31344: status: fix a comment r=petermattis,vilterp a=tschottdorf

Passing `true` here gives results for each NIC. If `false` were passed,
things would be summed up and a single result returned.

Release note: None

31364: storage: fix typo in comment r=bdarnell a=benesch

Release note: None

Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
distsqlrun: fix Sampler test flake
The Sampler test verifies that the sampling is uniform by running it
many times and checking the frequencies. The probability of failure
decreases exponentially with `numRuns`.

The fix increases the number of runs to 5000 but to avoid slowing down
the test, we modify it to check every 200 runs (and exit early).

Fixes #31293.

Release note: None
roachtest: force splits in acceptance/bank's split monkey
When merges are enabled by default, splits need to be forced because
they will be quickly discard by the merge queue. In this test the goal
is maximum chaos, so having the ranges get merged away soon after they
split is desirable.

Release note: None
craig[bot] and tschottdorf
Merge #31341
31341: storage: de-race TestMergeQueue r=bdarnell a=tschottdorf

It was mutating memory passed to the running cluster.

Fixes #31331.

Release note: None

Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
tpccbench: run clusters in us-central1 by default
We've found that this region is less noisy.

Release note: None
tpccbench: upload cockroach to load gen nodes for chaos
The load nodes need the cockroach binary to generate their haproxy
config.

Release note: None
roachtest: tag the slack message with the cloud
For example, `[AWS]` or `[GCE]`.

Release note: None
changefeedccl: test changefeed with unspecified primary key
If the user doesn't specify a primary key when making the table, we add
one (a hidden `unique_rowid` column). This tests the behavior of a
changefeed over one of these tables.

Closes #31202

Release note: None
3 authors
Merge #31363 #31376
31363: distsqlrun: fix Sampler test flake r=RaduBerinde a=RaduBerinde

The Sampler test verifies that the sampling is uniform by running it
many times and checking the frequencies. The probability of failure
decreases exponentially with `numRuns`.

The fix increases the number of runs to 5000 but to avoid slowing down
the test, we modify it to check every 200 runs (and exit early).

Fixes #31293.

Release note: None

31376: roachtest: tag the slack message with the cloud r=benesch a=petermattis

For example, `[AWS]` or `[GCE]`.

Release note: None

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
Co-authored-by: Peter Mattis <petermattis@gmail.com>
sql: deflake TestSchemaChangePurgeFailure
Initially disable fast exec async schema changes in the test until the
error is seen and index drop is queued.

Fixes #31296.

Release note: None
server: Avoid using txn timestamp in gc test
Using transaction timstamp can lead to flaky tests.
Use constant timestamps while inserting events in rangelog
gc test.

Fixes #31371.

Release note: None
craig[bot] and benesch
Merge #29583
29583: storage: re-enable the merge queue by default r=tschottdorf a=benesch

This reverts commit a1cc4c5.

The results from last night's stress run on were extremely promising. All the failures were existing flaky tests. You can see for yourself here:

https://teamcity.cockroachdb.com/viewType.html?buildTypeId=Cockroach_Nightlies_Stress&tab=buildTypeStatusDiv&branch_Cockroach_Nightlies=refs%2Fheads%2Fmerge-default&state=failed

Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
tpccbench: fix chaos tests
Closes #31156.

The drain and quit chaos was not working well. For now, this switches
back to the hard chaos, which worked in the past and still works.

Release note: None
tpccbench: remove ulimit commands
These are no longer needed now that roachprod sets the
open file descriptor limit when creating clusters.

Release note: None
3 authors
Merge #31355 #31382
31355: sql: deflake TestSchemaChangePurgeFailure r=eriktrinh a=eriktrinh

Initially disable fast exec async schema changes in the test until the
error is seen and index drop is queued.

Fixes #31296.

Release note: None

31382: roachtest: Deflake bank/zerosum-splits' RelocateRange problem r=a-robinson a=a-robinson

Touches #31287

Release note: None

Co-authored-by: Erik Trinh <erik@cockroachlabs.com>
Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
roachtest/bank: don't start chaos until nodes are serving SQL
Informs #30064.

This prevents us from running into issues with SQL migrations.

Release note: None
changefeedccl: test cursor= edge cases
Closes #29661

Release note: None
craig[bot] and nvanbenschoten
Merge #30989
30989: roachtest/bank: don't start chaos until nodes are serving SQL r=nvanbenschoten a=nvanbenschoten

Informs #30064.

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
workload: add pgx-based SQLRunner, use it in KV
SQLRunner is a common facility for issuing SQL queries through `pgx`.
It supports multiple issuing methods, specified by the `--method`
flag:
 - prepare: each statement is prepared once per session and then
   reused.
 - noprepare: each statement is executed directly (which internally
   is equivalent to preparing and executing each statement
   separately).
 - simple: parameters are formatted as text and replaced in the query
   before it is issued.

KV is switched to use the new runner. The default `prepare` method
should be similar to the old code (except that we go through `pgx`).

Benchmark numbers (ops/s for kv80, single node GCE worker):
  - before:            30990 (541 stddev)
  - prepare (default): 31478 (331 stddev)
  - noprepare:         25506 (530 stddev)
  - simple:            29187 (599 stddev)

Release note: None
workload/ycsb: add support for uniform load distribution
Previously we could only run YCSB with a zipfian distribution, now we'll
be able to use a default uniform distribution.

Closes #30996

Release note: None
craig[bot] and RaduBerinde
Merge #31358
31358: workload: add pgx-based SQLRunner, use it in KV r=RaduBerinde a=RaduBerinde

SQLRunner is a common facility for issuing SQL queries through `pgx`.
It supports multiple issuing methods, specified by the `--method`
flag:
 - prepare: each statement is prepared once per session and then
   reused.
 - noprepare: each statement is executed directly (which internally
   is equivalent to preparing and executing each statement
   separately).
 - simple: parameters are formatted as text and replaced in the query
   before it is issued.

KV is switched to use the new runner. The default `prepare` method
should be similar to the old code (except that we go through `pgx`).

Benchmark numbers (ops/s for kv80, single node GCE worker):
  - before:            30990 (541 stddev)
  - prepare (default): 31478 (331 stddev)
  - noprepare:         25506 (530 stddev)
  - simple:            29187 (599 stddev)

Release note: None

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
roachtest: minor verification fix
The "cluster id" had been dropped in previous shuffles, probably because
I didn't truly understand what this function was doing.

Release note: None
craig[bot] and danhhz
Merge #31392
31392: changefeedccl: more tests r=mrtracy a=danhhz

See commits for details.

Co-authored-by: Daniel Harrison <daniel.harrison@gmail.com>
craig[bot] and m-schneider
Merge #31155
31155: workload/ycsb: add support for uniform load distribution r=m-schneider a=m-schneider

Previously we could only run YCSB with a zipfian distribution, now we'll
be able to use a default uniform distribution.

Closes #30996

Release note: None

Co-authored-by: Masha Schneider <masha@cockroachlabs.com>
roachtest: fix roachtest --cluster
A recent commit delayed the setting of c.t, but some functions used by
attachToExistingCluster() were not prepated to work without c.t set.
This test introduces c.StartE/WipeE flavors that can be run on a cluster
that hasn't a test set yet.

Release note: None
craig[bot] and andreimatei
Merge #31401
31401: roachtest: fix roachtest --cluster r=andreimatei a=andreimatei

A recent commit delayed the setting of c.t, but some functions used by
attachToExistingCluster() were not prepated to work without c.t set.
This test introduces c.StartE/WipeE flavors that can be run on a cluster
that hasn't a test set yet.

Release note: None

Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
craig[bot] and andreimatei
Merge #31399
31399: roachtest: minor verification fix r=andreimatei a=andreimatei

The "cluster id" had been dropped in previous shuffles, probably because
I didn't truly understand what this function was doing.

Release note: None

Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
cdc: Fix Sink Retries Again
Another small error made in the implementation of sink retries - in
order to provide a good UX for the CREATE CHANGEFEED statement, we want
to immediately service sink-related errors to the user when the
statement is executing. Once the changefeed job is created, however, we
retry (and log) errors from the sink. In the previous implementation,
this check was performed when the changefeed distsql processors were
instantiated; however, this occurs inside of the "Resume" method, which
can not easily tell if there is still a user statement waiting for
feedback. Therefore, we were not retrying on some errors that we should
have been retrying.

With this change, the "canary" sink used to detect these errors is moved
to the statement hook, which is only executed as part of the SQL
statement and not as part of the job's Resume loop, and therefore is not
subject to retries.

Release note: Fixed a bug where changefeeds may not correctly retry
temporary errors when communicating with a sink.
Commits on Oct 16, 2018
server(ccl)/ui: identify zone configs by zone name, not ID
Previously, the DataDistribution endpoint was returning a map of zone
configs by zone config ID. However, zone config ID is not a unique
identier within `crdb_internal.zones`, since subzones attached to
partitions share the same ID (that of the top-level zone config).

Zone names should be unique; this change uses those instead and updates
the UI accordingly.

This change also introduces a `serverccl` package for the unit test to
live in, since testing this code path requires creating partitions, a
CCL feature.

Release note: None
craig[bot] and vilterp
Merge #31407
31407: server(ccl)/ui: identify zone configs by zone name, not ID r=vilterp a=vilterp

Previously, the `DataDistribution` endpoint was returning a map of zone configs by zone config ID. However, zone config ID is not a unique identier within `crdb_internal.zones`, since subzones attached to partitions share the same ID (that of the top-level zone config), so map entries were being overwritten and the endpoint was returning an incomplete list.

Zone names should be unique; this change uses those instead and updates the UI accordingly.

This change also introduces a `serverccl` package for the unit test to live in, since testing this code path requires creating partitions, a CCL feature.

Fixes #27718

Release note: None

Co-authored-by: Pete Vilter <vilterp@cockroachlabs.com>
roachtest: fix stdout output
roachtest's intention is that if there's no parallelism is requested,
logs are teed to stdout/stderr in addition to the test.log file. No
parallelism is specified explicitly by passing -p 1, or implicitly by
running a single test.
This patch fixes a bug where the "implicit" part was no longer behaving
as expected wrt the logs. The bug was introduced by a previous patch
that tried to reduce the scope of the "parallelism" global, but missed
the use in rootLogger(); the inferring of parallelism=1 was no longer
modifying the global. This patch kills the global for good.

Release note: None
sql: deprecate TableDescriptor.UpVersion
The bit was already deprecated in 2.1. This removes all the
lingering code for the 2.2 release.

Release note: None
craig[bot] and vivekmenezes
Merge #31400
31400: sql: deprecate TableDescriptor.UpVersion r=vivekmenezes a=vivekmenezes

The bit was already deprecated in 2.1. This removes all the
lingering code for the 2.2 release.

Release note: None

Co-authored-by: Vivek Menezes <vivek@cockroachlabs.com>
craig[bot] and andreimatei
Merge #31405
31405: roachtest: fix stdout output r=andreimatei a=andreimatei

roachtest's intention is that if there's no parallelism is requested,
logs are teed to stdout/stderr in addition to the test.log file. No
parallelism is specified explicitly by passing -p 1, or implicitly by
running a single test.
This patch fixes a bug where the "implicit" part was no longer behaving
as expected wrt the logs. The bug was introduced by a previous patch
that tried to reduce the scope of the "parallelism" global, but missed
the use in rootLogger(); the inferring of parallelism=1 was no longer
modifying the global. This patch kills the global for good.

Release note: None

Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
craig[bot] and tschottdorf
Merge #31343
31343: roachtest: apply timeouts to import/restore tests r=petermattis a=tschottdorf

Make stuck tests less expensive, in particular since 32 node clusters are involved.

Touches #31184.

Release note: None

Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
craig[bot] and nvanbenschoten
Merge #31275
31275: tpccbench: various improvements to chaos and non-partitioned tests r=nvanbenschoten a=nvanbenschoten

Closes #31234.
Closes #31156.

cc. @awoods187 

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
workload: refactor tpccTx
Refactoring tpccTx to allow per-worker state. This will be necessary
for preparing statements in advance.

Release note: None
opt: build IS OF (...) expression
This commit builds expressions of the form x IS OF (...). This is an
optbuilder-only change since the value of such an expression is always
known at plan time.

This is also performed statically in Postgres, in the file
src/backend/parser/parse_expr.c in the function transformAExprOf.

This commit also partially fixes a bug in the heuristic planner's
implementation of this feature by using `Equivalent` instead of
`FamilyEqual` to compare types, resulting in `INT[]` being considered
distinct from `STRING[]`. It also exposes a bug that I think is
difficult to fix at the moment, which is that the lack of a 1-1 mapping
between datum and column types means the following is incorrectly
reported as true:

```
3::INT2 IS OF (INT4)
```

I've added relevant test cases and added a TODO for that case.

Tagging @knz for the heuristic planner change and also to put the
type-related bug on his radar.

Release note (bug fix): Fixed IS OF (...) expressions to no longer
report arrays with different element types as being the same.
craig[bot] and justinj
Merge #31393
31393: opt: build IS OF (...) expression r=justinj a=justinj

This commit builds expressions of the form x IS OF (...). This is an
optbuilder-only change since the value of such an expression is always
known at plan time.

This commit also partially fixes a bug in the heuristic planner's
implementation of this feature by using `Equivalent` instead of
`FamilyEqual` to compare types, resulting in `INT[]` being considered
distinct from `STRING[]`. It also exposes a bug that I think is
difficult to fix at the moment, which is that the lack of a 1-1 mapping
between datum and column types means the following is incorrectly
reported as true:

```
3::INT2 IS OF (INT4)
```

I've added relevant test cases and added a TODO for that case.

Tagging @knz for the heuristic planner change and also to put the
remaining type-related bug on his radar.

Release note (bug fix): Fixed IS OF (...) expressions to no longer
report arrays with different element types as being the same.

Co-authored-by: Justin Jaffray <justin@cockroachlabs.com>
craig[bot] and petermattis
Merge #31412
31412: build: bake aws into the builder image r=benesch a=petermattis

Release note: None

Co-authored-by: Peter Mattis <petermattis@gmail.com>
craig[bot] and vivekmenezes
Merge #31319
31319: roachtest: add CREATE INDEX on tpcc 1000 cluster r=vivekmenezes a=vivekmenezes

The roachtest creates an index against a table with
30M rows on a tpcc cluster with a 1000 warehouses.

The test takes around 3 hours to run.

Release note: None

Co-authored-by: Vivek Menezes <vivek@cockroachlabs.com>
dt
craig[bot] and dt
Merge #31467
31467: build: make build and tracing able to build cgo-free r=dt a=dt

Release note: none.

Co-authored-by: David Taylor <tinystatemachine@gmail.com>
dt
buildutil: fix bug in dependencies test
I think this was supposed to check each imported path against the prefix, not the package path itself over and over.

Release note: none.
craig[bot] and dt
Merge #31506
31506: buildutil: fix bug in dependencies test r=dt a=dt

I think this was supposed to check each imported path against the prefix, not the package path itself over and over.

Release note: none.

Co-authored-by: David Taylor <tinystatemachine@gmail.com>
craig[bot] and a-robinson
Merge #31503
31503: sql: De-flake merge queue race in TestScatterRandomizeLeases r=a-robinson a=a-robinson

Fixes #31456

Release note: None

Co-authored-by: Alex Robinson <alexdwanerobinson@gmail.com>
ui: make cluster overview layout more fluid
Fixes: #31414
Fixes: #24314
Release note (admin ui change): Improve the layout of the Cluster Overview
on large clusters with many nodes and ranges.
ui: fix the color of the logout link
Release note: None
craig[bot] and mrtracy
Merge #31410
31410: cdc: Fix Sink Retries Again r=danhhz a=mrtracy

Another small error made in the implementation of sink retries - in
order to provide a good UX for the CREATE CHANGEFEED statement, we want
to immediately service sink-related errors to the user when the
statement is executing. Once the changefeed job is created, however, we
retry (and log) errors from the sink. In the previous implementation,
this check was performed when the changefeed distsql processors were
instantiated; however, this occurs inside of the "Resume" method, which
can not easily tell if there is still a user statement waiting for
feedback. Therefore, we were not retrying on some errors that we should
have been retrying.

With this change, the "canary" sink used to detect these errors is moved
to the statement hook, which is only executed as part of the SQL
statement and not as part of the job's Resume loop, and therefore is not
subject to retries.

Release note: Fixed a bug where changefeeds may not correctly retry
temporary errors when communicating with a sink.

Co-authored-by: Matt Tracy <matt@cockroachlabs.com>
c-deps: bump CryptoPP to avoid SIGTRAP on macOS
Bump CryptoPP to pick up a fix for #31380.
Details reproduced below.

Fix #31380.

---

As part of its CPU feature detection, CryptoPP installs a SIGILL signal
handler before issuing the cpuid instruction. The intent is to
gracefully degrade on CPUs that don't support the cpuid instruction.

The problem is that it is impossible to safely overwrite a signal
handler installed by the Go runtime in go1.10 on macOS
(golang/go#22805). This causes CockroachDB 2.0 to crash on macOS Mojave:
#31380.

The situation has improved on the Go front, as go1.11 makes it possible
to safely save and restore signal handlers installed by the Go runtime
on macOS.

Still, we can do better and support go1.10. There is no need to bother
installing a SIGILL handler, as the cpuid instruction is supported by
every x86-64 CPU. We can instead use conditional compilation to make
sure that we never execute a cpuid instruction on a non x86-64 CPU.

Note that CPU feature detection is performed at executable load time
(see the attribute(constructor) on DetectX86Features); therefore any
reference to function which calls DetectX86Features (notably HasAESNI)
corrupts the signal handler. It's not entirely clear why this corruption
later leads to the SIGTRAP seen in #31380--is
something in macOS or the Go runtime generating a SIGILL and trying to
handle it gracefully?--but regardless, not mucking with the signal
handler fixes the issue.

Release note (bug fix): CockroachDB no longer crashes due to a SIGTRAP error
soon after startup on macOS Mojave (#31380).
roachtest: deflake acceptance/bank/zerosum-splits
This test requires that the experimental_force_split_at session var be
set to force ALTER ... SPLIT AT to work even with the merge queue
enabled. gosql.DB's connection pool will occasionally open a new
connection which does not have the var set. Set the session var in the
same batch of statements as the ALTER ... SPLIT AT command so that the
session var is always set in the session that executes the ALTER ...
SPLIT AT command.

Fix #31510.

Release note: None
workload: use SQLRunner for queries without tuples
Switch TPCC to use pgx; use SQLRunner for queries that have a fixed
number of arguments.

Release note: None
craig[bot] and mvijaykarthik
Merge #31420
31420: server: Avoid using txn timestamp in gc test r=tschottdorf a=mvijaykarthik

Using transaction timstamp can lead to flaky tests.
Use constant timestamps while inserting events in rangelog
gc test.

Fixes #31371.

Release note: None

Co-authored-by: Vijay Karthik <vijay.karthik@rubrik.com>
craig[bot] and benesch
Merge #31516 #31517
31516: c-deps: bump CryptoPP to avoid SIGTRAP on macOS r=mberhault a=benesch

Bump CryptoPP to pick up a fix for #31380.
Details reproduced below.

Fix #31380.

---

As part of its CPU feature detection, CryptoPP installs a SIGILL signal
handler before issuing the cpuid instruction. The intent is to
gracefully degrade on CPUs that don't support the cpuid instruction.

The problem is that it is impossible to safely overwrite a signal
handler installed by the Go runtime in go1.10 on macOS
(golang/go#22805). This causes CockroachDB 2.0 to crash on macOS Mojave:
#31380.

The situation has improved on the Go front, as go1.11 makes it possible
to safely save and restore signal handlers installed by the Go runtime
on macOS.

Still, we can do better and support go1.10. There is no need to bother
installing a SIGILL handler, as the cpuid instruction is supported by
every x86-64 CPU. We can instead use conditional compilation to make
sure that we never execute a cpuid instruction on a non x86-64 CPU.

Note that CPU feature detection is performed at executable load time
(see the attribute(constructor) on DetectX86Features); therefore any
reference to function which calls DetectX86Features (notably HasAESNI)
corrupts the signal handler. It's not entirely clear why this corruption
later leads to the SIGTRAP seen in #31380--is
something in macOS or the Go runtime generating a SIGILL and trying to
handle it gracefully?--but regardless, not mucking with the signal
handler fixes the issue.

Release note (bug fix): CockroachDB no longer crashes due to a SIGTRAP error
soon after startup on macOS Mojave (#31380).

31517: roachtest: deflake acceptance/bank/zerosum-splits r=andreimatei a=benesch

This test requires that the experimental_force_split_at session var be
set to force ALTER ... SPLIT AT to work even with the merge queue
enabled. gosql.DB's connection pool will occasionally open a new
connection which does not have the var set. Set the session var in the
same batch of statements as the ALTER ... SPLIT AT command so that the
session var is always set in the session that executes the ALTER ...
SPLIT AT command.

Fix #31510.

Release note: None

Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
roachtest: move the logger from cluster to test
Before this patch, c.l was essentially a test's logger. But that logger
belongs better on a test than on a cluster, and so I've moved it.
c.l still exists, and it's being set at a high level to t.l. The idea is
that c.l will still be used, at least for the time being, by other
cluster methods, but otherwise tests will switch to using t.l instead of
c.l (this is being done in the next commit).

Release note: None
roachtest: tests switch to t.l from c.l
Now that t.l exists.

Release note: None
roachtest: remove the artifacts global
Recently we got better at plumbing the dirs where different log files
should go to through. This patch completes that migration by removing
the artifacts global.
A buglet is also fixed - the global was being used by the Jepsen tests
directly, in ignorance of the fact that, if --count is used, logs need
to go to a different dir for each iteration.

Release note: None
craig[bot] and andreimatei
Merge #31321
31321: roachtest: move the logger from cluster to test r=andreimatei a=andreimatei

Before this patch, c.l was essentially a test's logger. But that logger
belongs better on a test than on a cluster, and so I've moved it.
c.l still exists, and it's being set at a high level to t.l. The idea is
that c.l will still be used, at least for the time being, by other
cluster methods, but otherwise tests will switch to using t.l instead of
c.l (this is being done in the next commit).

Release note: None

Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
Commits on Oct 17, 2018
craig[bot] and eriktrinh
Merge #31515
31515: sql: deflake TestSchemaChangeReverseMutations r=eriktrinh a=eriktrinh

Fixes #31462.

Release note: None

Co-authored-by: Erik Trinh <erik@cockroachlabs.com>
webui: fix display of merges in rangelog
It would previously show "unknown".

Observed in #31409.

Release note: None
craig[bot] and RaduBerinde
Merge #31465
31465: workload: switch tpcc to pgx and SQLRunner r=RaduBerinde a=RaduBerinde

#### workload: refactor tpccTx

Refactoring tpccTx to allow per-worker state. This will be necessary
for preparing statements in advance.

Release note: None

#### workload: use SQLRunner for queries without tuples

Switch TPCC to use pgx; use SQLRunner for queries that have a fixed
number of arguments.

Release note: None


Benchmark results here: https://docs.google.com/spreadsheets/d/13tcnYoRA3ArkZQtEHUMbJOOVdayyhgf43D94fFMiAPY/edit#gid=1942348447

The averages are about the same, but the distribution is very different (p50 through p95 are way better and p99, pMax are much worse). This is probably due to differences in how `pgx` and `gosql` manage their connection pools (we have 100 workers using 10 connections).

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
craig[bot] and couchand
Merge #31513
31513: ui: fix the color of the logout link r=couchand a=couchand

Release note: None

---

Before:
<img width="89" alt="screen shot 2018-10-16 at 3 02 06 pm" src="https://user-images.githubusercontent.com/793969/47040553-7b3f3c80-d154-11e8-8f8b-f7469cbc6e8c.png">

After:
<img width="158" alt="screen shot 2018-10-16 at 3 00 42 pm" src="https://user-images.githubusercontent.com/793969/47040563-809c8700-d154-11e8-8c98-b98066ad7582.png">


Co-authored-by: Andrew Couch <andrew@cockroachlabs.com>
craig[bot] and couchand
Merge #31512
31512: ui: make cluster overview layout more fluid r=couchand a=couchand

Fixes: #31414
Fixes: #24314
Release note (admin ui change): Improve the layout of the Cluster Overview
on large clusters with many nodes and ranges.

---

<img width="967" alt="screen shot 2018-10-16 at 2 43 12 pm" src="https://user-images.githubusercontent.com/793969/47039622-5fd33200-d152-11e8-8fa6-a2abc401bc48.png">
<img width="1376" alt="screen shot 2018-10-16 at 2 43 33 pm" src="https://user-images.githubusercontent.com/793969/47039623-5fd33200-d152-11e8-87a1-5ee9a7fb6398.png">
<img width="1505" alt="screen shot 2018-10-16 at 2 43 41 pm" src="https://user-images.githubusercontent.com/793969/47039624-5fd33200-d152-11e8-925e-476454e652fc.png">
<img width="1680" alt="screen shot 2018-10-16 at 2 43 53 pm" src="https://user-images.githubusercontent.com/793969/47039625-5fd33200-d152-11e8-925d-a5a831e21f46.png">
<img width="1853" alt="screen shot 2018-10-16 at 2 44 00 pm" src="https://user-images.githubusercontent.com/793969/47039626-606bc880-d152-11e8-9d46-c9e8ff47486f.png">
<img width="2102" alt="screen shot 2018-10-16 at 2 44 10 pm" src="https://user-images.githubusercontent.com/793969/47039627-606bc880-d152-11e8-9d21-fb8f1d1ddd0a.png">


Co-authored-by: Andrew Couch <andrew@cockroachlabs.com>
craig[bot] and tschottdorf
Merge #31466
31466: roachtest: add tpccbench configurations that have caused instability r=petermattis,nvanbenschoten a=tschottdorf

See #31409.

Release note: None

Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
craig[bot] and petermattis
Merge #31549
31549: roachtest: only run synctest on v2.2.0 and later r=tschottdorf a=petermattis

Fixes #31459

Release note: None

Co-authored-by: Peter Mattis <petermattis@gmail.com>
exec: add columnarizer and materializer
These are the components that map data between the EncDatumRow
representation and the exec.ColBatch representation.

Release note: None
roachtest: fix artifacts publishing on TeamCity
Artifacts publishing broke recently when the way artifacts dirs started
being explicitly plumbed around. Before this patch, the wrong path was
being indicated to TC because test name was doubly-represented; it was
there both in the artifactsDir var and then we appended it again.

Release note: None
*: update to apd v2.0.0
There was a breaking API change but it's now much safer to use.

Release note: None
craig[bot] and jordanlewis
Merge #31353
31353: exec: add physical types; columnarizer and materializer r=jordanlewis a=jordanlewis

- exec: add physical types enum
- exec: add columnarizer and materializer

An exec physical type corresponds to a particular type's bytes
representation, from the perspective of exec. For example, OID
types and Integers are represented the same way - as int64s.
And Integers with bounded precisions may be represented as
int32, int16, or int8, depending on the precision bounds.

The columnarizer and materializer are the the components that map
data between the EncDatumRow representation and the exec.ColBatch
representation.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
storage: resolve intents synchronously for splits/merges
The resolve allowance isn't known to ever have fired for splits/merges
(it might be trigger-able with giant start/end keys), but it worried me
when I ran across it in:

#28005 (comment)

Release note: None
craig[bot] and tschottdorf
Merge #31538 #31543
31538: storage: resolve intents synchronously for splits/merges r=bdarnell a=tschottdorf

The resolve allowance isn't known to ever have fired for splits/merges
(it might be trigger-able with giant start/end keys), but it worried me
when I ran across it in:

#28005 (comment)

Release note: None

31543: webui: fix display of merges in rangelog r=vilterp a=tschottdorf

It would previously show "unknown".

Observed in #31409.

Release note: None

Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
3 authors
Merge #31552 #31553
31552: roachtest: fix artifacts publishing on TeamCity r=andreimatei a=andreimatei

Artifacts publishing broke recently when the way artifacts dirs started
being explicitly plumbed around. Before this patch, the wrong path was
being indicated to TC because test name was doubly-represented; it was
there both in the artifactsDir var and then we appended it again.

Release note: None

31553: *: update to apd v2.0.0 r=mjibson a=mjibson

There was a breaking API change but it's now much safer to use.

Release note: None

Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
cdc: Add ledger workload option to CDC roachtests
Adds a new workload option to the CDC tests "ledger", which runs the
ledger workload instead of the TPCC workload.

To accomodate this, significantly refactor the CDC test (already
confined to a single file, not a far-reaching refactor). Notes on this:

+ Breaks down the large test function into several logical components -
a workload, a verifier, a manager for kafka - and encapsulate those in
simple objects with methods. Makes the top-level flow much easier to
read.
+ Move all verification parameters (e.g. maximum allowed latency) to be
explicitly defined for each test, rather than being inferred within the
test from other parameters such as warehouse count.

Release note: None
vendor: Update etcd
Picks up etcd-io/etcd#10167. Future commits will use the new setting
to replace broken logic that prevented unbounded Raft log growth.

This also picks up etcd-io/etcd#10063.

Release note: None
storage: move Raft log configurations into base.RaftConfig
This centralizes all Raft configuration and makes it easier
to configure in tests.

Release note: None
storage: replace remote proposal tracking with uncommitted log size p…
…rotection

This change reverts most of the non-testing code from 03b116f and f2f3fd2
and replaces it with use of the MaxUncommittedEntriesSize config. This
configuration was added in etcd-io/etcd#10167 and provides protection against
unbounded Raft log growth when a Raft group stops being able to commit
entries. It makes proposals into Raft safer because proposers don't need
to verify before the fact that the proposal isn't a duplicate that might
be blowing up the size of the Raft group.

By default, the configuration is set to double the Replica's proposal quota.
The logic here is that the quotaPool should be responsible for throttling
proposals in all cases except for unbounded Raft re-proposals because it
queues efficiently instead of dropping proposals on the floor indiscriminately.

Release note (bug fix): Fix a bug where Raft proposals could get
stuck if forwarded to a leader who could not itself append a new
entry to its log.
craig[bot] and mrtracy
Merge #31537
31537: cdc: Add ledger workload option to CDC roachtests r=danhhz a=mrtracy

Adds a new workload option to the CDC tests "ledger", which runs the
ledger workload instead of the TPCC workload.

To accomodate this, significantly refactor the CDC test (already
confined to a single file, not a far-reaching refactor). Notes on this:

+ Breaks down the large test function into several logical components -
a workload, a verifier, a manager for kafka - and encapsulate those in
simple objects with methods. Makes the top-level flow much easier to
read.
+ Move all verification parameters (e.g. maximum allowed latency) to be
explicitly defined for each test, rather than being inferred within the
test from other parameters such as warehouse count.

Release note: None

Co-authored-by: Matt Tracy <matt@cockroachlabs.com>
craig[bot] and nvanbenschoten
Merge #31408
31408: storage: replace remote proposal tracking with uncommitted log size protection r=nvanbenschoten a=nvanbenschoten

Closes #30064.

This change reverts most of the non-testing code from 03b116f and f2f3fd2
and replaces it with use of the MaxUncommittedEntriesSize config. This
configuration was added in etcd-io/etcd#10167 and provides protection against
unbounded Raft log growth when a Raft group stops being able to commit
entries. It makes proposals into Raft safer because proposers don't need
to verify before the fact that the proposal isn't a duplicate that might
be blowing up the size of the Raft group.

By default, the configuration is set to double the Replica's proposal quota.
The logic here is that the quotaPool should be responsible for throttling
proposals in all cases except for unbounded Raft re-proposals because it
queues efficiently instead of dropping proposals on the floor indiscriminately.

Release note (bug fix): Fix a bug where Raft proposals could get
stuck if forwarded to a leader who could not itself append a new
entry to its log.

This will be backported, but not to 2.1.0. The plan is to get it into 2.1.1.

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Commits on Oct 18, 2018
[cli] estimate-gc with custom TTL
Release note:
`cockroach debug estimate-gc` now allows user to specify TTL period,
with a default of 24 hours.
craig[bot] and neeral
Merge #31402
31402: [cli] estimate-gc with custom TTL r=nvanbenschoten a=neeral

Release note:
`cockroach debug estimate-gc` now allows user to specify TTL period,
with a default of 24 hours.

Co-authored-by: neeral <neeral@users.noreply.github.com>
craig[bot] and RaduBerinde
Merge #31561
31561: docs: use the correct type annotation syntax in the typing RFC r=RaduBerinde a=RaduBerinde

Release note: None

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
Showing 473 changed files with 12,490 additions and 7,236 deletions.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -3,7 +3,7 @@
set -euo pipefail
image=cockroachdb/builder
version=20180813-101406
version=20181015-212512
function init() {
docker build --tag="${image}" "$(dirname "${0}")/builder"
View
@@ -197,6 +197,7 @@ RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key ad
# google-cloud-sdk - roachprod acceptance tests
# yarn - ui
# chrome - ui
# unzip - for installing awscli
RUN apt-get install -y --no-install-recommends \
ccache \
google-cloud-sdk \
@@ -207,7 +208,15 @@ RUN apt-get install -y --no-install-recommends \
openjdk-8-jre \
openssh-client \
yarn \
google-chrome-stable
google-chrome-stable \
unzip
# awscli - roachtests
# NB: we don't use apt-get because we need an up to date version of awscli
RUN curl -fsSL "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" && \
unzip awscli-bundle.zip && \
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws && \
rm -rf awscli-bundle.zip awscli-bundle
ENV PATH /opt/backtrace/bin:$PATH
Submodule cryptopp updated 1 files
+13 −36 cpu.cpp
@@ -28,6 +28,25 @@ class TimeBoundTblPropCollector : public rocksdb::TablePropertiesCollector {
const char* Name() const override { return "TimeBoundTblPropCollector"; }
rocksdb::Status Finish(rocksdb::UserCollectedProperties* properties) override {
if (!last_value_.empty()) {
// Check to see if an intent was the last key in the SSTable. If
// it was, we need to extract the timestamp from the intent and
// update the bounds to include that timestamp.
cockroach::storage::engine::enginepb::MVCCMetadata meta;
if (!meta.ParseFromArray(last_value_.data(), last_value_.size())) {
// We're unable to parse the MVCCMetadata. Fail open by not
// setting the min/max timestamp properties.
return rocksdb::Status::OK();
}
if (meta.has_txn()) {
// We have an intent, use the intent's timestamp to update the
// timestamp bounds.
std::string ts;
EncodeTimestamp(ts, meta.timestamp().wall_time(), meta.timestamp().logical());
UpdateBounds(ts);
}
}
*properties = rocksdb::UserCollectedProperties{
{"crdb.ts.min", ts_min_},
{"crdb.ts.max", ts_max_},
@@ -40,25 +59,39 @@ class TimeBoundTblPropCollector : public rocksdb::TablePropertiesCollector {
uint64_t file_size) override {
rocksdb::Slice unused;
rocksdb::Slice ts;
if (SplitKey(user_key, &unused, &ts) && !ts.empty()) {
if (!SplitKey(user_key, &unused, &ts)) {
return rocksdb::Status::OK();
}
if (!ts.empty()) {
last_value_.clear();
ts.remove_prefix(1); // The NUL prefix.
if (ts_max_.empty() || ts.compare(ts_max_) > 0) {
ts_max_.assign(ts.data(), ts.size());
}
if (ts_min_.empty() || ts.compare(ts_min_) < 0) {
ts_min_.assign(ts.data(), ts.size());
}
UpdateBounds(ts);
return rocksdb::Status::OK();
}
last_value_.assign(value.data(), value.size());
return rocksdb::Status::OK();
}
virtual rocksdb::UserCollectedProperties GetReadableProperties() const override {
return rocksdb::UserCollectedProperties{};
}
private:
void UpdateBounds(rocksdb::Slice ts) {
if (ts_max_.empty() || ts.compare(ts_max_) > 0) {
ts_max_.assign(ts.data(), ts.size());
}
if (ts_min_.empty() || ts.compare(ts_min_) < 0) {
ts_min_.assign(ts.data(), ts.size());
}
}
private:
std::string ts_min_;
std::string ts_max_;
std::string last_value_;
};
class TimeBoundTblPropCollectorFactory : public rocksdb::TablePropertiesCollectorFactory {
@@ -15,7 +15,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -17,7 +17,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -163,7 +163,7 @@ spec:
# In addition to the node certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -22,7 +22,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -162,7 +162,7 @@ spec:
# In addition to the node certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -194,7 +194,7 @@ spec:
# In addition to the node certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -15,7 +15,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -17,7 +17,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -149,7 +149,7 @@ spec:
# In addition to the node certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -22,7 +22,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -15,7 +15,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -17,7 +17,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -161,7 +161,7 @@ spec:
# In addition to the node certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
@@ -22,7 +22,7 @@ spec:
# In addition to the client certificate and key, the init-certs entrypoint will symlink
# the cluster CA to the certs directory.
- name: init-certs
image: cockroachdb/cockroach-k8s-request-cert:0.3
image: cockroachdb/cockroach-k8s-request-cert:0.4
imagePullPolicy: IfNotPresent
command:
- "/bin/ash"
Oops, something went wrong.

No commit comments for this range