Skip to content

Fixup logcontexts after replication PR.#19146

Merged
erikjohnston merged 3 commits into
developfrom
erikj/lgc
Nov 5, 2025
Merged

Fixup logcontexts after replication PR.#19146
erikjohnston merged 3 commits into
developfrom
erikj/lgc

Conversation

@erikjohnston

Copy link
Copy Markdown
Member

Fixes logcontext leaks introduced in #19138.

@erikjohnston erikjohnston marked this pull request as ready for review November 5, 2025 15:11
@erikjohnston erikjohnston requested a review from a team as a code owner November 5, 2025 15:11
@erikjohnston erikjohnston merged commit 6790312 into develop Nov 5, 2025
41 of 43 checks passed
@erikjohnston erikjohnston deleted the erikj/lgc branch November 5, 2025 15:38
Comment on lines +1032 to +1033
with PreserveLoggingContext():
self._deferred.callback(None)

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.

I spotted some of this while reviewing the original PR (see #19142) but went back and forth on whether this was actually a problem before calling it off.

For my own reference, can you explain how this is messing up the logcontexts please?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, so I think what is happening here is some combination of a) not being careful of logcontexts when using raw deferreds (note that .callback(None) will run code waiting on the deferred), and b) I think the new(?) call_later logcontexts get confused when passing in a synchronous deferred.callback? I didn't quite hunt down exactly what went wrong, and it may be more of a problem with how it got used by BackgroundQueue that didn't affect current usages

@MadLittleMods MadLittleMods Nov 5, 2025

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.

What I don't understand is "a) not being careful of logcontexts when using raw deferreds (note that .callback(None) will run code waiting on the deferred)"

I can see the whole deferred and interactions in the old version of DeferredEvent. Nothing is being added to the deferred callback chain and nothing is even changing logging contexts at all there.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

When those deferreds get called they were waking up the DeferredList , which then triggered the behaviour in make_deferred_yieldable to set the logcontexts to something. Then there is nothing to set those logcontexts back after the .callback(..) has finished?

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.

Ahh, perfect! I see. Thanks for pointing out the connection and explaining! 🙇

MadLittleMods added a commit that referenced this pull request Nov 13, 2025
MadLittleMods added a commit that referenced this pull request Nov 13, 2025
MadLittleMods added a commit that referenced this pull request Nov 13, 2025
MadLittleMods added a commit that referenced this pull request Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants