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

chore: flush idle dataobjects after X seconds #16348

Merged
merged 6 commits into from
Feb 18, 2025
Merged

Conversation

fcjack
Copy link
Contributor

@fcjack fcjack commented Feb 18, 2025

What this PR does / why we need it:

We need an idle check for our objects to be flushed, since there are cases that objects are in memory until reach the configurable size.

If we stop receiving data the size won't increase and it is not flushed.

Which issue(s) this PR fixes:
Fixes https://github.com/grafana/loki-private/issues/1359

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

@fcjack fcjack self-assigned this Feb 18, 2025
@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Feb 18, 2025
Copy link
Contributor

github-actions bot commented Feb 18, 2025

💻 Deploy preview deleted.

@fcjack fcjack changed the title chore(wip): flush idle dataobjects after X seconds chore: flush idle dataobjects after X seconds Feb 18, 2025
@fcjack fcjack marked this pull request as ready for review February 18, 2025 15:15
@fcjack fcjack requested a review from a team as a code owner February 18, 2025 15:15
@fcjack fcjack enabled auto-merge (squash) February 18, 2025 16:24
Copy link
Contributor

@benclive benclive left a comment

Choose a reason for hiding this comment

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

LGTM. I left a few minor suggestions but approving so you can merge once you're ready

cfg.IdleFlushTimeout = 60 * 60 * time.Second // default to 1 hour
}

f.DurationVar(&cfg.IdleFlushTimeout, prefix+"idle-flush-timeout", cfg.IdleFlushTimeout, "The maximum amount of time to wait in seconds before flushing an object that is no longer receiving new writes")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can set the default value as the 3rd argument in the flag definition, if you wish

@@ -39,6 +39,10 @@ type partitionProcessor struct {
bucket objstore.Bucket
bufPool *sync.Pool

// Idle stream handling
idleFlushTimout time.Duration
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: Timout -> Timeout

}

now := time.Now()
if now.Sub(p.lastFlush) < p.idleFlushTimout {
Copy link
Contributor

Choose a reason for hiding this comment

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

You could also use time.Since here: time.Since(p.lastFlush) < p.idleFlushTimeout
In practice it makes very little difference but its slightly easier to read

@fcjack fcjack merged commit a51e5a2 into main Feb 18, 2025
61 checks passed
@fcjack fcjack deleted the fcjack/flush-idle-objects branch February 18, 2025 16:37
@fcjack fcjack mentioned this pull request Feb 18, 2025
6 tasks
fcjack added a commit that referenced this pull request Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L type/chore 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