Skip to content

[Rhythm] Fix ingester to correctly delete old blocks even if not flushing to object storage#5005

Merged
mdisibio merged 4 commits intografana:mainfrom
mdisibio:rhythm-ingester-noflush-deletefix
Apr 16, 2025
Merged

[Rhythm] Fix ingester to correctly delete old blocks even if not flushing to object storage#5005
mdisibio merged 4 commits intografana:mainfrom
mdisibio:rhythm-ingester-noflush-deletefix

Conversation

@mdisibio
Copy link
Copy Markdown
Contributor

@mdisibio mdisibio commented Apr 15, 2025

What this PR does:
Fixes a bug in #4857 where the ingester doesn't delete blocks off disk when flush_to_storage=false. Additionally, updated the time comparison to look at the block meta to determine the age of the block. Previously it was based on flushed time, which meant that for a retention 1h it wouldn't delete the block off disk until 1h after it was flushed to object storage.

Which issue(s) this PR fixes:

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Comment thread modules/ingester/instance.go Outdated
}
break
// This block can be deleted.
i.completeBlocks = append(i.completeBlocks[:idx], i.completeBlocks[idx+1:]...)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this line be after the clearBlock try? If we remove the id from the list of complete blocks and then we get an error, the block will be dangling forever

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I guess that has been an issue for a long time. Also, the previous code was only deleting 1 block per pass, and I attemped to delete all matching blocks. This was broken and needed some other updates because we are modifying the slice while iterating it. Thoughts? There are several ways to do this, and none are particularly clear.

… deletion, fix deleting multiple blocks in 1 pass
Comment thread modules/ingester/instance.go
Copy link
Copy Markdown
Collaborator

@joe-elliott joe-elliott left a comment

Choose a reason for hiding this comment

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

a glorious act of software development

@mdisibio mdisibio merged commit ab100cd into grafana:main Apr 16, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants