-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
DataStore update queue order not respected #8012
Comments
I was able to reproduce this issue with https://www.npmjs.com/package/aws-amplify/v/3.3.27-unstable.19 specifically with the code you have here, where We'll need to explore this a bit more. Could you please elaborate on this use case so we can better understand it? Normally, I wouldn't expect to send the input with each stroke but would be debouncing or going off of another event altogether before sending the network request. |
We could try debouncing or using an event such as changing screens to save, however our users can often see 2-3s or upwards of latency. The concern is then that a user will modify a record within the few seconds it takes for the network request to complete. This would update the local store temporarily and give the impression that a record was updated without the change actually being persisted. Or if connectivity is lost, we haven't tested this but presumably it would also result in lost data.
Yes only the first typed letter (or backspace) is actually persisted, even though DataStore shows the change as persisted initially (local store presumably), another query after a few seconds reveals only the first request's change to have been effected. |
Adding some latency artificially helps with demonstrating the potential problems, if you happen to be close to the AWS region. I'm quite far from the AWS region we're running against, our users are distributed too, and I'm not aware of a way to reduce latency to accomodate quicker updates. |
I will explore solutions for this use case specifically too, but let me know if debouncing or performing a |
I want to get some more context about your application and usage patterns to see if we can help you come up with a working solution. Will the same |
One record would likely only be modified by one user. There's about ten models linked with keys at the moment, and each has about 5 to 10 fields. We're expecting hundreds of users in the short terms, scaling to thousands after several months. |
Roughly half of those fields would be liable to be updated frequently/quickly. |
@raybotha have you tried changing the conflict resolution strategy to Optimistic Concurrency? I think that will work much better for your use case, especially if you're not expecting multiple users to be updating the same records. You can change the conflict resolution strategy for your entire API or on a per-model basis via the Amplify CLI > amplify update api
? GraphQL
? Walkthrough all configurations
(Select the same auth config that you already have)
? Do you want to configure advanced settings for the GraphQL API?
Yes, I want to make some additional changes.
? Configure additional auth types? No
? Enable conflict detection? **Yes**
? Select the default resolution strategy **Optimistic Concurrency**
? Do you want to override default per model settings? (y/N) I still suggest debouncing changes in your inputs before performing a |
Thanks for the update, using optimistic concurrency does seem to work as desired. It would likely solve the issue for our current use case. We'll add deboucing anyway as a matter of good practice. |
Great! Is it ok to close this issue? |
I think so yes. |
This issue randomly returned and I had to run the CLI command again, it could be related to using the Amplify Admin UI. |
Is the admin UI incompatible with optimistic concurrency? |
@raybotha AdminUI will currently revert your conflict resolution strategy back to Automerge after you perform changes to the data model. The team is aware of this issue and is tracking it internally. We will be modifying the behavior of AdminUI to keep whichever conflict resolution strategy has been configured on that API. As a temporary workaround, you can manually set the conflict resolution back to Optimistic Concurrency via the CLI following a change to the data model in AdminUI. Alternatively, you can update the conflict resolution strategy in the AWS AppSync Console in each mutation resolver. |
Thanks, I thought that's what's happening. Is there an issue or somewhere to keep track of when it's fixed? |
We're tracking it internally at the moment, but I'll make sure to circle back around and post an update here once we've fixed it |
@iartemiev Hey, any news or public issue yet for this Admin UI issue? |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
DataStore
Amplify Categories
api
Environment information
Describe the bug
The queue for updates consistently doesn't seem to work, updates to a record seem to be disregarded completely if a previous update/save is being synced to the server.
Example is of updating a record on text field change (on each change query by ID and save).
Expected behavior
With a single network-connected client there should be no conflicts between server and client store. The latest update to a record should take priority and not be discarded or overwritten by previous updates, especially not from the same client.
Reproduction steps
Update a record rapidly and query the results as in code snippet.
Code Snippet
Log output
The text was updated successfully, but these errors were encountered: