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(DataStore): Reconcile mutation responses from conflict handler path #3370

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

lawmicha
Copy link
Contributor

@lawmicha lawmicha commented Nov 17, 2023

Issue #

Description

This PR passes the reconciliationQueue to the ProcessMutationErrorFromCloudOperation to reconcile conflict-handler resulting mutation responses. Reconciliation will update the local model's metadata version to keep it up to date.

The impact; normally this is not needed since the subscription events should funnel into the reconciliation queue, however this is not the case for apps that have disabled subscriptions. There are some clients that disable subscriptions for various reasons, to have a limited functioning DataStore without real-time updates. For these apps, DataStore will continue to reoncile responses from locally sourced mutations so that that data local to the app will be kept up to date with the remote store as much as possible.

General Checklist

  • Added new tests to cover change, if needed
  • Build succeeds with all target using Swift Package Manager
  • All unit tests pass
  • All integration tests pass
  • Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc)
  • Documentation update for the change if required
  • PR title conforms to conventional commit style
  • New or updated tests include Given When Then inline code documentation and are named accordingly testThing_condition_expectation()
  • If breaking change, documentation/changelog update with migration instructions

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

@lawmicha lawmicha force-pushed the fix.reconcile-on-conflicts branch from 9361448 to 4dc530f Compare November 20, 2023 14:29
@lawmicha lawmicha marked this pull request as ready for review November 20, 2023 14:32
@lawmicha lawmicha requested a review from a team as a code owner November 20, 2023 14:32
}

finish(result: .success(nil))
Copy link
Member

Choose a reason for hiding this comment

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

Just making sure this is expected behaviour.. Even if there is an underlying error, it will still finish with a success?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes success and failure here is fairly loose contract between the OutgoingMutationQueue and this operation. I believe even if it's marked as a failure, OutgoingMutationQueue will continue to move on to the next mutation event in the queue (by deleting the mutation event and picking up the next). The important logic in this operation before it finishes is that it's handling the errors. When DataStore can no longer take action on the error, it will call the errorHandler (see line 315 and 320) to inform the client that the error has occurred, before we remove the mutation event.

@lawmicha lawmicha merged commit c72184e into main Nov 20, 2023
@lawmicha lawmicha deleted the fix.reconcile-on-conflicts branch November 20, 2023 19:44
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