-
Notifications
You must be signed in to change notification settings - Fork 369
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
Deadlock and concurrent modification related to Model.data #1944
Merged
jinliu9508
merged 3 commits into
user-model/main
from
deadlock-between-model-and-subscriber
Jan 10, 2024
Merged
Deadlock and concurrent modification related to Model.data #1944
jinliu9508
merged 3 commits into
user-model/main
from
deadlock-between-model-and-subscriber
Jan 10, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jinliu9508
requested review from
jkasten2,
nan-li,
emawby,
shepherd-l and
jennantilla
December 15, 2023 21:33
jinliu9508
force-pushed
the
deadlock-between-model-and-subscriber
branch
from
January 2, 2024 18:19
15f0554
to
450d943
Compare
jinliu9508
force-pushed
the
deadlock-between-model-and-subscriber
branch
from
January 2, 2024 20:21
450d943
to
b40fc6b
Compare
jinliu9508
force-pushed
the
deadlock-between-model-and-subscriber
branch
2 times, most recently
from
January 2, 2024 21:33
8ebc7ee
to
907631b
Compare
jinliu9508
changed the title
WIP: Deadlock between model and subscriber
Deadlock and concurrent modification related to Model.data
Jan 2, 2024
jinliu9508
force-pushed
the
deadlock-between-model-and-subscriber
branch
from
January 2, 2024 22:04
907631b
to
2b7a27b
Compare
jkasten2
requested changes
Jan 3, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some other possible deadlocks, such as addItem
and removeItem
since they fire events externally. Even if firing doesn't create a deadlock now this is a risk in the future, as well threads could be waiting longer than needed.
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/common/modeling/Model.kt
Outdated
Show resolved
Hide resolved
...nal/core/src/test/java/com/onesignal/user/internal/subscriptions/SubscriptionManagerTests.kt
Outdated
Show resolved
Hide resolved
jinliu9508
force-pushed
the
deadlock-between-model-and-subscriber
branch
from
January 8, 2024 18:58
2b7a27b
to
037f81d
Compare
jinliu9508
force-pushed
the
deadlock-between-model-and-subscriber
branch
from
January 8, 2024 19:20
037f81d
to
4f0d3d1
Compare
jkasten2
approved these changes
Jan 9, 2024
Merged
jinliu9508
added a commit
that referenced
this pull request
Jan 31, 2024
…bscriber Deadlock and concurrent modification related to Model.data
jinliu9508
added a commit
that referenced
this pull request
Jan 31, 2024
…bscriber Deadlock and concurrent modification related to Model.data
jinliu9508
added a commit
that referenced
this pull request
Feb 6, 2024
…bscriber Deadlock and concurrent modification related to Model.data
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Fix ANR and concurrent modification exception related to Model.setOptAnyProperty that locks Model.data.
Details
Motivation
Fix a bug that causes ANR and/or concurrent modification exception
Scope
This will solve any ANR that calls setOptAnyProperty and concurrent modification exception that calls toJson in the stack trace.
Other
This PR comprises three commits. The first commit introduces a test unit that creates a deadlock scenario, resulting in a failed test due to the deadlock. The second commit implements the fix for the issue, allowing us to observe the successful execution of the unit test post-fix. The third commit concludes with final wrap-up and cleanup, preparing it for merging.
Testing
Unit testing
A test unit is added to SubscriptionManagerTests to simulate a deadlock scenario.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is