amplify-category-api icon indicating copy to clipboard operation
amplify-category-api copied to clipboard

DeltaSyncWriteError on trying to update a Dynamodb row through appsync

Open DevTGhosh opened this issue 2 years ago • 3 comments

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v16.20.1

Amplify CLI Version

11.0.3

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

None

Describe the bug

When attempting to update a specific DynamoDB row using GraphQL, I encounter a DeltaSyncWriteError with the message Failed to write delta sync record. On investigating, I found that the value is successfully updated in the backend. However, the API call still fails, resulting in the mentioned error. This discrepancy suggests an issue in the synchronization process or with the API response handling.

As far as I can see issue only exists on 1 particular row. The rest are fine. I can't think of anything that might have caused the issue. I can't recreate this issue either in any other env.

Its major blocker for an important client of ours any help will be greatly appreciated.

Expected behavior

API call to succeed and get me the updated values from graphql

Reproduction steps

  1. Create a graphql table.
  2. Create a row through graphql for that table .
  3. Update that row using graphql.

Project Identifier

8b6503fea4d84d8ae7c9b34e7f619040

Log output

# Put your logs below this line

// Graphql Payload 

{
  "query": "mutation UpdateCompany($input: UpdateCompanyInput!, $condition: ModelCompanyConditionInput) {   
	// Table  keys
    createdAt\n    updatedAt\n    _version\n    _deleted\n    _lastChangedAt\n  }\n}\n",
  "variables": {
    "input": {
      "phone": "t",
      "id":  "primary key",
      "_version": 1343
    }
  }
}


//Graphql response

{
    "data": {
        "updateCompany": null
    },
    "errors": [
        {
            "path": [
                "updateCompany"
            ],
            "data": { 
            // updated data is being shown here
            },
            "errorType": "DeltaSyncWriteError",
            "errorInfo": null,
            "locations": [
                {
                    "line": 2,
                    "column": 3,
                    "sourceName": null
                }
            ],
            "message": "Failed to write delta sync record."
        }
    ]
}

Additional information

No response

Before submitting, please confirm:

  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

DevTGhosh avatar Nov 10 '23 18:11 DevTGhosh

If you're here from Google trying to solve this, you might have created the app with an old version of Amplify. Check the AmplifyDataStore table on DynamoDB, and make sure that the PartitionKey and SortKey are both "ds_pk" and "ds_sk" respectively.

Screenshot 2023-11-14 at 9 42 34 pm

For some reason, on my version it was set to "pk" and "sk" even though it was created by the CLI. Manually deleting and then recreating the table resolved the issue for me.

darylteo avatar Nov 14 '23 13:11 darylteo

Hey @DevTGhosh, Can you confirm if the suggestion above resolved your problem?

AnilMaktala avatar Jan 04 '24 18:01 AnilMaktala

@AnilMaktala nope issue is still there.

DevTGhosh avatar Jan 15 '24 12:01 DevTGhosh

I had the same awkward weird issue until I turned off this:

image

I'm new to AWS and still learning...

Mohdx avatar Jun 12 '24 02:06 Mohdx

@DevTGhosh Please let me know if this works for you and someone explain why?

Mohdx avatar Jun 12 '24 02:06 Mohdx