Skip to content

Commit

Permalink
Merge #35442 #35602
Browse files Browse the repository at this point in the history
35442: roachtest: add nightly multi-AZ tpccbench test r=nvanbenschoten a=nvanbenschoten

This test deviates from similar roachtests in a few useful ways:
- it tests across three AZs in the same region
- it tests a 6-node cluster
- it loads 5k tpcc warehouses
- it runs on only about half of them (testing the impact of cold data)

I've run this a number of times over the past few days and settled upon
2500 warehouses as a good estimate.

Release note: None

35602: pgdate: Improve handling of negative years r=bobvawter a=bobvawter

The current parsing code doesn't handle negative year values and returns an
unhelpful error message. This change allows negative years to be specified, so
that negative-year datums can at least be round-tripped through the parser.

Supports #28099
Fixes #35255

Release note: None

Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
Co-authored-by: Bob Vawter <bob@cockroachlabs.com>
  • Loading branch information
3 people committed Mar 11, 2019
3 parents 409a2c1 + 62fcb08 + 53dd651 commit 57fc3f3
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 13 deletions.
39 changes: 30 additions & 9 deletions pkg/cmd/roachtest/tpcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,14 @@ func registerTPCC(r *registry) {
LoadWarehouses: 1000,
EstimatedMax: 300,
})
registerTPCCBenchSpec(r, tpccBenchSpec{
Nodes: 6,
CPUs: 16,
Distribution: multiZone,

LoadWarehouses: 5000,
EstimatedMax: 2500,
})
registerTPCCBenchSpec(r, tpccBenchSpec{
Nodes: 9,
CPUs: 4,
Expand Down Expand Up @@ -524,19 +532,32 @@ func loadTPCCBench(
func runTPCCBench(ctx context.Context, t *test, c *cluster, b tpccBenchSpec) {
// Determine the nodes in each load group. A load group consists of a set of
// Cockroach nodes and a single load generator.
numRoachNodes := b.Nodes
numLoadGroups := b.LoadConfig.numLoadNodes(b.Distribution)
nodesPerGroup := c.nodes / numLoadGroups
loadGroup := make([]struct{ roachNodes, loadNodes nodeListOption }, numLoadGroups)
for i, j := 1, 0; i <= c.nodes; i += nodesPerGroup {
loadGroup[j].roachNodes = c.Range(i, i+nodesPerGroup-2)
loadGroup[j].loadNodes = c.Node(i + nodesPerGroup - 1)
j++
numZones := len(b.Distribution.zones())
roachNodesPerGroup := numRoachNodes / numLoadGroups
nodesPerGroup := roachNodesPerGroup + 1 // nodesPerGroup * numLoadGroups == c.nodes
zonesPerGroup := numZones / numLoadGroups
// Roachprod round-robins the allocation of nodes across zones. When running
// a single load group across zones, the first zone will always have one more
// node than the others. This extra node is the load node.
loadNodePerGroup := roachNodesPerGroup / zonesPerGroup
loadGroups := make([]struct{ roachNodes, loadNodes nodeListOption }, numLoadGroups)
for i := range loadGroups {
for j := 0; j < nodesPerGroup; j++ {
n := c.Node(i*nodesPerGroup + j + 1)
if j == loadNodePerGroup {
loadGroups[i].loadNodes = loadGroups[i].loadNodes.merge(n)
} else {
loadGroups[i].roachNodes = loadGroups[i].roachNodes.merge(n)
}
}
}

// Aggregate nodes across load groups.
var roachNodes nodeListOption
var loadNodes nodeListOption
for _, g := range loadGroup {
for _, g := range loadGroups {
roachNodes = roachNodes.merge(g.roachNodes)
loadNodes = loadNodes.merge(g.loadNodes)
}
Expand Down Expand Up @@ -605,8 +626,8 @@ func runTPCCBench(ctx context.Context, t *test, c *cluster, b tpccBenchSpec) {
// If we're running multiple load generators, run them in parallel and then
// aggregate tpmCChan.
var eg errgroup.Group
tpmCChan := make(chan float64, len(loadGroup))
for groupIdx, group := range loadGroup {
tpmCChan := make(chan float64, numLoadGroups)
for groupIdx, group := range loadGroups {
// Copy for goroutine
groupIdx := groupIdx
group := group
Expand Down
30 changes: 30 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/datetime
Original file line number Diff line number Diff line change
Expand Up @@ -1193,3 +1193,33 @@ query T
SELECT date_trunc('month', "date") AS date_trunc_month_created_at FROM "topics";
----
2017-12-01 00:00:00 +0000 UTC


# Test negative years to ensure they can round-trip through the parser.
# Also ensure that we don't trigger any of the "convenience" rules.
subtest regression_35255

query T
SELECT '-56325279622-12-26'::DATE
----
-56325279622-12-26 00:00:00 +0000 +0000

query T
SELECT '-5632-12-26'::DATE
----
-5632-12-26 00:00:00 +0000 +0000

query T
SELECT '-563-12-26'::DATE
----
-0563-12-26 00:00:00 +0000 +0000

query T
SELECT '-56-12-26'::DATE
----
-0056-12-26 00:00:00 +0000 +0000

query T
SELECT '-5-12-26'::DATE
----
-0005-12-26 00:00:00 +0000 +0000
9 changes: 6 additions & 3 deletions pkg/util/timeutil/pgdate/field_extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,13 @@ func (fe *fieldExtract) interpretNumber(chunk numberChunk, textMonth bool) error
case fe.Wants(fieldYear) && fe.Wants(fieldMonth) && fe.Wants(fieldDay):
// Example: All date formats, we're starting from scratch.
switch {
case chunk.magnitude >= 6:
case chunk.magnitude >= 6 && chunk.separator != '-':
// Example: "YYMMDD"
// ^^^^^^
// Example: "YYYYMMDD"
// ^^^^^^^^
// We're looking at some kind of concatenated date.
// We're looking at some kind of concatenated date. We do want
// to exclude large-magnitude, negative years from this test.

// Record whether or not it's a two-digit year.
fe.tweakYear = chunk.magnitude == 6
Expand All @@ -350,7 +351,9 @@ func (fe *fieldExtract) interpretNumber(chunk numberChunk, textMonth bool) error
// year-first mode, we'll accept the first chunk and possibly
// adjust a two-digit value later on. This means that
// 99 would get adjusted to 1999, but 0099 would not.
if chunk.magnitude <= 2 {
if chunk.separator == '-' {
chunk.v *= -1
} else if chunk.magnitude <= 2 {
fe.tweakYear = true
}
return fe.SetChunk(fieldYear, chunk)
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/timeutil/pgdate/parsing.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func ParseTimestamp(now time.Time, mode ParseMode, s string) (time.Time, error)

// badFieldPrefixError constructs a CodeInvalidDatetimeFormatError pgerror.
func badFieldPrefixError(field field, prefix rune) error {
return inputErrorf("unexpected separator '%v' for field %s", prefix, field.Pretty())
return inputErrorf("unexpected separator '%s' for field %s", string(prefix), field.Pretty())
}

// inputErrorf returns a CodeInvalidDatetimeFormatError pgerror.
Expand Down

0 comments on commit 57fc3f3

Please sign in to comment.