-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
GetRef returns 0 for existing series #8861
Comments
cc @bwplotka |
From an interface standpoint, it's correct, it's up to the implementation to drop series any time, so getRef can get 0 when labels are not preserved. But based on our implementation it indeed sounds weird, maybe it's some race? Still, it's not dangerous, callers should expect any of this. |
ok I refactored the example a bit to make it more clear where I am confused. Main thing I can't figure out is how would I avoid creating the same timeseries with a diff ref ID which is what is happening here? I was expecting that |
also I see few places in Prometheus itself where the Append is called with 0 for the reference so this means that the same timeseries will be created under a new reference every time. |
I don’t think the implementation is compelled to add something new every time you pass zero to (I didn’t check this in the code today. Speaking from memory.) |
@bboreham yes this is what I thought, but did you look at my example? |
Maybe this behaviour changed with the recent |
It does the expected thing if you swap |
It's on the definition of prometheus/pkg/labels/labels.go Lines 42 to 44 in 03b354d
|
Nice finding! Ordering is a must - hash is totally different depending on the order. So is there something we should change @krasi-georgiev or does it solve your problem? |
@bboreham no labels are swapped, the code is using exactly the same labels for all appends. here is the same code but only with append for 3 labels.
output
|
oooh, now I understand what are you saying, the labels need to be sorted before the append. |
I have run your code with sorted labels, indeed it works as expected:
thanks @bboreham for the investigation. |
yep here is the updated code that works
output
|
The following call to
GetRef
always returns 0 in the first iteration even when the series exists.The strange thing is that when is commented out
labels.Label{Name: "domain", Value: "b"},
it returns the existing reference for the series as expected.This is with the current commit on the main branch #03b354d4d9386e4b3bfbcd45da4bb58b182051a5
I am not sure if this is a bug or the implementation of using
GetRef
is incorrect.cc @codesome , @tomwilkie , @bboreham
output:
The text was updated successfully, but these errors were encountered: