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(Core): Fixing concurrency issues in AWSSynchronizedMutableDictionary #5413

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

sebaland
Copy link
Member

@sebaland sebaland commented Jul 31, 2024

Issue #, if available:

Description of changes:

When using barriers and concurrent queues, doing dispatch_barrier_sync can cause deadlocks (and crashes), so dispatch_barrier_async is recommended.
Our AWSSynchronizedMutableDictionary was using sync for write operations, which are really unnecessary and can be async. Read operations do remain sync, but with no barrier involved.


Also included in this PR is a potential fix for the random crash when disconnecting and quickly connecting again. If a disconnection happens due to an error, the reconnectThread is trigger, which sets the reconnectTimer so that a reconnection is attempted in x seconds.
But if a new connection is explicitly triggered, a new streamsThread will be created and the old one discarded. We do attempt to invalidate the reconnectTimer in these situations, but we try to do it in the reconnectThread as that is where the timer was set.

However, if the reconnectThread has finished (i.e. not running), then the timer will not be invalidated and will fire eventually, which will attempt to use the now deallocated old streamsThread.
So I'm just adding a simple check to allow us to invalidate the timer anyway if the reconnectThread has finished.


Check points:

  • Added new tests to cover change, if needed
  • All unit tests pass
  • All integration tests pass
  • Updated CHANGELOG.md
  • Documentation update for the change if required
  • PR title conforms to conventional commit style

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

fix(IoT): Fixing random crash when a connection is attempted just after disconnecting
@sebaland sebaland requested review from awsmobilesdk and a team as code owners July 31, 2024 16:40
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 16:40 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:43 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:43 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:43 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland temporarily deployed to IntegrationTest July 31, 2024 17:58 — with GitHub Actions Inactive
@sebaland sebaland merged commit 21daae9 into main Jul 31, 2024
67 checks passed
@sebaland sebaland deleted the ruisebas/dictionary_crash branch July 31, 2024 20:27
@sebaland sebaland restored the ruisebas/dictionary_crash branch July 31, 2024 21:33
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