Skip to content

Commit

Permalink
workload/tpcc: move tpcc error checks before length checks
Browse files Browse the repository at this point in the history
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 #102004

Release note: None
  • Loading branch information
DrewKimball committed Apr 22, 2023
1 parent 54b672f commit 43f9614
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 @@ -147,15 +147,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 @@ -243,18 +255,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 43f9614

Please sign in to comment.