question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delete or Create key fails: Attempting to mutate more than 1 global secondary index at the same time

See original GitHub issue

Describe the bug

When attempting to delete a single key (no other changes) I get:

Attempting to mutate more than 1 global secondary index at the same time on the FooTable table in the Foo stack. 
An error occurred during the push operation: Attempting to mutate more than 1 global secondary index at the same time on the FooTable table in the Foo stack. 

Amplify CLI Version

4.29.2

To Reproduce

  1. Have a schema that has already been pushed with an example @key
  2. Try to delete the @key
  3. amplify push fails

Expected behavior

@key should be deleted

Additional context

Example schema:

type Foo
  @model
  @key(name: "FooStatusUpdatedAt", fields: ["status", "updatedAt"], queryField: "fooStatusUpdatedAt")
  @searchable
{
  updatedAt: AWSDateTime,
  status: PublicationStatus,
  ...
}

enum PublicationStatus {
  draft
}

Note: I downgraded to @aws-amplify/cli@4.27.3 and was able to perform the amplify push without issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:39 (10 by maintainers)

github_iconTop GitHub Comments

7reactions
malcommcommented, Nov 7, 2020

Any updates on this?

7reactions
dsypniewskicommented, Oct 1, 2020

I have the same problem, and I just found out that the order of the @key directives seems to matter. Going from this:

type Foo
  @model
  @key(name: "FooSubjectId", fields: ["fooSubjectId"], queryField: "fooSubjectId")

to this:

type Foo
  @model
  @key(name: "FooByUpdatedAt", fields: ["searchIndex", "updatedAt"], queryField: "fooByUpdatedAt")
  @key(name: "FooSubjectId", fields: ["fooSubjectId"], queryField: "fooSubjectId")

results in abovementioned error, but instead doing:

type Foo
  @model
  @key(name: "FooSubjectId", fields: ["fooSubjectId"], queryField: "fooSubjectId")
  @key(name: "FooByUpdatedAt", fields: ["searchIndex", "updatedAt"], queryField: "fooByUpdatedAt")

seems to work. My guess is that the diffing in the first case creates something like this:

DELETE FooSubjectId
CREATE FooByUpdatedAt
CREATE FooSubjectId

instead of this:

CREATE FooByUpdatedAt
Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing Global Secondary Indexes - Amazon DynamoDB
Create, modify, and delete global secondary indexes online in Amazon DynamoDB. ... You must specify one attribute to act as the index partition...
Read more >
AWS Amplify create Global Secondary Index after DynamoDB ...
An error occured during the push operation: Attempting to add a local secondary index to the table1Table table in the table1 stack. Local...
Read more >
API (GraphQL) - Troubleshooting - AWS Amplify Docs
Attempting to mutate more than 1 global secondary index at the same time. If you're running into the error above during amplify push...
Read more >
Cannot perform more than one GSI creation or deletion in a ...
Problem. This error occurs when you try to: create a DynamoDB table with more than one Global Secondary Index (GSI); or; add or...
Read more >
GSI (Global Secondary Index) errors with Amplify push
DynamoDB cannot update, modify, create, or delete more than on GSI (Global Secondary Index) at a time on a particular table.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found