Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash due to violated storage invariant #367

Closed
juliusv opened this issue Oct 17, 2013 · 10 comments
Closed

Crash due to violated storage invariant #367

juliusv opened this issue Oct 17, 2013 · 10 comments

Comments

@juliusv
Copy link
Member

juliusv commented Oct 17, 2013

A Prometheus instance was crashing every time a curator was run with:

013-10-17_02:25:38.29021 I1017 02:25:38.284106 21616 curator.go:344] Curating 00037903341943518732-i-4-0...
2013-10-17_02:25:38.44258 I1017 02:25:38.442115 21616 curator.go:344] Curating 00040943594374712143-i-5-s...
2013-10-17_02:25:38.78029 I1017 02:25:38.779829 21616 curator.go:344] Curating 00052710819040147975-e-9-5...
2013-10-17_02:25:38.78978 I1017 02:25:38.782647 21616 curator.go:344] Curating 00052723516016874828-e-0-1...
2013-10-17_02:25:38.78980 panic: violated invariant SampleKey for 00052723516016874828-e-0-1 at 2013-10-15 18:22:24 +0000 UTC to 0001-01-01 00:00:00 +0000 UTC with 0 values. SampleKey for 00052723516016874828-e-0-1 at 2013-10-15 18:20:39 +0000 UTC to 2013-10-05 15:53:49 +0000 UTC with 427 values.
2013-10-17_02:25:38.78981 
2013-10-17_02:25:38.78982 
2013-10-17_02:25:38.78983 goroutine 24 [running]:
2013-10-17_02:25:38.78983 github.com/prometheus/prometheus/storage/metric.(*iteratorSeekerState).initialMatchTime(0xc2024f3c00, 0xc203200140)
2013-10-17_02:25:38.78984   /home/julius/gosrc/src/github.com/prometheus/prometheus/.build/root/gopath/src/github.com/prometheus/prometheus/storage/metric/objective.go:177 +0x291
2013-10-17_02:25:38.78985 github.com/prometheus/prometheus/storage/metric.*iteratorSeekerState.(github.com/prometheus/prometheus/storage/metric.initialMatchTime)·fm(0xc203200140)
2013-10-17_02:25:38.78986   /home/julius/gosrc/src/github.com/prometheus/prometheus/.build/root/gopath/src/github.com/prometheus/prometheus/storage/metric/objective.go:138 +0x24
2013-10-17_02:25:38.79740 github.com/prometheus/prometheus/storage/metric.(*watermarkScanner).Operate(0xc201be0000, 0x82d6e0, 0xc2031fbed0, 0x7f0060, 0xc203704720, ...)
2013-10-17_02:25:38.79742   /home/julius/gosrc/src/github.com/prometheus/prometheus/.build/root/gopath/src/github.com/prometheus/prometheus/storage/metric/curator.go:397 +0x762
2013-10-17_02:25:38.79744 github.com/prometheus/prometheus/storage/raw/leveldb.(*LevelDBPersistence).ForEach(0xc20013c6c0, 0xc20233d330, 0xc201be0000, 0xc20233d360, 0xc201be0000, ...)
2013-10-17_02:25:38.79746   /home/julius/gosrc/src/github.com/prometheus/prometheus/.build/root/gopath/src/github.com/prometheus/prometheus/storage/raw/leveldb/leveldb.go:490 +0x323
2013-10-17_02:25:38.79747 github.com/prometheus/prometheus/storage/metric.(*LevelDBHighWatermarker).ForEach(0xc200000988, 0xc20233d330, 0xc201be0000, 0xc20233d360, 0xc201be0000, ...)
2013-10-17_02:25:38.79748   /home/julius/gosrc/src/github.com/prometheus/prometheus/.build/root/gopath/src/github.com/prometheus/prometheus/storage/metric/watermark.go:106 +0x6f
2013-10-17_02:25:38.79748 github.com/prometheus/prometheus/storage/metric.(*Curator).Run(0xc2035149c0, 0x45d964b800, 0xec9f141a1, 0xc21cda069a, 0xdec340, ...)
2013-10-17_02:25:38.79751   /home/julius/gosrc/src/github.com/prometheus/prometheus/.build/root/gopath/src/github.com/prometheus/prometheus/storage/metric/curator.go:212 +0x767
2013-10-17_02:25:38.79752 main.(*prometheus).compact(0xc2002a5d20, 0x45d964b800, 0x1f4, 0x0, 0x0, ...)
2013-10-17_02:25:38.79752   /home/julius/gosrc/src/github.com/prometheus/prometheus/main.go:131 +0x285
2013-10-17_02:25:38.79753 main.func·003()
2013-10-17_02:25:38.80327   /home/julius/gosrc/src/github.com/prometheus/prometheus/main.go:311 +0x150
2013-10-17_02:25:38.80328 created by main.main
2013-10-17_02:25:38.80329   /home/julius/gosrc/src/github.com/prometheus/prometheus/main.go:318 +0xea4

[...]

I have a copy of the storage that triggers this crash if someone wants to look at it.

@juliusv
Copy link
Member Author

juliusv commented Oct 17, 2013

When using the dumper tool, the storage around that fingerprint looks like this (note that there is only a single chunk for this fingerprint, it's possible that this is what triggers the error):

00052710819040147975-e-9-5,1381861239,1380988429,427,424,1380988399,31
00052710819040147975-e-9-5,1381861239,1380988429,427,425,1380988414,31
00052710819040147975-e-9-5,1381861239,1380988429,427,426,1380988429,31
00052723516016874828-e-0-1,1381861239,1380988429,427,0,1381861239,19.294089
00052723516016874828-e-0-1,1381861239,1380988429,427,1,1381861254,19.188952
00052723516016874828-e-0-1,1381861239,1380988429,427,2,1381861269,19.188952
00052723516016874828-e-0-1,1381861239,1380988429,427,3,1381861284,18.975568
00052723516016874828-e-0-1,1381861239,1380988429,427,4,1381861299,18.975568
00052723516016874828-e-0-1,1381861239,1380988429,427,5,1381861314,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,6,1381861329,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,7,1381861344,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,8,1381861359,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,9,1381861374,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,10,1381861389,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,11,1381861404,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,12,1381861419,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,13,1381861434,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,14,1381861449,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,15,1381861464,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,16,1381861479,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,17,1381861494,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,18,1381861509,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,19,1381861524,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,20,1381861539,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,21,1381861554,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,22,1381861569,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,23,1381861584,18.81896
00052723516016874828-e-0-1,1381861239,1380988429,427,24,1381861599,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,25,1381861614,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,26,1381861629,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,27,1381861644,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,28,1381861659,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,29,1381861674,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,30,1381861689,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,31,1381861704,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,32,1381861719,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,33,1381861734,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,34,1381861749,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,35,1381861764,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,36,1381861779,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,37,1381861794,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,38,1381861809,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,39,1381861824,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,40,1381861839,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,41,1381861854,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,42,1381861869,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,43,1381861884,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,44,1381861899,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,45,1381861914,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,46,1381861929,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,47,1381861944,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,48,1381861959,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,49,1381861974,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,50,1381861989,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,51,1381862004,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,52,1381862019,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,53,1381862034,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,54,1381862049,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,55,1381862064,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,56,1381862079,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,57,1381862094,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,58,1381862109,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,59,1381862124,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,60,1381862139,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,61,1381862154,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,62,1381862169,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,63,1381862184,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,64,1381862199,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,65,1381862214,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,66,1381862229,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,67,1381862244,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,68,1381862259,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,69,1381862274,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,70,1381862289,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,71,1381862304,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,72,1381862319,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,73,1381862334,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,74,1381862349,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,75,1381862364,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,76,1381862379,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,77,1381862394,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,78,1381862409,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,79,1381862424,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,80,1381862439,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,81,1381862454,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,82,1381862469,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,83,1381862484,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,84,1381862499,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,85,1381862514,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,86,1381862529,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,87,1381862544,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,88,1381862559,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,89,1381862574,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,90,1381862589,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,91,1381862604,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,92,1381862619,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,93,1381862634,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,94,1381862649,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,95,1381862664,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,96,1381862679,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,97,1381862694,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,98,1381862709,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,99,1381862724,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,100,1381862739,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,101,1381862754,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,102,1381862769,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,103,1381862784,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,104,1381862799,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,105,1381862814,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,106,1381862829,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,107,1381862844,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,108,1381862859,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,109,1381862874,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,110,1381862889,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,111,1381862904,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,112,1381862919,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,113,1381862934,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,114,1381862949,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,115,1381862964,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,116,1381862979,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,117,1381862994,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,118,1381863009,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,119,1381863024,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,120,1381863039,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,121,1381863054,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,122,1381863069,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,123,1381863084,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,124,1381863099,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,125,1381863114,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,126,1381863129,17.544689
00052723516016874828-e-0-1,1381861239,1380988429,427,127,1380987694,31
00052723516016874828-e-0-1,1381861239,1380988429,427,128,1380987709,31
00052723516016874828-e-0-1,1381861239,1380988429,427,129,1380987724,31
00052723516016874828-e-0-1,1381861239,1380988429,427,130,1380987739,31
00052723516016874828-e-0-1,1381861239,1380988429,427,131,1380987754,31
00052723516016874828-e-0-1,1381861239,1380988429,427,132,1380987769,31
00052723516016874828-e-0-1,1381861239,1380988429,427,133,1380987784,31
00052723516016874828-e-0-1,1381861239,1380988429,427,134,1380987799,31
00052723516016874828-e-0-1,1381861239,1380988429,427,135,1380987814,31
00052723516016874828-e-0-1,1381861239,1380988429,427,136,1380987829,31
00052723516016874828-e-0-1,1381861239,1380988429,427,137,1380987844,31
00052723516016874828-e-0-1,1381861239,1380988429,427,138,1380987859,31
00052723516016874828-e-0-1,1381861239,1380988429,427,139,1380987874,31
00052723516016874828-e-0-1,1381861239,1380988429,427,140,1380987889,31
00052723516016874828-e-0-1,1381861239,1380988429,427,141,1380987904,31
00052723516016874828-e-0-1,1381861239,1380988429,427,142,1380987919,31
00052723516016874828-e-0-1,1381861239,1380988429,427,143,1380987934,31
00052723516016874828-e-0-1,1381861239,1380988429,427,144,1380987949,31
00052723516016874828-e-0-1,1381861239,1380988429,427,145,1380987964,31
00052723516016874828-e-0-1,1381861239,1380988429,427,146,1380987979,31
00052723516016874828-e-0-1,1381861239,1380988429,427,147,1380987994,31
00052723516016874828-e-0-1,1381861239,1380988429,427,148,1380988009,31
00052723516016874828-e-0-1,1381861239,1380988429,427,149,1380988024,31
00052723516016874828-e-0-1,1381861239,1380988429,427,150,1380988039,31
00052723516016874828-e-0-1,1381861239,1380988429,427,151,1380988054,31
00052723516016874828-e-0-1,1381861239,1380988429,427,152,1380988069,31
00052723516016874828-e-0-1,1381861239,1380988429,427,153,1380988084,31
00052723516016874828-e-0-1,1381861239,1380988429,427,154,1380988099,31
00052723516016874828-e-0-1,1381861239,1380988429,427,155,1380988114,31
00052723516016874828-e-0-1,1381861239,1380988429,427,156,1380988129,31
00052723516016874828-e-0-1,1381861239,1380988429,427,157,1380988144,31
00052723516016874828-e-0-1,1381861239,1380988429,427,158,1380988159,31
00052723516016874828-e-0-1,1381861239,1380988429,427,159,1380988174,31
00052723516016874828-e-0-1,1381861239,1380988429,427,160,1380988189,31
00052723516016874828-e-0-1,1381861239,1380988429,427,161,1380988204,31
00052723516016874828-e-0-1,1381861239,1380988429,427,162,1380988219,31
00052723516016874828-e-0-1,1381861239,1380988429,427,163,1380988234,31
00052723516016874828-e-0-1,1381861239,1380988429,427,164,1380988249,31
00052723516016874828-e-0-1,1381861239,1380988429,427,165,1380988264,31
00052723516016874828-e-0-1,1381861239,1380988429,427,166,1380988279,31
00052723516016874828-e-0-1,1381861239,1380988429,427,167,1380988294,31
00052723516016874828-e-0-1,1381861239,1380988429,427,168,1380988309,31
00052723516016874828-e-0-1,1381861239,1380988429,427,169,1380988324,31
00052723516016874828-e-0-1,1381861239,1380988429,427,170,1380988339,31
00052723516016874828-e-0-1,1381861239,1380988429,427,171,1380988354,31
00052723516016874828-e-0-1,1381861239,1380988429,427,172,1380988369,31
00052723516016874828-e-0-1,1381861239,1380988429,427,173,1380988384,31
00052723516016874828-e-0-1,1381861239,1380988429,427,174,1380988399,31
00052723516016874828-e-0-1,1381861239,1380988429,427,175,1380988414,31
00052723516016874828-e-0-1,1381861239,1380988429,427,176,1380988429,31
00052723516016874828-e-0-1,1381861239,1380988429,427,177,1380987694,31
00052723516016874828-e-0-1,1381861239,1380988429,427,178,1380987709,31
00052723516016874828-e-0-1,1381861239,1380988429,427,179,1380987724,31
00052723516016874828-e-0-1,1381861239,1380988429,427,180,1380987739,31
00052723516016874828-e-0-1,1381861239,1380988429,427,181,1380987754,31
00052723516016874828-e-0-1,1381861239,1380988429,427,182,1380987769,31
00052723516016874828-e-0-1,1381861239,1380988429,427,183,1380987784,31
00052723516016874828-e-0-1,1381861239,1380988429,427,184,1380987799,31
00052723516016874828-e-0-1,1381861239,1380988429,427,185,1380987814,31
00052723516016874828-e-0-1,1381861239,1380988429,427,186,1380987829,31
00052723516016874828-e-0-1,1381861239,1380988429,427,187,1380987844,31
00052723516016874828-e-0-1,1381861239,1380988429,427,188,1380987859,31
00052723516016874828-e-0-1,1381861239,1380988429,427,189,1380987874,31
00052723516016874828-e-0-1,1381861239,1380988429,427,190,1380987889,31
00052723516016874828-e-0-1,1381861239,1380988429,427,191,1380987904,31
00052723516016874828-e-0-1,1381861239,1380988429,427,192,1380987919,31
00052723516016874828-e-0-1,1381861239,1380988429,427,193,1380987934,31
00052723516016874828-e-0-1,1381861239,1380988429,427,194,1380987949,31
00052723516016874828-e-0-1,1381861239,1380988429,427,195,1380987964,31
00052723516016874828-e-0-1,1381861239,1380988429,427,196,1380987979,31
00052723516016874828-e-0-1,1381861239,1380988429,427,197,1380987994,31
00052723516016874828-e-0-1,1381861239,1380988429,427,198,1380988009,31
00052723516016874828-e-0-1,1381861239,1380988429,427,199,1380988024,31
00052723516016874828-e-0-1,1381861239,1380988429,427,200,1380988039,31
00052723516016874828-e-0-1,1381861239,1380988429,427,201,1380988054,31
00052723516016874828-e-0-1,1381861239,1380988429,427,202,1380988069,31
00052723516016874828-e-0-1,1381861239,1380988429,427,203,1380988084,31
00052723516016874828-e-0-1,1381861239,1380988429,427,204,1380988099,31
00052723516016874828-e-0-1,1381861239,1380988429,427,205,1380988114,31
00052723516016874828-e-0-1,1381861239,1380988429,427,206,1380988129,31
00052723516016874828-e-0-1,1381861239,1380988429,427,207,1380988144,31
00052723516016874828-e-0-1,1381861239,1380988429,427,208,1380988159,31
00052723516016874828-e-0-1,1381861239,1380988429,427,209,1380988174,31
00052723516016874828-e-0-1,1381861239,1380988429,427,210,1380988189,31
00052723516016874828-e-0-1,1381861239,1380988429,427,211,1380988204,31
00052723516016874828-e-0-1,1381861239,1380988429,427,212,1380988219,31
00052723516016874828-e-0-1,1381861239,1380988429,427,213,1380988234,31
00052723516016874828-e-0-1,1381861239,1380988429,427,214,1380988249,31
00052723516016874828-e-0-1,1381861239,1380988429,427,215,1380988264,31
00052723516016874828-e-0-1,1381861239,1380988429,427,216,1380988279,31
00052723516016874828-e-0-1,1381861239,1380988429,427,217,1380988294,31
00052723516016874828-e-0-1,1381861239,1380988429,427,218,1380988309,31
00052723516016874828-e-0-1,1381861239,1380988429,427,219,1380988324,31
00052723516016874828-e-0-1,1381861239,1380988429,427,220,1380988339,31
00052723516016874828-e-0-1,1381861239,1380988429,427,221,1380988354,31
00052723516016874828-e-0-1,1381861239,1380988429,427,222,1380988369,31
00052723516016874828-e-0-1,1381861239,1380988429,427,223,1380988384,31
00052723516016874828-e-0-1,1381861239,1380988429,427,224,1380988399,31
00052723516016874828-e-0-1,1381861239,1380988429,427,225,1380988414,31
00052723516016874828-e-0-1,1381861239,1380988429,427,226,1380988429,31
00052723516016874828-e-0-1,1381861239,1380988429,427,227,1380987694,31
00052723516016874828-e-0-1,1381861239,1380988429,427,228,1380987709,31
00052723516016874828-e-0-1,1381861239,1380988429,427,229,1380987724,31
00052723516016874828-e-0-1,1381861239,1380988429,427,230,1380987739,31
00052723516016874828-e-0-1,1381861239,1380988429,427,231,1380987754,31
00052723516016874828-e-0-1,1381861239,1380988429,427,232,1380987769,31
00052723516016874828-e-0-1,1381861239,1380988429,427,233,1380987784,31
00052723516016874828-e-0-1,1381861239,1380988429,427,234,1380987799,31
00052723516016874828-e-0-1,1381861239,1380988429,427,235,1380987814,31
00052723516016874828-e-0-1,1381861239,1380988429,427,236,1380987829,31
00052723516016874828-e-0-1,1381861239,1380988429,427,237,1380987844,31
00052723516016874828-e-0-1,1381861239,1380988429,427,238,1380987859,31
00052723516016874828-e-0-1,1381861239,1380988429,427,239,1380987874,31
00052723516016874828-e-0-1,1381861239,1380988429,427,240,1380987889,31
00052723516016874828-e-0-1,1381861239,1380988429,427,241,1380987904,31
00052723516016874828-e-0-1,1381861239,1380988429,427,242,1380987919,31
00052723516016874828-e-0-1,1381861239,1380988429,427,243,1380987934,31
00052723516016874828-e-0-1,1381861239,1380988429,427,244,1380987949,31
00052723516016874828-e-0-1,1381861239,1380988429,427,245,1380987964,31
00052723516016874828-e-0-1,1381861239,1380988429,427,246,1380987979,31
00052723516016874828-e-0-1,1381861239,1380988429,427,247,1380987994,31
00052723516016874828-e-0-1,1381861239,1380988429,427,248,1380988009,31
00052723516016874828-e-0-1,1381861239,1380988429,427,249,1380988024,31
00052723516016874828-e-0-1,1381861239,1380988429,427,250,1380988039,31
00052723516016874828-e-0-1,1381861239,1380988429,427,251,1380988054,31
00052723516016874828-e-0-1,1381861239,1380988429,427,252,1380988069,31
00052723516016874828-e-0-1,1381861239,1380988429,427,253,1380988084,31
00052723516016874828-e-0-1,1381861239,1380988429,427,254,1380988099,31
00052723516016874828-e-0-1,1381861239,1380988429,427,255,1380988114,31
00052723516016874828-e-0-1,1381861239,1380988429,427,256,1380988129,31
00052723516016874828-e-0-1,1381861239,1380988429,427,257,1380988144,31
00052723516016874828-e-0-1,1381861239,1380988429,427,258,1380988159,31
00052723516016874828-e-0-1,1381861239,1380988429,427,259,1380988174,31
00052723516016874828-e-0-1,1381861239,1380988429,427,260,1380988189,31
00052723516016874828-e-0-1,1381861239,1380988429,427,261,1380988204,31
00052723516016874828-e-0-1,1381861239,1380988429,427,262,1380988219,31
00052723516016874828-e-0-1,1381861239,1380988429,427,263,1380988234,31
00052723516016874828-e-0-1,1381861239,1380988429,427,264,1380988249,31
00052723516016874828-e-0-1,1381861239,1380988429,427,265,1380988264,31
00052723516016874828-e-0-1,1381861239,1380988429,427,266,1380988279,31
00052723516016874828-e-0-1,1381861239,1380988429,427,267,1380988294,31
00052723516016874828-e-0-1,1381861239,1380988429,427,268,1380988309,31
00052723516016874828-e-0-1,1381861239,1380988429,427,269,1380988324,31
00052723516016874828-e-0-1,1381861239,1380988429,427,270,1380988339,31
00052723516016874828-e-0-1,1381861239,1380988429,427,271,1380988354,31
00052723516016874828-e-0-1,1381861239,1380988429,427,272,1380988369,31
00052723516016874828-e-0-1,1381861239,1380988429,427,273,1380988384,31
00052723516016874828-e-0-1,1381861239,1380988429,427,274,1380988399,31
00052723516016874828-e-0-1,1381861239,1380988429,427,275,1380988414,31
00052723516016874828-e-0-1,1381861239,1380988429,427,276,1380988429,31
00052723516016874828-e-0-1,1381861239,1380988429,427,277,1380987694,31
00052723516016874828-e-0-1,1381861239,1380988429,427,278,1380987709,31
00052723516016874828-e-0-1,1381861239,1380988429,427,279,1380987724,31
00052723516016874828-e-0-1,1381861239,1380988429,427,280,1380987739,31
00052723516016874828-e-0-1,1381861239,1380988429,427,281,1380987754,31
00052723516016874828-e-0-1,1381861239,1380988429,427,282,1380987769,31
00052723516016874828-e-0-1,1381861239,1380988429,427,283,1380987784,31
00052723516016874828-e-0-1,1381861239,1380988429,427,284,1380987799,31
00052723516016874828-e-0-1,1381861239,1380988429,427,285,1380987814,31
00052723516016874828-e-0-1,1381861239,1380988429,427,286,1380987829,31
00052723516016874828-e-0-1,1381861239,1380988429,427,287,1380987844,31
00052723516016874828-e-0-1,1381861239,1380988429,427,288,1380987859,31
00052723516016874828-e-0-1,1381861239,1380988429,427,289,1380987874,31
00052723516016874828-e-0-1,1381861239,1380988429,427,290,1380987889,31
00052723516016874828-e-0-1,1381861239,1380988429,427,291,1380987904,31
00052723516016874828-e-0-1,1381861239,1380988429,427,292,1380987919,31
00052723516016874828-e-0-1,1381861239,1380988429,427,293,1380987934,31
00052723516016874828-e-0-1,1381861239,1380988429,427,294,1380987949,31
00052723516016874828-e-0-1,1381861239,1380988429,427,295,1380987964,31
00052723516016874828-e-0-1,1381861239,1380988429,427,296,1380987979,31
00052723516016874828-e-0-1,1381861239,1380988429,427,297,1380987994,31
00052723516016874828-e-0-1,1381861239,1380988429,427,298,1380988009,31
00052723516016874828-e-0-1,1381861239,1380988429,427,299,1380988024,31
00052723516016874828-e-0-1,1381861239,1380988429,427,300,1380988039,31
00052723516016874828-e-0-1,1381861239,1380988429,427,301,1380988054,31
00052723516016874828-e-0-1,1381861239,1380988429,427,302,1380988069,31
00052723516016874828-e-0-1,1381861239,1380988429,427,303,1380988084,31
00052723516016874828-e-0-1,1381861239,1380988429,427,304,1380988099,31
00052723516016874828-e-0-1,1381861239,1380988429,427,305,1380988114,31
00052723516016874828-e-0-1,1381861239,1380988429,427,306,1380988129,31
00052723516016874828-e-0-1,1381861239,1380988429,427,307,1380988144,31
00052723516016874828-e-0-1,1381861239,1380988429,427,308,1380988159,31
00052723516016874828-e-0-1,1381861239,1380988429,427,309,1380988174,31
00052723516016874828-e-0-1,1381861239,1380988429,427,310,1380988189,31
00052723516016874828-e-0-1,1381861239,1380988429,427,311,1380988204,31
00052723516016874828-e-0-1,1381861239,1380988429,427,312,1380988219,31
00052723516016874828-e-0-1,1381861239,1380988429,427,313,1380988234,31
00052723516016874828-e-0-1,1381861239,1380988429,427,314,1380988249,31
00052723516016874828-e-0-1,1381861239,1380988429,427,315,1380988264,31
00052723516016874828-e-0-1,1381861239,1380988429,427,316,1380988279,31
00052723516016874828-e-0-1,1381861239,1380988429,427,317,1380988294,31
00052723516016874828-e-0-1,1381861239,1380988429,427,318,1380988309,31
00052723516016874828-e-0-1,1381861239,1380988429,427,319,1380988324,31
00052723516016874828-e-0-1,1381861239,1380988429,427,320,1380988339,31
00052723516016874828-e-0-1,1381861239,1380988429,427,321,1380988354,31
00052723516016874828-e-0-1,1381861239,1380988429,427,322,1380988369,31
00052723516016874828-e-0-1,1381861239,1380988429,427,323,1380988384,31
00052723516016874828-e-0-1,1381861239,1380988429,427,324,1380988399,31
00052723516016874828-e-0-1,1381861239,1380988429,427,325,1380988414,31
00052723516016874828-e-0-1,1381861239,1380988429,427,326,1380988429,31
00052723516016874828-e-0-1,1381861239,1380988429,427,327,1380987694,31
00052723516016874828-e-0-1,1381861239,1380988429,427,328,1380987709,31
00052723516016874828-e-0-1,1381861239,1380988429,427,329,1380987724,31
00052723516016874828-e-0-1,1381861239,1380988429,427,330,1380987739,31
00052723516016874828-e-0-1,1381861239,1380988429,427,331,1380987754,31
00052723516016874828-e-0-1,1381861239,1380988429,427,332,1380987769,31
00052723516016874828-e-0-1,1381861239,1380988429,427,333,1380987784,31
00052723516016874828-e-0-1,1381861239,1380988429,427,334,1380987799,31
00052723516016874828-e-0-1,1381861239,1380988429,427,335,1380987814,31
00052723516016874828-e-0-1,1381861239,1380988429,427,336,1380987829,31
00052723516016874828-e-0-1,1381861239,1380988429,427,337,1380987844,31
00052723516016874828-e-0-1,1381861239,1380988429,427,338,1380987859,31
00052723516016874828-e-0-1,1381861239,1380988429,427,339,1380987874,31
00052723516016874828-e-0-1,1381861239,1380988429,427,340,1380987889,31
00052723516016874828-e-0-1,1381861239,1380988429,427,341,1380987904,31
00052723516016874828-e-0-1,1381861239,1380988429,427,342,1380987919,31
00052723516016874828-e-0-1,1381861239,1380988429,427,343,1380987934,31
00052723516016874828-e-0-1,1381861239,1380988429,427,344,1380987949,31
00052723516016874828-e-0-1,1381861239,1380988429,427,345,1380987964,31
00052723516016874828-e-0-1,1381861239,1380988429,427,346,1380987979,31
00052723516016874828-e-0-1,1381861239,1380988429,427,347,1380987994,31
00052723516016874828-e-0-1,1381861239,1380988429,427,348,1380988009,31
00052723516016874828-e-0-1,1381861239,1380988429,427,349,1380988024,31
00052723516016874828-e-0-1,1381861239,1380988429,427,350,1380988039,31
00052723516016874828-e-0-1,1381861239,1380988429,427,351,1380988054,31
00052723516016874828-e-0-1,1381861239,1380988429,427,352,1380988069,31
00052723516016874828-e-0-1,1381861239,1380988429,427,353,1380988084,31
00052723516016874828-e-0-1,1381861239,1380988429,427,354,1380988099,31
00052723516016874828-e-0-1,1381861239,1380988429,427,355,1380988114,31
00052723516016874828-e-0-1,1381861239,1380988429,427,356,1380988129,31
00052723516016874828-e-0-1,1381861239,1380988429,427,357,1380988144,31
00052723516016874828-e-0-1,1381861239,1380988429,427,358,1380988159,31
00052723516016874828-e-0-1,1381861239,1380988429,427,359,1380988174,31
00052723516016874828-e-0-1,1381861239,1380988429,427,360,1380988189,31
00052723516016874828-e-0-1,1381861239,1380988429,427,361,1380988204,31
00052723516016874828-e-0-1,1381861239,1380988429,427,362,1380988219,31
00052723516016874828-e-0-1,1381861239,1380988429,427,363,1380988234,31
00052723516016874828-e-0-1,1381861239,1380988429,427,364,1380988249,31
00052723516016874828-e-0-1,1381861239,1380988429,427,365,1380988264,31
00052723516016874828-e-0-1,1381861239,1380988429,427,366,1380988279,31
00052723516016874828-e-0-1,1381861239,1380988429,427,367,1380988294,31
00052723516016874828-e-0-1,1381861239,1380988429,427,368,1380988309,31
00052723516016874828-e-0-1,1381861239,1380988429,427,369,1380988324,31
00052723516016874828-e-0-1,1381861239,1380988429,427,370,1380988339,31
00052723516016874828-e-0-1,1381861239,1380988429,427,371,1380988354,31
00052723516016874828-e-0-1,1381861239,1380988429,427,372,1380988369,31
00052723516016874828-e-0-1,1381861239,1380988429,427,373,1380988384,31
00052723516016874828-e-0-1,1381861239,1380988429,427,374,1380988399,31
00052723516016874828-e-0-1,1381861239,1380988429,427,375,1380988414,31
00052723516016874828-e-0-1,1381861239,1380988429,427,376,1380988429,31
00052723516016874828-e-0-1,1381861239,1380988429,427,377,1380987694,31
00052723516016874828-e-0-1,1381861239,1380988429,427,378,1380987709,31
00052723516016874828-e-0-1,1381861239,1380988429,427,379,1380987724,31
00052723516016874828-e-0-1,1381861239,1380988429,427,380,1380987739,31
00052723516016874828-e-0-1,1381861239,1380988429,427,381,1380987754,31
00052723516016874828-e-0-1,1381861239,1380988429,427,382,1380987769,31
00052723516016874828-e-0-1,1381861239,1380988429,427,383,1380987784,31
00052723516016874828-e-0-1,1381861239,1380988429,427,384,1380987799,31
00052723516016874828-e-0-1,1381861239,1380988429,427,385,1380987814,31
00052723516016874828-e-0-1,1381861239,1380988429,427,386,1380987829,31
00052723516016874828-e-0-1,1381861239,1380988429,427,387,1380987844,31
00052723516016874828-e-0-1,1381861239,1380988429,427,388,1380987859,31
00052723516016874828-e-0-1,1381861239,1380988429,427,389,1380987874,31
00052723516016874828-e-0-1,1381861239,1380988429,427,390,1380987889,31
00052723516016874828-e-0-1,1381861239,1380988429,427,391,1380987904,31
00052723516016874828-e-0-1,1381861239,1380988429,427,392,1380987919,31
00052723516016874828-e-0-1,1381861239,1380988429,427,393,1380987934,31
00052723516016874828-e-0-1,1381861239,1380988429,427,394,1380987949,31
00052723516016874828-e-0-1,1381861239,1380988429,427,395,1380987964,31
00052723516016874828-e-0-1,1381861239,1380988429,427,396,1380987979,31
00052723516016874828-e-0-1,1381861239,1380988429,427,397,1380987994,31
00052723516016874828-e-0-1,1381861239,1380988429,427,398,1380988009,31
00052723516016874828-e-0-1,1381861239,1380988429,427,399,1380988024,31
00052723516016874828-e-0-1,1381861239,1380988429,427,400,1380988039,31
00052723516016874828-e-0-1,1381861239,1380988429,427,401,1380988054,31
00052723516016874828-e-0-1,1381861239,1380988429,427,402,1380988069,31
00052723516016874828-e-0-1,1381861239,1380988429,427,403,1380988084,31
00052723516016874828-e-0-1,1381861239,1380988429,427,404,1380988099,31
00052723516016874828-e-0-1,1381861239,1380988429,427,405,1380988114,31
00052723516016874828-e-0-1,1381861239,1380988429,427,406,1380988129,31
00052723516016874828-e-0-1,1381861239,1380988429,427,407,1380988144,31
00052723516016874828-e-0-1,1381861239,1380988429,427,408,1380988159,31
00052723516016874828-e-0-1,1381861239,1380988429,427,409,1380988174,31
00052723516016874828-e-0-1,1381861239,1380988429,427,410,1380988189,31
00052723516016874828-e-0-1,1381861239,1380988429,427,411,1380988204,31
00052723516016874828-e-0-1,1381861239,1380988429,427,412,1380988219,31
00052723516016874828-e-0-1,1381861239,1380988429,427,413,1380988234,31
00052723516016874828-e-0-1,1381861239,1380988429,427,414,1380988249,31
00052723516016874828-e-0-1,1381861239,1380988429,427,415,1380988264,31
00052723516016874828-e-0-1,1381861239,1380988429,427,416,1380988279,31
00052723516016874828-e-0-1,1381861239,1380988429,427,417,1380988294,31
00052723516016874828-e-0-1,1381861239,1380988429,427,418,1380988309,31
00052723516016874828-e-0-1,1381861239,1380988429,427,419,1380988324,31
00052723516016874828-e-0-1,1381861239,1380988429,427,420,1380988339,31
00052723516016874828-e-0-1,1381861239,1380988429,427,421,1380988354,31
00052723516016874828-e-0-1,1381861239,1380988429,427,422,1380988369,31
00052723516016874828-e-0-1,1381861239,1380988429,427,423,1380988384,31
00052723516016874828-e-0-1,1381861239,1380988429,427,424,1380988399,31
00052723516016874828-e-0-1,1381861239,1380988429,427,425,1380988414,31
00052723516016874828-e-0-1,1381861239,1380988429,427,426,1380988429,31
00059007603139390477-i-8-s,1380987694,1380988429,50,0,1380987694,31
00059007603139390477-i-8-s,1380987694,1380988429,50,1,1380987709,31
00059007603139390477-i-8-s,1380987694,1380988429,50,2,1380987724,31

@juliusv
Copy link
Member Author

juliusv commented Oct 17, 2013

Ok, that's actually a corrupt chunk. The FirstTime is larger than the LastTime, and you can see that this is due to out-of-order samples in the chunk.

So now the question is, what corrupted this chunk? Probably a bug in the compactor. I remember we once had this kind of problem in the compactor already, when two arguments to an append() were the wrong way around.

@juliusv
Copy link
Member Author

juliusv commented Oct 20, 2013

I traced this down to two pernicious bugs, one in the compactor, one in the watermarker. I have fixes for both, but am holding on to them as I reflect on how to best add regression tests for them (so far I've tested them with a bunch of Go-written tools and scripts).

  1. The first bug is the one that directly causes the chunk corruption seen above:

for lastCurated.Before(stopAt) && lastTouchedTime.Before(stopAt) && sampleKey.Fingerprint.Equal(fingerprint) {

The check sampleKey.Fingerprint.Equal(fingerprint) only happens after the samples for the wrong fingerprint have already been added to unactedSamples in line 139:

unactedSamples, err = extractSampleValues(sampleIterator)

That means when the for loop exits that there will be unacted samples that belong to the wrong (next) fingerprint, and they are stuck into a chunk that gets stored as the previous fingerprint. Thus, chunks get corrupted in the way we saw above. Ouch!

  1. I saw another bug where only the last chunk of any series (except the first one) got compacted. The reason: when the LevelDBCurationRemarker doesn't find a curation remark for a series (which is used for seeking to the right initial key before the compaction), it returns an uninitialized time.Time object. However, the way we encode keys in LevelDB, we only support Unix timestamps starting at 1970-01-01. An uninitialized time.Time will point to 0001-01-01, which will encode to a negative Unix timestamp, which in turn will in the final binary protobuf encode to a bit string larger than any usual timestamps. Thus, the initial compactor seek always seeked beyond the last chunk of a series, then rewound by one to get back into its series keyspace. Thus, only the last chunk of a series was ever compacted in this case.

/cc @matttproud

@juliusv
Copy link
Member Author

juliusv commented Oct 20, 2013

We should evaluate whether it makes sense to entirely get rid of time.Time in Prometheus' storage and instead only use Unix timestamps. This would:

  • prevent bugs like the one above
  • decrease memory storage space
  • make time operations faster
  • be less Go-idiomatic :-/

@juliusv
Copy link
Member Author

juliusv commented Oct 22, 2013

@matttproud Fixes along with regression tests for the two bugs reported in this bug are uploaded for review here:

http://review.prometheus.io:8080/#/c/51/
http://review.prometheus.io:8080/#/c/52/
http://review.prometheus.io:8080/#/c/53/
http://review.prometheus.io:8080/#/c/54/

@juliusv
Copy link
Member Author

juliusv commented Oct 22, 2013

There's also a test case included in http://review.prometheus.io:8080/#/c/54/ which is currently commented out and which triggers #368 (which is not yet fixed), in case you want to reproduce it.

@juliusv
Copy link
Member Author

juliusv commented Oct 26, 2013

This was addressed in the following changes:

a1a97ed
b5f6e3c
6ea22f2

@juliusv juliusv closed this as completed Oct 26, 2013
@matttproud
Copy link
Member

@juliusv OK. Good astute observations in the course of this! Please review the following for post-TBR code review:

http://review.prometheus.io:8080/#/c/53/

http://review.prometheus.io:8080/#/c/54/

@juliusv
Copy link
Member Author

juliusv commented Oct 30, 2013

@matttproud Thanks a lot! I'll get to fix these comments up in time!

What is still most problematic right now is this compaction crash that I haven't figured out yet: #368. A number of production Prometheusses are crashing every few hours now due to this. The compaction tests in http://review.prometheus.io/#/c/54/4/storage/metric/compaction_regression_test.go have a commented-out test case that reproduce this crash every time.

juliusv added a commit that referenced this issue Dec 2, 2013
So far we've been using Go's native time.Time for anything related to sample
timestamps. Since the range of time.Time is much bigger than what we need, this
has created two problems:

- there could be time.Time values which were out of the range/precision of the
  time type that we persist to disk, therefore causing incorrectly ordered keys.
  One bug caused by this was:

  #367

  It would be good to use a timestamp type that's more closely aligned with
  what the underlying storage supports.

- sizeof(time.Time) is 192, while Prometheus should be ok with a single 64-bit
  Unix timestamp (possibly even a 32-bit one). Since we store samples in large
  numbers, this seriously affects memory usage. Furthermore, copying/working
  with the data will be faster if it's smaller.

*MEMORY USAGE RESULTS*
Initial memory usage comparisons for a running Prometheus with 1 timeseries and
100,000 samples show roughly a 13% decrease in total (VIRT) memory usage. In my
tests, this advantage for some reason decreased a bit the more samples the
timeseries had (to 5-7% for millions of samples). This I can't fully explain,
but perhaps garbage collection issues were involved.

*WHEN TO USE THE NEW TIMESTAMP TYPE*
The new clientmodel.Timestamp type should be used whenever time
calculations are either directly or indirectly related to sample
timestamps.

For example:
- the timestamp of a sample itself
- all kinds of watermarks
- anything that may become or is compared to a sample timestamp (like the timestamp
  passed into Target.Scrape()).

When to still use time.Time:
- for measuring durations/times not related to sample timestamps, like duration
  telemetry exporting, timers that indicate how frequently to execute some
  action, etc.

*NOTE ON OPERATOR OPTIMIZATION TESTS*
We don't use operator optimization code anymore, but it still lives in
the code as dead code. It still has tests, but I couldn't get all of them to
pass with the new timestamp format. I commented out the failing cases for now,
but we should probably remove the dead code soon. I just didn't want to do that
in the same change as this.

Change-Id: I821787414b0debe85c9fffaeb57abd453727af0f
juliusv added a commit that referenced this issue Dec 2, 2013
This adds regression tests that catch the two error cases reported in

  #367

It also adds a commented-out test case for the crash in

  #368

but there's no fix for the latter crash yet.

Change-Id: Idffefea4ed7cc281caae660bcad2e3c13ec3bd17
juliusv added a commit to prometheus/client_golang that referenced this issue Dec 2, 2013
So far we've been using Go's native time.Time for anything related to sample
timestamps. Since the range of time.Time is much bigger than what we need, this
has created two problems:

- there could be time.Time values which were out of the range/precision of the
  time type that we persist to disk, therefore causing incorrectly ordered keys.
  One bug caused by this was:

  prometheus/prometheus#367

  It would be good to use a timestamp type that's more closely aligned with
  what the underlying storage supports.

- sizeof(time.Time) is 192, while Prometheus should be ok with a single 64-bit
  Unix timestamp (possibly even a 32-bit one). Since we store samples in large
  numbers, this seriously affects memory usage. Furthermore, copying/working
  with the data will be faster if it's smaller.

*MEMORY USAGE RESULTS*
Initial memory usage comparisons for a running Prometheus with 1 timeseries and
100,000 samples show roughly a 13% decrease in total (VIRT) memory usage. In my
tests, this advantage for some reason decreased a bit the more samples the
timeseries had (to 5-7% for millions of samples). This I can't fully explain,
but perhaps garbage collection issues were involved.

*WHEN TO USE THE NEW TIMESTAMP TYPE*
The new clientmodel.Timestamp type should be used whenever time
calculations are either directly or indirectly related to sample
timestamps.

For example:
- the timestamp of a sample itself
- all kinds of watermarks
- anything that may become or is compared to a sample timestamp (like the timestamp
  passed into Target.Scrape()).

When to still use time.Time:
- for measuring durations/times not related to sample timestamps, like duration
  telemetry exporting, timers that indicate how frequently to execute some
  action, etc.

Change-Id: I253a467388774280c10400fda122369ff77c1730
juliusv added a commit that referenced this issue Dec 3, 2013
So far we've been using Go's native time.Time for anything related to sample
timestamps. Since the range of time.Time is much bigger than what we need, this
has created two problems:

- there could be time.Time values which were out of the range/precision of the
  time type that we persist to disk, therefore causing incorrectly ordered keys.
  One bug caused by this was:

  #367

  It would be good to use a timestamp type that's more closely aligned with
  what the underlying storage supports.

- sizeof(time.Time) is 192, while Prometheus should be ok with a single 64-bit
  Unix timestamp (possibly even a 32-bit one). Since we store samples in large
  numbers, this seriously affects memory usage. Furthermore, copying/working
  with the data will be faster if it's smaller.

*MEMORY USAGE RESULTS*
Initial memory usage comparisons for a running Prometheus with 1 timeseries and
100,000 samples show roughly a 13% decrease in total (VIRT) memory usage. In my
tests, this advantage for some reason decreased a bit the more samples the
timeseries had (to 5-7% for millions of samples). This I can't fully explain,
but perhaps garbage collection issues were involved.

*WHEN TO USE THE NEW TIMESTAMP TYPE*
The new clientmodel.Timestamp type should be used whenever time
calculations are either directly or indirectly related to sample
timestamps.

For example:
- the timestamp of a sample itself
- all kinds of watermarks
- anything that may become or is compared to a sample timestamp (like the timestamp
  passed into Target.Scrape()).

When to still use time.Time:
- for measuring durations/times not related to sample timestamps, like duration
  telemetry exporting, timers that indicate how frequently to execute some
  action, etc.

*NOTE ON OPERATOR OPTIMIZATION TESTS*
We don't use operator optimization code anymore, but it still lives in
the code as dead code. It still has tests, but I couldn't get all of them to
pass with the new timestamp format. I commented out the failing cases for now,
but we should probably remove the dead code soon. I just didn't want to do that
in the same change as this.

Change-Id: I821787414b0debe85c9fffaeb57abd453727af0f
simonpasquier pushed a commit to simonpasquier/prometheus that referenced this issue Oct 12, 2017
@lock
Copy link

lock bot commented Mar 25, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants