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

Creating / deleting multiple indexes in firestore in datastore modes may lead to: Error 409: Aborted due to cross-transaction contention #16599

Closed
raz-amir opened this issue Nov 23, 2023 · 1 comment · Fixed by GoogleCloudPlatform/magic-modules#9515, hashicorp/terraform-provider-google-beta#6677 or #16618
Assignees

Comments

@raz-amir
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform: 1.6.4
Google provider: 5.7.0

Affected Resource(s)

  • google_firestore_index

Terraform Configuration Files

resource "google_firestore_index" "index_create71" {
  api_scope  = "DATASTORE_MODE_API"
  collection = "mycollection2"
  database   = "database22"


  query_scope = "COLLECTION_RECURSIVE"

  fields {
    field_path = "field1"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field2"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field4"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field5"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field8"
    order      = "ASCENDING"
  }
}

resource "google_firestore_index" "index_create72" {
  api_scope  = "DATASTORE_MODE_API"
  collection = "mycollection2"
  database   = "database22"


  query_scope = "COLLECTION_RECURSIVE"

  fields {
    field_path = "field1"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field2"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field4"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field5"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field8"
    order      = "DESCENDING"
  }
}

resource "google_firestore_index" "index_create73" {
  api_scope  = "DATASTORE_MODE_API"
  collection = "mycollection2"
  database   = "database22"


  query_scope = "COLLECTION_RECURSIVE"

  fields {
    field_path = "field1"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field2"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field4"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field5"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
}

resource "google_firestore_index" "index_create74" {
  api_scope  = "DATASTORE_MODE_API"
  collection = "mycollection2"
  database   = "database22"


  query_scope = "COLLECTION_RECURSIVE"

  fields {
    field_path = "field1"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field2"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field4"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field5"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "DESCENDING"
  }
}

resource "google_firestore_index" "index_create75" {
  api_scope  = "DATASTORE_MODE_API"
  collection = "mycollection2"
  database   = "database22"


  query_scope = "COLLECTION_RECURSIVE"

  fields {
    field_path = "field1"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field2"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field4"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field5"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field6"
    order      = "DESCENDING"
  }
}

resource "google_firestore_index" "index_create76" {
  api_scope  = "DATASTORE_MODE_API"
  collection = "mycollection2"
  database   = "database22"


  query_scope = "COLLECTION_RECURSIVE"

  fields {
    field_path = "field1"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field2"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field4"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field5"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field6"
    order      = "ASCENDING"
  }
}

resource "google_firestore_index" "index_create77" {
  api_scope  = "DATASTORE_MODE_API"
  collection = "mycollection2"
  database   = "database22"


  query_scope = "COLLECTION_RECURSIVE"

  fields {
    field_path = "field1"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field2"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field4"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field5"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field7"
    order      = "ASCENDING"
  }
}

resource "google_firestore_index" "index_create78" {
  api_scope  = "DATASTORE_MODE_API"
  collection = "mycollection2"
  database   = "database22"


  query_scope = "COLLECTION_RECURSIVE"

  fields {
    field_path = "field1"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field2"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field3"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field4"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field5"
    order      = "ASCENDING"
  }
  fields {
    field_path = "field7"
    order      = "DESCENDING"
  }
}

Debug Output

https://gist.github.com/ramir-savvy/622c116aae0ef6de01bb9b7356b1839a

Panic Output

Expected Behavior

All indexes should be created

Actual Behavior

Some indexes are created, the others are giving this error:

Error: Error creating Index: googleapi: Error 409: Aborted due to cross-transaction contention. This occurs when multiple transactions attempt to access the same data, requiring Firestore to abort at least one in order to enforce serializability.

It seems like the provider should retry on this error too.

Steps to Reproduce

Run terraform apply.

Important Factoids

References

  • #0000
@raz-amir raz-amir added the bug label Nov 23, 2023
@github-actions github-actions bot added forward/review In review; remove label to forward service/firestore-dataplane labels Nov 23, 2023
@raz-amir raz-amir changed the title Creating multiple indexes in firestore in datastore modes may lead to: Error 409: Aborted due to cross-transaction contention Creating / deleting multiple indexes in firestore in datastore modes may lead to: Error 409: Aborted due to cross-transaction contention Nov 23, 2023
@edwardmedia edwardmedia added forward/exempt Never forward this issue and removed forward/review In review; remove label to forward labels Nov 24, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.