Transactions in Dgraph

Is there any support for adding transactions to Dgraph?

I see the use cases as:

  • financial transactions
  • adding unique indexes (useful for user auth providers)
  • allocating stock to an order / decrementing stock levels
  • time scheduling
  • preventing inconsistent data

You could add this by applying conditions that need to pass before applying a mutation - i.e. only apply a mutation if the following assertions are met.

mutation {
  transaction {
    actor (func: allofterms(name@en, "jones indiana")) {
      @assert(count(), 0)
    }
  }
  set {
    _:a <name> “Indiana Jones” .
  }
}

To do transactions, we’ll have to do distributed transactions, given the fact that Dgraph is a distributed system. And doing distributed txns is a hard problem, that we don’t want to solve at the moment.

For most applications, atomic consistency and durability, that we provide should be sufficient. Dgraph won’t be suited for financial transactions, that’s true.

To anyone reading this old thread, Dgraph will have transactions starting in v0.9 per the Dgraph team:

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.