Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Add more log context checks when patching inlineCallbacks#6127

Merged
erikjohnston merged 15 commits intodevelopfrom
erikj/patch_inner
Oct 10, 2019
Merged

Add more log context checks when patching inlineCallbacks#6127
erikjohnston merged 15 commits intodevelopfrom
erikj/patch_inner

Conversation

@erikjohnston
Copy link
Copy Markdown
Member

This does two things:

  1. Adds a function that tracks changes in log contexts over yield points. This helps track down roughly where things are going wrong.

  2. Adds an env var to enable patching, so that we can enable it for things like sytest as well as unit tests.

Copy link
Copy Markdown
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

looks generally sane, but a few thoughts

Comment thread synapse/__init__.py Outdated
Comment thread synapse/handlers/room_member.py Outdated
Comment thread tests/patch_inline_callbacks.py Outdated
frame.f_code.co_filename,
)
)
changes.append(err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why do we put these in an array, rather than printing them out immediately?

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.

I've added some comments, but broadly functions do change contexts fairly frequently, e.g. when using Measure or manually creating log contexts, so we only really want to log this info if it later turns out something is going wrong.

In future we might be able to do something that lets us turn this into a hard error by somehow understanding when its "ok" that the log context has changed.

else:
d = gen.send(result)
except (StopIteration, defer._DefGen_Return) as e:
if LoggingContext.current_context() != expected_context:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

isn't this case handled by check_ctx above?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(if we're going to double-check the normal-termination case, we should probably also double-check the raised-an-exception case, and tbh it looks like a bunch of cod e that we can get rid of)

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.

Hmm, yeah, I mainly found it useful for the line numbers

Comment thread tests/patch_inline_callbacks.py
Comment thread tests/patch_inline_callbacks.py Outdated
Comment thread tests/patch_inline_callbacks.py
@erikjohnston erikjohnston marked this pull request as ready for review October 10, 2019 10:53
@erikjohnston erikjohnston requested a review from a team October 10, 2019 12:03
Copy link
Copy Markdown
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

lgtm

Comment thread synapse/util/patch_inline_callbacks.py Outdated
Comment thread synapse/util/patch_inline_callbacks.py Outdated
Comment thread synapse/util/patch_inline_callbacks.py Outdated
Co-Authored-By: Richard van der Hoff <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants