-
Notifications
You must be signed in to change notification settings - Fork 216
fix(datastore): change OutgoingMutationQueue use TaskQueue for state transitions #3720
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
Conversation
@@ -55,7 +52,7 @@ final class OutgoingMutationQueue: OutgoingMutationQueueBehavior { | |||
|
|||
let operationQueue = OperationQueue() | |||
operationQueue.name = "com.amazonaws.OutgoingMutationOperationQueue" | |||
operationQueue.underlyingQueue = mutationDispatchQueue | |||
operationQueue.qualityOfService = .default |
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 think the default is .default
so no need to set this
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.
According to the doc, the default value for the OperationQueue
is NSOperationQualityOfServiceBackground
. I set it to the .default
because DispatchQueue.global()
uses a default quality of service (qos = .default
).
For queues you create yourself, the default value is NSOperationQualityOfServiceBackground. For the queue returned by the main method, the default value is NSOperationQualityOfServiceUserInteractive and cannot be changed.
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.
ah, got it, thanks
...urces/AWSDataStorePlugin/Sync/MutationSync/OutgoingMutationQueue/OutgoingMutationQueue.swift
Outdated
Show resolved
Hide resolved
…ionSync/OutgoingMutationQueue/OutgoingMutationQueue.swift Co-authored-by: Michael Law <1365977+lawmicha@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3720 +/- ##
==========================================
+ Coverage 68.38% 68.46% +0.07%
==========================================
Files 1089 1089
Lines 37651 37651
==========================================
+ Hits 25748 25777 +29
+ Misses 11903 11874 -29
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Issue #
The crash reports indicate that a
SEGV_ACCERR
occurred due to an attempted dereference of a garbage pointer. In the implementation of theOutgoingMutationQueue
, themutationDispatchQueue
was targeted to the concurrent global queue, with state transition actions being dispatched to this queue. This setup means thatstarting
andstopping
could trigger two state transite operations running concurrently. Specifically, the starting action needs to complete some I/O work, while the stopping action is cleaning up the operation queue, potentially causing a data race.Description
In this PR, we modified
mutationDispatchQueue
to use theTaskQueue
implementation, ensuring that all state transition actions run serially. Also, we set the mutation eventoperationQueue
to have the same QOS as the global queue and removed the underlying queue.General Checklist
Given When Then
inline code documentation and are named accordinglytestThing_condition_expectation()
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.