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

Fix data race with logging #1215

Merged
merged 3 commits into from Feb 14, 2024
Merged

Fix data race with logging #1215

merged 3 commits into from Feb 14, 2024

Conversation

ankur22
Copy link
Collaborator

@ankur22 ankur22 commented Feb 13, 2024

What?

Remove the use of the logrus formatter.

Why?

  1. When we use the loki output, it can cause a race condition since the loki hook works with the entry (the log message and metadata) asynchronously, which means that while the hook reads the entry, the formatter could be amending the same entry. The entry is not thread safe.
  2. The formatter is only used in one place, which is when writing the output from console.log that is used in the website under test. This change could safely be moved to where it's used, which also makes it clear how the console message is formatted before being logged.

Full details can be found here: #1066 (comment)

Checklist

  • I have performed a self-review of my code
  • I have added tests for my changes
  • I have commented on my code, particularly in hard-to-understand areas

Related PR(s)/Issue(s)

Updates: #1066

Copy link
Member

@inancgumus inancgumus left a comment

Choose a reason for hiding this comment

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

LGTM

The log formatter causes two issues:
1. When we use the loki output, it can cause a race condition since the
   loki hook works with the entry (the log message and metadata)
   asynchronously, which means that while the hook reads the entry, the
   formatter could be amending the same entry. The entry is not thread
   safe.
2. The formatter is only used in one place, which is when writing the
   output from console.log that is used in the website under test. This
   change could safely be moved to where it's used, which also makes it
   clear how the console message is formatted before being logged.
The serializer doesn't do anything new now that the formatter has been
removed, so use the logger.
The serializer isn't needed since all it does is create a clone of the
existing logger.
@ankur22 ankur22 merged commit b90c091 into main Feb 14, 2024
17 checks passed
@ankur22 ankur22 deleted the fix/1066_data_race branch February 14, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants