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: Delete old session replay files #4446

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

fix: Delete old session replay files #4446

wants to merge 8 commits into from

Conversation

brustolin
Copy link
Contributor

📜 Description

Clean up for old session replay files

💚 How did you test it?

Unit tests

📝 Checklist

You have to check all boxes before merging:

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Copy link

github-actions bot commented Oct 15, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1234.65 ms 1251.69 ms 17.04 ms
Size 21.90 KiB 707.58 KiB 685.68 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0ecf042 1228.25 ms 1250.67 ms 22.42 ms
0d32275 1230.96 ms 1237.90 ms 6.94 ms
e0f077c 1224.65 ms 1243.52 ms 18.87 ms
af1f4dd 1207.33 ms 1230.04 ms 22.71 ms
7bc3c0d 1212.35 ms 1228.94 ms 16.59 ms
3f366ee 1242.28 ms 1260.80 ms 18.52 ms
cb6ab62 1213.47 ms 1248.46 ms 34.99 ms
42ef6ba 1219.58 ms 1245.37 ms 25.78 ms
b9d59f7 1222.23 ms 1227.16 ms 4.93 ms
888a145 1228.63 ms 1248.94 ms 20.30 ms

App size

Revision Plain With Sentry Diff
0ecf042 21.58 KiB 631.82 KiB 610.24 KiB
0d32275 22.84 KiB 403.14 KiB 380.29 KiB
e0f077c 22.85 KiB 412.59 KiB 389.74 KiB
af1f4dd 22.85 KiB 414.71 KiB 391.86 KiB
7bc3c0d 20.76 KiB 427.35 KiB 406.59 KiB
3f366ee 20.76 KiB 427.84 KiB 407.08 KiB
cb6ab62 22.85 KiB 413.42 KiB 390.57 KiB
42ef6ba 21.58 KiB 417.86 KiB 396.28 KiB
b9d59f7 22.85 KiB 405.77 KiB 382.92 KiB
888a145 21.58 KiB 713.54 KiB 691.96 KiB

Previous results on branch: fix/sr-clean-up

Startup times

Revision Plain With Sentry Diff
feff236 1223.37 ms 1258.00 ms 34.63 ms

App size

Revision Plain With Sentry Diff
feff236 21.90 KiB 707.69 KiB 685.79 KiB

Comment on lines +376 to +377
// Mapping replay folder here and not in dispatched queue to prevent a race condition between
// listing files and creating a new replay session.
Copy link
Member

Choose a reason for hiding this comment

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

The dispatch queue in the dependency manager is a serial queue, so there shouldn't be a danger of race condition:

dispatch_queue_attr_t attributes = dispatch_queue_attr_make_with_qos_class(
DISPATCH_QUEUE_SERIAL, DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

In fact, you might even be creating a race condition by not placing this on the serial queue, depending on what other replay operations are or aren't also performed on the queue. Something that was previously deferred might be interleaved with this line and the next block enqueued below in various combinations.

For instance, what happens if multiple calls to SentryReplayApi.start are received in quick succession?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The dispatch queue in the dependency manager is a serial queue

But the SentrySessionReplay class that creates a new replay session has it own queue.

what happens if multiple calls to SentryReplayApi.start

The Integration is initialized only once and the cleanUp will run only once.

Copy link
Member

@armcknight armcknight Oct 16, 2024

Choose a reason for hiding this comment

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

Hm, the only reason I mentioned the dependency container's queue is because that's what's being used in this file. Should we use one queue for all replay activity? Why the dependency container's here and the private queue in SentrySessionReplay.swift, wouldn't that open up the possibility of more race conditions?

Sources/Sentry/SentrySessionReplayIntegration.m Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

Attention: Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.

Project coverage is 91.351%. Comparing base (f31b069) to head (92fa6bc).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Sources/Sentry/SentrySessionReplayIntegration.m 89.285% 3 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #4446       +/-   ##
=============================================
+ Coverage   91.343%   91.351%   +0.008%     
=============================================
  Files          610       610               
  Lines        49928     49964       +36     
  Branches     18039     18047        +8     
=============================================
+ Hits         45606     45643       +37     
  Misses        4230      4230               
+ Partials        92        91        -1     
Files with missing lines Coverage Δ
...onReplay/SentrySessionReplayIntegrationTests.swift 98.884% <100.000%> (+0.061%) ⬆️
Sources/Sentry/SentrySessionReplayIntegration.m 85.818% <89.285%> (+0.442%) ⬆️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f31b069...92fa6bc. Read the comment docs.

Copy link

github-actions bot commented Oct 16, 2024

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryFileManager.m

@brustolin
Copy link
Contributor Author

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing >these files, and have an extra careful look at these:

Sources/Sentry/SentryFileManager.m

It's just a new function to check whether a path points to a directory.

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.

4 participants