mgo

Any txn.Op with non-existing Id and Assert set returns ErrAborted instead of ErrNotFound

Bug #1403846 reported by Dimiter Naydenov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mgo
Invalid
Undecided
Unassigned

Bug Description

Consider the following txn.Op{
  Id: "not-existing",
  Assert: D{{"life", "alive"}},
  Update: ... # unimportant
}

If you try to run a transaction with this Op, instead of the expected mgo.ErrNotFound, txn.ErrAborted is returned, which is slightly surprising.

Tags: juju-core
Revision history for this message
Dimiter Naydenov (dimitern) wrote :

Related juju-core bug #1403738

Changed in mgo:
status: New → Confirmed
Revision history for this message
Gustavo Niemeyer (niemeyer) wrote :

This behavior is in line with the intended semantics: asserts fail with ErrAborted, always, and the fact a document is not present will not abort a transaction without an assertion. This behavior may be leveraged to implement useful semantics, although I do understand your desire to know exactly how a transaction failed. Unfortunately, there's a trade-off against consistency and simplicity in this case, and I'd rather not make the transaction package any more complex than it already is.

You can easily implement that on your side, though: once a transaction is aborted, just read the document _id to see if it is there. Of course, that might not be the real state of the document when the transaction was attempted, but this will be true either way if you consider the document non-existent (it may have been created since the transaction finished as well, for example).

Changed in mgo:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.