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

[EMBR-2802] Fix race condition on LogSink and LogOrchestrator. #544

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

lucaslabari
Copy link
Contributor

Goal

  • Converted the list on LogSink into a ConcurrentLinkedQueue to use thread-safe operations.
  • Added a lock on the flush method, so no more than one thread can execute the flush at the same time.
  • Added a param to the flushLogs method to provide the max number of logs to flush.
  • Converted properties that hold time in LogOrchestrator to AtomicLong.

Testing

Added a method created by Hanson to emulate the race condition.

@lucaslabari lucaslabari requested a review from a team as a code owner March 11, 2024 16:12
@lucaslabari lucaslabari changed the title Fix race condition on LogSink and LogOrchestrator. [EMBR-2802] Fix race condition on LogSink and LogOrchestrator. Mar 11, 2024
Copy link

Copy link
Collaborator

@bidetofevil bidetofevil left a comment

Choose a reason for hiding this comment

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

LGTM! One comment about simplifying the flush logic but feel free to take it or leave it

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 96.29630% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 79.70%. Comparing base (5e18d90) to head (9bd44a7).
Report is 25 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #544      +/-   ##
==========================================
+ Coverage   79.45%   79.70%   +0.24%     
==========================================
  Files         403      409       +6     
  Lines       10861    10927      +66     
  Branches     1602     1613      +11     
==========================================
+ Hits         8630     8709      +79     
+ Misses       1585     1571      -14     
- Partials      646      647       +1     
Files Coverage Δ
...mbrace/android/embracesdk/internal/logs/LogSink.kt 100.00% <100.00%> (ø)
...ce/android/embracesdk/internal/logs/LogSinkImpl.kt 88.88% <100.00%> (+1.38%) ⬆️
...ndroid/embracesdk/internal/logs/LogOrchestrator.kt 91.66% <93.75%> (+7.29%) ⬆️

... and 25 files with indirect coverage changes

@lucaslabari lucaslabari merged commit c1735c9 into master Mar 11, 2024
4 checks passed
@lucaslabari lucaslabari deleted the lucas/fix_race_condition_logs branch March 11, 2024 19:05
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

3 participants