Skip to content

Commit

Permalink
Avoid panic when inserting out-of-order points in spite of one partition
Browse files Browse the repository at this point in the history
  • Loading branch information
nakabonne committed Jul 21, 2021
1 parent fda1a6f commit 9034eef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion storage.go
Expand Up @@ -280,11 +280,12 @@ func (s *storage) InsertRows(rows []Row) error {
defer func() { <-s.workersLimitCh }()
s.ensureActiveHead()
iterator := s.partitionList.newIterator()
n := s.partitionList.size()
rowsToInsert := rows
// Starting at the head partition, try to insert rows, and loop to insert outdated rows
// into older partitions. Any rows more than `writablePartitionsNum` partitions out
// of date are dropped.
for i := 0; i < writablePartitionsNum; i++ {
for i := 0; i < n && i < writablePartitionsNum; i++ {
if len(rowsToInsert) == 0 {
break
}
Expand Down

0 comments on commit 9034eef

Please sign in to comment.