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

feat(blooms): disk-backed queue for the bloom-planner #14874

Merged
merged 3 commits into from
Nov 13, 2024

Conversation

salvacorts
Copy link
Contributor

@salvacorts salvacorts commented Nov 12, 2024

What this PR does / why we need it:
We store chunkrefs for each task. As a result, the queue can grow and not fit into memory. This PR adds a new set of options to configure the queue to store the tasks in the filesystem. As a result, the queue only keeps the task metadata (e.g. results channel, time in queue, retires...) and the path to the task in the disk.

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@salvacorts salvacorts force-pushed the salvacorts/disk-backed-queue-bloom-planner branch from de63e40 to 1e1d05b Compare November 12, 2024 14:02
@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Nov 12, 2024
@salvacorts salvacorts force-pushed the salvacorts/disk-backed-queue-bloom-planner branch from 1e1d05b to 015e123 Compare November 12, 2024 14:07
@salvacorts salvacorts marked this pull request as ready for review November 12, 2024 14:11
@salvacorts salvacorts requested a review from a team as a code owner November 12, 2024 14:11
}

// RegisterFlagsWithPrefix registers flags for the bloom-planner configuration.
func (cfg *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.IntVar(&cfg.MaxQueuedTasksPerTenant, prefix+".max-tasks-per-tenant", 30000, "Maximum number of tasks to queue per tenant.")
f.BoolVar(&cfg.StoreTasksOnDisk, prefix+".store-tasks-on-disk", false, "Whether to store tasks on disk.")
f.StringVar(&cfg.TasksDiskDirectory, prefix+".tasks-disk-directory", "/tmp/bloom-planner-queue", "Directory to store tasks on disk. All files will be removed on startup.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
f.StringVar(&cfg.TasksDiskDirectory, prefix+".tasks-disk-directory", "/tmp/bloom-planner-queue", "Directory to store tasks on disk. All files will be removed on startup.")
f.StringVar(&cfg.TasksDiskDirectory, prefix+".tasks-disk-directory", "/tmp/bloom-planner-queue", "Directory to persist tasks on disk across restarts.")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are not yet doing this.

All files will be removed on startup

Removing this bit.

Comment on lines 105 to 108
// TODO(salvacorts): We can recover the queue from the disk here.
// Until then, we just remove all the files in the directory so the disk
// doesn't grow indefinitely.
if q.cfg.StoreTasksOnDisk && q.cfg.CleanTasksDirectory {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we cannot recover tasks from disk yet, we should not expose any settings for it.

CleanTaskDirectory should be false instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should not expose any settings for it.

I don't think we are. Which one do you mean?

CleanTasksDirectory will be gone when we are able to recover tasks from the disk.

Until then, if we do not recover from the disk, we will keep leaking files into the disk across restarts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, ofc it should be true. No need for a setting then

Copy link
Contributor

Choose a reason for hiding this comment

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

return filepath.Join("tasks", task.Tenant(), task.Table(), task.ID())
func getTaskPath(task *protos.ProtoTask) string {
table := protos.FromProtoDayTableToDayTable(task.Table)
taskFile := task.Id + ".task"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use .protobuf extension to indicate that the content is a binary encoded protobuf object

useDisk bool
}{
{
name: "in-memory",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Could be more explicit:

Suggested change
name: "in-memory",
name: "in-memory",
useDisk: false,

pkg/bloombuild/planner/queue/queue.go Outdated Show resolved Hide resolved
Co-authored-by: Christian Haudum <christian.haudum@gmail.com>
@salvacorts salvacorts merged commit b646861 into main Nov 13, 2024
58 checks passed
@salvacorts salvacorts deleted the salvacorts/disk-backed-queue-bloom-planner branch November 13, 2024 08:35
loki-gh-app bot pushed a commit that referenced this pull request Nov 14, 2024
Co-authored-by: Christian Haudum <christian.haudum@gmail.com>
(cherry picked from commit b646861)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport k227 size/XL type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants