lib/storage: validate rows in partition.AddRows() only during tests

This commit is contained in:
Aliaksandr Valialkin 2023-04-14 20:52:36 -07:00
parent 292b6a851f
commit 0a11c46cd2
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 13 additions and 8 deletions

View file

@ -431,20 +431,24 @@ func (pt *partition) AddRows(rows []rawRow) {
return return
} }
// Validate all the rows. if isDebug {
for i := range rows { // Validate all the rows.
r := &rows[i] for i := range rows {
if !pt.HasTimestamp(r.Timestamp) { r := &rows[i]
logger.Panicf("BUG: row %+v has Timestamp outside partition %q range %+v", r, pt.smallPartsPath, &pt.tr) if !pt.HasTimestamp(r.Timestamp) {
} logger.Panicf("BUG: row %+v has Timestamp outside partition %q range %+v", r, pt.smallPartsPath, &pt.tr)
if err := encoding.CheckPrecisionBits(r.PrecisionBits); err != nil { }
logger.Panicf("BUG: row %+v has invalid PrecisionBits: %s", r, err) if err := encoding.CheckPrecisionBits(r.PrecisionBits); err != nil {
logger.Panicf("BUG: row %+v has invalid PrecisionBits: %s", r, err)
}
} }
} }
pt.rawRows.addRows(pt, rows) pt.rawRows.addRows(pt, rows)
} }
var isDebug = false
type rawRowsShards struct { type rawRowsShards struct {
shardIdx uint32 shardIdx uint32

View file

@ -14,6 +14,7 @@ import (
) )
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
isDebug = true
n := m.Run() n := m.Run()
if err := os.RemoveAll("benchmarkTableSearch"); err != nil { if err := os.RemoveAll("benchmarkTableSearch"); err != nil {
panic(fmt.Errorf("cannot remove benchmark tables: %w", err)) panic(fmt.Errorf("cannot remove benchmark tables: %w", err))