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

Add more log context checks when patching inlineCallbacks #6127

Merged
merged 15 commits into from Oct 10, 2019

Conversation

@erikjohnston
Copy link
Member

erikjohnston commented Sep 27, 2019

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 left a comment

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)

This comment has been minimized.

Copy link
@richvdh

richvdh Sep 30, 2019

Member

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

This comment has been minimized.

Copy link
@erikjohnston

erikjohnston Oct 10, 2019

Author Member

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:

This comment has been minimized.

Copy link
@richvdh

richvdh Sep 30, 2019

Member

isn't this case handled by check_ctx above?

This comment has been minimized.

Copy link
@richvdh

richvdh Sep 30, 2019

Member

(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)

This comment has been minimized.

Copy link
@erikjohnston

erikjohnston Oct 10, 2019

Author Member

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 Oct 10, 2019
@erikjohnston erikjohnston requested a review from matrix-org/synapse-core Oct 10, 2019
Copy link
Member

richvdh left a comment

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 <1389908+richvdh@users.noreply.github.com>
@erikjohnston erikjohnston merged commit 933034e into develop Oct 10, 2019
16 of 18 checks passed
16 of 18 checks passed
buildkite/synapse Build #4903 failed (29 minutes, 4 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-monolith Failed (exit status 1)
Details
buildkite/synapse/check-sample-config Passed (1 minute, 25 seconds)
Details
buildkite/synapse/check-style Passed (1 minute, 59 seconds)
Details
buildkite/synapse/isort Passed (16 seconds)
Details
buildkite/synapse/mypy Passed (26 seconds)
Details
buildkite/synapse/newspaper-newsfile Passed (14 seconds)
Details
buildkite/synapse/packaging Passed (33 seconds)
Details
buildkite/synapse/pipeline Passed (3 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-postgres-9-dot-5 Passed (17 minutes, 58 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite Passed (6 minutes, 9 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite-slash-old-deps Passed (12 minutes, 20 seconds)
Details
buildkite/synapse/python-3-dot-6-slash-sqlite Passed (7 minutes, 6 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-11 Passed (17 minutes, 55 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-9-dot-5 Passed (17 minutes, 47 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-sqlite Passed (6 minutes, 48 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-workers Passed (12 minutes, 18 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-sqlite-slash-monolith Passed (11 minutes, 54 seconds)
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.