Error: 10 ABORTED: Too much contention on these documents. Please try again

前端 未结 6 790
臣服心动
臣服心动 2020-12-10 16:24

What does this error mean?

Especially, what do they mean by : Please try again

Does it mean that the transaction failed I have to re-run the

6条回答
  •  攒了一身酷
    2020-12-10 16:59

    Firestore now supports server-side increment() and decrement() atomic operations.

    You can increment or decrement by any amount. See their blog post for full details. In many cases, this will remove the need for a client side transaction.

    Example:

    document("fitness_teams/Team_1").
      updateData(["step_counter" : FieldValue.increment(500)])
    

    This is still limited to a sustained write limit of 1 QPS per document so if you need higher throughput, consider using distributed counters. This will increase your read cost (as you'll need to read all the shard documents and compute a total) but allow you to scale your throughput by increasing the number of shards. Now, if you do need to increment a counter as part of a transaction, it's much less likely to fail due to update contention.

提交回复
热议问题