fix: avoid panic if shard group has no shards (#25717) (#25719)

Avoid panicking when mapping points to a shard group
that has no shards. This does not address the root problem,
how the shard group ended up with no shards.

helps: https://github.com/influxdata/influxdb/issues/25715
(cherry picked from commit 5b364b51c8)

closes: https://github.com/influxdata/influxdb/issues/25718
master-1.x
davidby-influx 2024-12-27 14:30:01 -08:00 committed by GitHub
parent db523227a2
commit 694607a22c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -255,6 +255,9 @@ func (w *PointsWriter) MapShards(wp *WritePointsRequest) (*ShardMapping, error)
mapping.Dropped = append(mapping.Dropped, p)
atomic.AddInt64(&w.stats.WriteDropped, 1)
continue
} else if len(sg.Shards) <= 0 {
// Shard groups should have at least one shard.
return nil, fmt.Errorf("shard group %d covering %s to %s has no shards", sg.ID, sg.StartTime, sg.EndTime)
}
sh := sg.ShardFor(p)