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

Add more log context checks when patching inlineCallbacks #6127

Merged
merged 15 commits into from
Oct 10, 2019

Conversation

erikjohnston
Copy link
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
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

synapse/__init__.py Outdated Show resolved Hide resolved
synapse/handlers/room_member.py Outdated Show resolved Hide resolved
tests/patch_inline_callbacks.py Outdated Show resolved Hide resolved
frame.f_code.co_filename,
)
)
changes.append(err)
Copy link
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
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
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
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
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

tests/patch_inline_callbacks.py Outdated Show resolved Hide resolved
tests/patch_inline_callbacks.py Outdated Show resolved Hide resolved
tests/patch_inline_callbacks.py Outdated Show resolved Hide resolved
@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
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

synapse/util/patch_inline_callbacks.py Outdated Show resolved Hide resolved
synapse/util/patch_inline_callbacks.py Outdated Show resolved Hide resolved
synapse/util/patch_inline_callbacks.py Outdated Show resolved Hide resolved
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