Skip to content

loki.source.journal: fix deadlock#4571

Merged
kalleep merged 4 commits intomainfrom
thampiotr/fix-journal-deadlock
Oct 9, 2025
Merged

loki.source.journal: fix deadlock#4571
kalleep merged 4 commits intomainfrom
thampiotr/fix-journal-deadlock

Conversation

@thampiotr
Copy link
Contributor

@thampiotr thampiotr commented Oct 8, 2025

PR Description

loki.source.journal needs the same fix as we have done in #4352

Which issue(s) this PR fixes

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

@thampiotr thampiotr marked this pull request as ready for review October 8, 2025 15:44
@thampiotr thampiotr requested a review from a team as a code owner October 8, 2025 15:44
@kalleep kalleep requested a review from Copilot October 9, 2025 06:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a potential deadlock issue in the loki.source.journal component by implementing the same synchronization pattern that was previously applied to the syslog component. The fix ensures proper handling of component stopping and reloading to prevent deadlock scenarios.

Key changes:

  • Refactored the main run loop to use a separate reloadTargets() method instead of inline target management
  • Added a draining routine to handle entries during component shutdown/reload
  • Improved synchronization by copying state before releasing locks during stop operations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/component/loki/source/journal/journal.go Implements deadlock prevention by refactoring target lifecycle management and adding proper draining routines
internal/component/loki/source/syslog/syslog.go Shows the reference implementation pattern being applied to journal component
CHANGELOG.md Documents the deadlock fix for the journal component

Copy link
Contributor

@kalleep kalleep left a comment

Choose a reason for hiding this comment

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

Great, as we talked about in slack we should review other loki components to make sure they all follow the same pattern

@kalleep kalleep merged commit 08c69ec into main Oct 9, 2025
41 checks passed
@kalleep kalleep deleted the thampiotr/fix-journal-deadlock branch October 9, 2025 06:47
kalleep pushed a commit that referenced this pull request Oct 9, 2025
* loki.source.journal: fix deadlock

* changelog

* remove redundant field

* rephrase changelog
kalleep added a commit that referenced this pull request Oct 9, 2025
* loki.source.journal: fix deadlock (#4571)

* fix: add logging wrapper for cloudwatch exporter with support for debug field (#4553)

* Use sync timeout to decide how long to retry waiting for k8s api for prometheus.operator.* components (#4568)

---------

Co-authored-by: Piotr <17101802+thampiotr@users.noreply.github.com>
Co-authored-by: Sam DeHaan <sam.dehaan@grafana.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants