Skip to content

Commit

Permalink
Merge #43200 #43242
Browse files Browse the repository at this point in the history
43200: roachtest: improve error reporting from monitor r=andreimatei a=andreimatei

Knowing that errors (in particular, test failures) come from a monitor
is useful. Before this patch, you'd have to look at the succinct stack
trace printed on failures to figure that out.

Release note: None

43242: opt: don't attempt to negate Overlaps operator r=justinj a=justinj

Fixes #43228.

Previously, we would attempt to fold expressions of the form
```
NOT(a && b)
```
which did not work, because the && operator has no negated form.
This commit adds Overlaps to the blacklist to not negate.

I thought about doing something more general (blacklist of non-negatable
ops?) to avoid this happening in the future but I think new operators
are uncommon enough that it's not worth the overhead.

Release note (bug fix): No longer fail on an expression of the form
NOT(a && b).

Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
Co-authored-by: Justin Jaffray <justin@cockroachlabs.com>
  • Loading branch information
3 people committed Dec 17, 2019
3 parents cb8cd59 + 3c15520 + 5608304 commit 20e2f03
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
14 changes: 9 additions & 5 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/quotapool"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
"github.com/cockroachdb/errors"
_ "github.com/lib/pq"
"github.com/pkg/errors"
"golang.org/x/sync/errgroup"
)

Expand Down Expand Up @@ -2151,7 +2151,7 @@ func (m *monitor) WaitE() error {
return errors.New("already failed")
}

return m.wait(roachprod, "monitor", m.nodes)
return errors.Wrap(m.wait(roachprod, "monitor", m.nodes), "monitor failure")
}

func (m *monitor) Wait() {
Expand Down Expand Up @@ -2204,9 +2204,13 @@ func (m *monitor) wait(args ...string) error {
m.cancel()
wg.Done()
}()
setErr(m.g.Wait())
setErr(errors.Wrap(m.g.Wait(), "monitor task failed"))
}()

setMonitorCmdErr := func(err error) {
setErr(errors.Wrap(err, "monitor command failure"))
}

// 2. The second goroutine forks/execs the monitoring command.
pipeR, pipeW := io.Pipe()
wg.Add(1)
Expand All @@ -2221,7 +2225,7 @@ func (m *monitor) wait(args ...string) error {

monL, err := m.l.ChildLogger(`MONITOR`)
if err != nil {
setErr(err)
setMonitorCmdErr(err)
return
}
defer monL.close()
Expand All @@ -2233,7 +2237,7 @@ func (m *monitor) wait(args ...string) error {
if err != context.Canceled && !strings.Contains(err.Error(), "killed") {
// The expected reason for an error is that the monitor was killed due
// to the context being canceled. Any other error is an actual error.
setErr(err)
setMonitorCmdErr(err)
return
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/roachtest/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"time"

"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/pkg/errors"
"github.com/cockroachdb/errors"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -148,7 +148,7 @@ func TestClusterMonitor(t *testing.T) {

// If wait terminates, context gets canceled.
err := m.wait(`true`)
if err != context.Canceled {
if !errors.Is(err, context.Canceled) {
t.Errorf(`expected context canceled, got: %+v`, err)
}
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/norm/rules/bool.opt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ $input
# by the Not operator. For example, Eq maps to Ne, and Gt maps to Le. All
# comparisons can be negated except for the JSON comparisons.
[NegateComparison, Normalize]
(Not $input:(Comparison $left:* $right:*) & ^(Contains|JsonExists|JsonSomeExists|JsonAllExists))
(Not $input:(Comparison $left:* $right:*) & ^(Contains|JsonExists|JsonSomeExists|JsonAllExists|Overlaps))
=>
(NegateComparison (OpName $input) $left $right)

Expand Down
6 changes: 4 additions & 2 deletions pkg/sql/opt/norm/testdata/rules/bool
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ SELECT * FROM a WHERE
NOT('[1, 2]' @> j) AND NOT(j <@ '[3, 4]') AND
NOT(j ? 'foo') AND
NOT(j ?| ARRAY['foo']) AND
NOT(j ?& ARRAY['foo'])
NOT(j ?& ARRAY['foo']) AND
NOT(ARRAY[i] && ARRAY[1])
----
select
├── columns: k:1(int!null) i:2(int) f:3(float) s:4(string) j:5(jsonb)
Expand All @@ -413,7 +414,8 @@ select
├── NOT ('[3, 4]' @> j) [type=bool, outer=(5)]
├── NOT (j ? 'foo') [type=bool, outer=(5)]
├── NOT (j ?| ARRAY['foo']) [type=bool, outer=(5)]
└── NOT (j ?& ARRAY['foo']) [type=bool, outer=(5)]
├── NOT (j ?& ARRAY['foo']) [type=bool, outer=(5)]
└── NOT (ARRAY[i] && ARRAY[1]) [type=bool, outer=(2)]

# --------------------------------------------------
# EliminateNot
Expand Down

0 comments on commit 20e2f03

Please sign in to comment.