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

Tail queue #11930

Merged
merged 2 commits into from
Feb 20, 2024
Merged

Tail queue #11930

merged 2 commits into from
Feb 20, 2024

Conversation

salvacorts
Copy link
Contributor

No description provided.

@salvacorts salvacorts changed the title tail queue Tail queue Feb 14, 2024
@salvacorts salvacorts mentioned this pull request Feb 16, 2024
8 tasks
@salvacorts salvacorts marked this pull request as ready for review February 16, 2024 10:06
@salvacorts salvacorts requested a review from a team as a code owner February 16, 2024 10:06
@@ -288,30 +288,28 @@ func (s *stream) recordAndSendToTailers(record *wal.Record, entries []logproto.E
hasTailers := len(s.tailers) != 0
s.tailerMtx.RUnlock()
if hasTailers {
go func() {
Copy link
Member

Choose a reason for hiding this comment

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

Hmm I don't understand the surrounding code, but from the recordAndSendToTailers() name and from the previous usage of a goroutine here, I assume this part should be as non-blocking as possible? If so, does it make sense to keep the goroutine here? We'd still handle the actual sending over a queue, but this part won't be blocking either.

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 removing the goroutine and sending the stream to the queue. Since the queue is a buffered channel, it's a non-blocking opt (if chan is full, the stream is dropped)

Copy link
Member

@na-- na-- left a comment

Choose a reason for hiding this comment

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

LGTM in general, though I don't understand enough of the context to give it a proper 👍

@na-- na-- requested a review from a team February 16, 2024 11:25
for {
select {
case <-t.conn.Context().Done():
t.close()
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 maybe t.close() should be in a defer block so that anywhere we return from this function it would be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@slim-bean slim-bean left a comment

Choose a reason for hiding this comment

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

one change to close the the tailer if we exit the receive loop for any reason, otherwise LGTM!

@salvacorts salvacorts merged commit b7cb85f into main Feb 20, 2024
8 checks passed
@salvacorts salvacorts deleted the salvacorts/debug-tail-queue branch February 20, 2024 09:41
rhnasc pushed a commit to inloco/loki that referenced this pull request Apr 12, 2024
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.

None yet

3 participants