-
Notifications
You must be signed in to change notification settings - Fork 198
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
Amplify DataStore Not Syncing Deleted Records on iOS #3821
Comments
Hi @rohit3d2003, GraphQL mutations selection set need to match the selection set of the Subscription operation that is established by Swift DataStore or Amplify Studio. The corresponding mutation response as a subscription event on the clients have to be decoded to each respective platform's types. It needs all the fields of the model, the system metadata fields like
The selection set controls the about of data the subscription event is sent with, if not aligned, will cause decoding errors. |
@lawmicha - Both my selection set for the mutation and subscription operations are the same. As mentioned earlier, I tried deleting a transaction from Lambda while the iOS app was running in the Simulator. In this scenario, the iOS app received the delete event and synced properly. However, the issue occurs when a transaction is deleted via Lambda (e.g., overnight when my app isn’t running in the Simulator or on a physical device). The transaction is successfully deleted from DynamoDB, but Amplify Studio -> Content still shows the transaction, and it never syncs with the iOS app. I have baseTableTtl set to 1 on all tables via override, but I’m not sure if this is affecting the sync behavior in this scenario. Below is the requested items Base Table TTL
Schema
GraphQL Delete Mutation Request
|
Hi @rohit3d2003, the app or Amplify Studio will catch up to the changes with the sync query. When you launch the app and start DataStore, are you able to observe that the data that is fetched and reconciled? It should perform Could the baseTTL be affecting the response of the sync query such that the item no longer exists so it doesn't get returned on the query, thus not get reconciled? |
Hi @lawmicha - It’s been three days now, and syncing still hasn’t caught up. As I mentioned earlier, this issue only occurs when the app wasn’t running at the time the record was deleted from DynamoDB, and since the record no longer exists, it doesn’t reconcile. I’ve increased the TTL to 1 day to see if this changes anything. If it does, app developers will need to ensure the correct TTL is set based on how frequently the app is expected to run. If the duration exceeds the TTL, the datastore should be cleared to allow resyncing. |
I believe the TTL defaults set to 30 days and when the item is soft deleted (_deleted = true), sync query will return them during catch up and reconcile the soft deleted items by removing the corresponding item from the local store on the device. If the short TTL is causing the issue, is there a reason to have reduced this from the default? |
It's mostly due to cost. I don't need to store the deleted items so removing them earlier saves the storage cost. Btw, increasing the Ttl to 1 day fixed it. I am thinking of going with default of 30 days now. |
Closing the ticket as the issue seems to be resolved. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
I am experiencing an issue with Amplify DataStore in my iOS app. When I delete a record directly from DynamoDB using a GraphQL API call via Lambda function, the data is successfully deleted from DynamoDB. However, this deletion is not reflected in the iOS app or Amplify Studio -> Content section.
Steps To Reproduce
Expected behavior
The iOS app and Amplify Studio -> Content section should automatically sync and reflect the deletion of the record from DynamoDB.
Amplify Framework Version
2.36
Amplify Categories
API, DataStore
Dependency manager
Swift PM
Swift version
5.10
CLI version
12.12.4
Xcode version
15.4
Relevant log output
No response
Is this a regression?
Yes
Regression additional context
No response
Platforms
iOS
OS Version
17.5
Device
iPhone 15
Specific to simulators
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: