Aborted transaction examples?

We’re using the dgraph-js-http client to communicate with Dgraph, and I’m interested in understanding how best to handle aborted transactions. The documentation for committing a transaction says:

An error will be returned if other transactions running concurrently modify the same data that was modified in this transaction.

That’s a pretty broad statement, and maybe I haven’t put enough thought into this, but can anyone give me a simple yet concrete example of how to force two concurrent transactions to modify the same data? I want to make sure we’re handling this in our app, ideally where I force it to happen in my integration tests.

There was an example video somewhere in the docs I remember where a member of the team forced a transaction abort.

Basically:

  1. Use the @upsert directive on a predicate to make it more likely to happen.
  2. start a transaction and update that value on a certain uid, do not commit the transaction yet.
  3. start a different transaction and update that value on the same uid, commit that transaction.
  4. commit original transaction, it should error with an abort.

On mobile atm so can’t find the video of the dgraph devs walking through this.

In general the pattern would be to retry the failed transaction in it’s entirety if it is aborted.