Using dgo v2 clinet to do multiple queries then mutate in same txn cause "Transaction has already been committed or discarded" error

Hi,

I’ve used dgo v1 for following procedure (basically trying to upsert data) and it works fine. When I upgrade to v2 (for dgraph 1.1.0 server) it gives me “Transaction has already been committed or discarded” error. Anyone knows what cause it? Thank you!

ctx := context.Background()
txn := this._dgraphClient.NewTxn()
defer txn.Discard(ctx)

txn.QueryWithVars(…)

txn.QueryWithVars(…)



_, err := txn.Mutate(
ctx,
&api.Mutation{
SetNquads: byte(Nquads.String()),
},
)

if nil != err {
return err … Error was thrown here
}

Hi Steven,

Thank you for your question. I will have one of our engineers take a look at it and get back to you soon.

Shekar

Can you share a complete code example? It’s not clear why the error is happening. If this is the only client code that’s running, then either txn.Commit(ctx) or txn.Discard(ctx) were called by the client.

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