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

[PLAT-6223] Fix unreliable ordering of breadcrumbs #1049

Merged
merged 1 commit into from
Mar 22, 2021

Conversation

nickdowell
Copy link
Contributor

@nickdowell nickdowell commented Mar 22, 2021

Goal

Fixes a customer reported issue where breadcrumbs sometimes appeared in the wrong order.

Changeset

The bug was caused by sorting the breadcrumb filenames using -[NSString compare:] - which causes e.g. "20" to appear before "3".

-[BugsnagBreadcrumbs loadBreadcrumbsAsDictionaries:] now sorts filenames using a custom comparator.

There is remaining issue - when leaving breadcrumbs simultaneously from multiple threads, the order of file writes does not always match the timestamps (a thread may stop executing between recording the timestamp and writing the file) so the timestamps sometimes are out of order.

Attempted sorting breadcrumbs by their timestamp, but that is problematic due to the limited accuracy used in the JSON representation - causing unit tests to fail due to unreliable ordering of breadcrumbs.

Testing

Reproduced the issue by amending the BugsnagStressTest fixture to check breadcrumbs ordering. I have not committed this check since it fails due to the concurrency issue.

Reproducing via E2E tests was not successful as they do not log a sufficient volume of breadcrumbs to trigger the bug.

@nickdowell nickdowell force-pushed the nickdowell/fix-breadcrumbs-ordering branch from 4363667 to bcbd82f Compare March 22, 2021 14:27
@github-actions
Copy link

github-actions bot commented Mar 22, 2021

Infer: No issues found 🎉

OCLint: No issues found 🎉

Bugsnag.framework binary size increased by 440 bytes from 1,102,456 to 1,102,896

Generated by 🚫 Danger

@nickdowell nickdowell force-pushed the nickdowell/fix-breadcrumbs-ordering branch 3 times, most recently from 36f6395 to 6e0f437 Compare March 22, 2021 15:09
@nickdowell nickdowell marked this pull request as ready for review March 22, 2021 15:16
@nickdowell nickdowell marked this pull request as draft March 22, 2021 15:22
@nickdowell nickdowell removed the request for review from kstenerud March 22, 2021 15:32
@nickdowell nickdowell closed this Mar 22, 2021
@nickdowell nickdowell force-pushed the nickdowell/fix-breadcrumbs-ordering branch from 6e0f437 to a0166e1 Compare March 22, 2021 15:44
@nickdowell
Copy link
Contributor Author

Not sure what's happened here, I didn't close the PR 🤨

@nickdowell nickdowell reopened this Mar 22, 2021
@nickdowell nickdowell marked this pull request as ready for review March 22, 2021 16:19
@nickdowell nickdowell requested a review from kattrali March 22, 2021 16:19
@nickdowell nickdowell merged commit 404388d into next Mar 22, 2021
@nickdowell nickdowell deleted the nickdowell/fix-breadcrumbs-ordering branch March 22, 2021 16:22
@nickdowell nickdowell mentioned this pull request Mar 24, 2021
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.

2 participants