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

Use the parent's logging context name for runWithConnection. #9895

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/9895.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in v1.32.0 where the associated connection was improperly logged for SQL logging statements.
4 changes: 3 additions & 1 deletion synapse/storage/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,9 @@ def inner_func(conn, *args, **kwargs):
# pool).
assert not self.engine.in_transaction(conn)

with LoggingContext("runWithConnection", parent_context) as context:
with LoggingContext(
str(curr_context), parent_context=parent_context
Copy link
Member Author

Choose a reason for hiding this comment

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

str(curr_context) will either be parent_context.name or "sentinel". We do this in a few other spots so seems reasonable to do here too.

We could add a suffix, but in that case should be using nested_logging_context. 🤷

Copy link
Member

Choose a reason for hiding this comment

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

I also couldn't see any other LoggingContext that need to be changed

) as context:
sched_duration_sec = monotonic_time() - start_time
sql_scheduling_timer.observe(sched_duration_sec)
context.add_database_scheduled(sched_duration_sec)
Expand Down