Skip to content

Loki: Fix memchunk headblock filter #8591

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

Merged
merged 4 commits into from
Feb 22, 2023
Merged

Conversation

DylanGuedes
Copy link
Contributor

What this PR does / why we need it:
Fix our memchunk headblock filter to not skip entries that have timestamp=maxT.

@DylanGuedes DylanGuedes requested a review from a team as a code owner February 22, 2023 18:19
@DylanGuedes DylanGuedes changed the title Fix memchunk headblock filter. Loki: Fix memchunk headblock filter Feb 22, 2023
@@ -1005,7 +1005,7 @@ func (hb *headBlock) Iterator(ctx context.Context, direction logproto.Direction,
baseHash := pipeline.BaseLabels().Hash()
process := func(e entry) {
// apply time filtering
if e.t < mint || e.t >= maxt {
if e.t < mint || e.t > maxt {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in all cases timestamp filtering Loki is inclusive of the start time and exclusive of the end time.

I'm not 100% sure what's driving this change but I think it is likely correct as is?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, sorry should have slowed down a little, it looks like the change you are making would follow the convention I just outlined.

Is there more context for this change though?

Copy link
Contributor Author

@DylanGuedes DylanGuedes Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context:

  • we're releasing a new version that updates Go version to Go 1.20
  • go 1.20 linter complained that this part of the code was shadowing the tt variable
  • once I added the tt := tt assignment the tests started to break. Removing the parallel flag also exposed the problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all that said: this isn't a major problem, I talked with Owen and it is a nanosecond precision, so not really important. however, it is blocking the new Loki version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, I think I stand by my initial feedback, I think this change breaks important behavior. (it's actually testing if the timestamp is outside the bounds)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ts == maxt is technically outside of the bounds since end time is not inclusive.

Copy link
Contributor Author

@DylanGuedes DylanGuedes Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right but what if maxt == mint? ex: maxt=1, mint1= and you have an entry with ts=1.
since start time is inclusive I'd expect it to have precedence over end time not being inclusive.
also, that test that I removed the Parallel call is supposed to fail; it is only passing because of the variable shadowing in conjunction with the parallel call.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think when maxt == mint (such as an instant query), we mutate the endts = endts+1nanosecond prior to running the query

@MasslessParticle MasslessParticle merged commit 030d323 into main Feb 22, 2023
@MasslessParticle MasslessParticle deleted the fix-headblock-check branch February 22, 2023 20:39
owen-d added a commit that referenced this pull request Feb 22, 2023
owen-d added a commit that referenced this pull request Feb 22, 2023
Reverts #8591

This altered an internal API. We execute queries that are inclusive of
start and exclusive of end: `[start,end)` and shouldn't break this. We
use other ways to ensure `start==end` still works, such as by using the
lookback-period to alter the range of queries:

https://github.com/grafana/loki/blob/main/pkg/logql/evaluator.go#L179-L181
MichelHollands added a commit that referenced this pull request Feb 23, 2023
**What this PR does / why we need it**:

- Use the 0.28.1 build image
- Update Go version to 1.20.1
- Use Alpine 3.16.4
- Fix linter issues due to updated govet in 1.20.1 
- Modify images to not create `/etc/nsswitch.conf` file anymore
(available by default on Alpine 3.16.4)
- Remove impossible test cases for `TestMemChunk_IteratorBounds`(see
#8591 (comment) for
context)

Signed-off-by: Michel Hollands <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Co-authored-by: Christian Haudum <[email protected]>
Co-authored-by: DylanGuedes <[email protected]>
DylanGuedes added a commit that referenced this pull request Feb 24, 2023
**What this PR does / why we need it**:

- Use the 0.28.1 build image
- Update Go version to 1.20.1
- Use Alpine 3.16.4
- Fix linter issues due to updated govet in 1.20.1
- Modify images to not create `/etc/nsswitch.conf` file anymore
(available by default on Alpine 3.16.4)
- Remove impossible test cases for `TestMemChunk_IteratorBounds`(see
#8591 (comment) for
context)

Signed-off-by: Michel Hollands <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Co-authored-by: Christian Haudum <[email protected]>
Co-authored-by: DylanGuedes <[email protected]>
(cherry picked from commit 4f8d324)
mraboosk pushed a commit to mraboosk/loki that referenced this pull request Oct 7, 2024
**What this PR does / why we need it**:

- Use the 0.28.1 build image
- Update Go version to 1.20.1
- Use Alpine 3.16.4
- Fix linter issues due to updated govet in 1.20.1 
- Modify images to not create `/etc/nsswitch.conf` file anymore
(available by default on Alpine 3.16.4)
- Remove impossible test cases for `TestMemChunk_IteratorBounds`(see
grafana#8591 (comment) for
context)

Signed-off-by: Michel Hollands <[email protected]>
Signed-off-by: Christian Haudum <[email protected]>
Co-authored-by: Christian Haudum <[email protected]>
Co-authored-by: DylanGuedes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants