Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
102081: workload/tpcc: move tpcc error checks before length checks r=DrewKimball a=DrewKimball

Some of the TPCC consistency checks ensure that the number of rows returned by two queries is the same. This is done by checking that if one of the iterators returns false, they both do. However, if one of the iterators encounters an error, it will return false even though there are still rows left. This could cause the consistency check to seem as if it failed with incorrect results:
```
Error: check failed: 3.3.2.4: at 1682088974198157583.0000000000: length of order.sum(o_ol_cnt) != order_line.count(*)
```
when really one of the iterators just encountered an error. This patch moves the error-checking before the length checking, so that the correct error message is returned.

Fixes cockroachdb#102004

Release note: None

Co-authored-by: Drew Kimball <[email protected]>
  • Loading branch information
craig[bot] and DrewKimball committed May 22, 2023
2 parents 8f64f5b + 0578414 commit b38e51a
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions pkg/workload/tpcc/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,27 @@ ORDER BY
i, order, newOrder, district-1)
}
}
if err := districtRows.Err(); err != nil {
retErr = errors.CombineErrors(retErr, errors.Wrap(err, "on district"))
}
if err := newOrderRows.Err(); err != nil {
retErr = errors.CombineErrors(retErr, errors.Wrap(err, "on new_order"))
}
if err := orderRows.Err(); err != nil {
retErr = errors.CombineErrors(retErr, errors.Wrap(err, "on order"))
}
// Return the error before performing the remaining checks, because they are
// expected to fail if something else has already gone wrong.
if retErr != nil {
return retErr
}
if districtRows.Next() || newOrderRows.Next() || orderRows.Next() {
return errors.New("length mismatch between rows")
}
if i == 0 {
return errors.Errorf("zero rows")
}
retErr = errors.CombineErrors(retErr, districtRows.Err())
retErr = errors.CombineErrors(retErr, newOrderRows.Err())
return errors.CombineErrors(retErr, orderRows.Err())
return nil
}

func check3323(db *gosql.DB, asOfSystemTime string) error {
Expand Down Expand Up @@ -226,18 +238,18 @@ ORDER BY
return errors.Errorf("order.sum(o_ol_cnt): %d != order_line.count(*): %d", left, right)
}
}
if leftRows.Next() || rightRows.Next() {
return errors.Errorf("at %s: length of order.sum(o_ol_cnt) != order_line.count(*)", ts)
}
if i == 0 {
return errors.Errorf("0 rows returned")
}
if err := leftRows.Err(); err != nil {
return errors.Wrap(err, "on `order`")
}
if err := rightRows.Err(); err != nil {
return errors.Wrap(err, "on `order_line`")
}
if leftRows.Next() || rightRows.Next() {
return errors.Errorf("at %s: length of order.sum(o_ol_cnt) != order_line.count(*)", ts)
}
if i == 0 {
return errors.Errorf("0 rows returned")
}
return nil
}

Expand Down

0 comments on commit b38e51a

Please sign in to comment.