Closed
Description
The millisecond-resolution Unix timestamps (i.e., JavaScript-style) in the new TSDBHeadStats struct introduced by #925 will overflow on 32-bit archs
// TSDBHeadStats contains TSDB stats
type TSDBHeadStats struct {
NumSeries int `json:"numSeries"`
NumLabelPairs int `json:"numLabelPairs"`
ChunkCount int `json:"chunkCount"`
MinTime int `json:"minTime"`
MaxTime int `json:"maxTime"`
}
A typical / recent Unix timestamp in millisecond resolution is approximately 760 times larger than a signed 32-bit int can hold.
The struct would need to be modified to use explicit int64 types, or if it is intended to be consumed by JavaScript clients, then it should really match the data type that timestamps are in the JavaScript world - i.e., float64 (JavaScript "number").
Test failure:
$ GOARCH=386 go test ./...
ok github.com/prometheus/client_golang/api (cached)
# github.com/prometheus/client_golang/api/prometheus/v1 [github.com/prometheus/client_golang/api/prometheus/v1.test]
api/prometheus/v1/api_test.go:1155:23: cannot use 1634644800304 (untyped int constant) as int value in map literal (overflows)
api/prometheus/v1/api_test.go:1156:23: cannot use 1634650590304 (untyped int constant) as int value in map literal (overflows)
api/prometheus/v1/api_test.go:1188:21: cannot use 1634644800304 (untyped int constant) as int value in struct literal (overflows)
api/prometheus/v1/api_test.go:1189:21: cannot use 1634650590304 (untyped int constant) as int value in struct literal (overflows)
FAIL github.com/prometheus/client_golang/api/prometheus/v1 [build failed]
It seems that unit tests are only being performed on 64-bit archs, allowing assumptions like this to slip past.