error-handling tip

Chris Muller chris at funkyobjects.org
Wed Aug 16 22:47:27 UTC 2006


I just wanted to post about a tricky situation that can occur related
to errors inside of a commit block.  This recently fooled Brent and I
where we thought changes weren't being reflected in other sessions, and
I think it even got Göran once in the past.

Its very easy, in our minds, to extend the atomicity concept of the
commit block to its actual mechanics.  This is not the case.  The
following:

  mySession commit: [ "..make some changes to the model.." ]

this is exactly the same as:

  mySession begin.
  "..make some changes to the model.."
  mySession commit

So if "..make some changes to the model.." causes a debugger, it's
normal to think "the commit didn't work, I'm back to exactly where I
was, nothing is changed."  But this is only true with respect to the
persistent model.  The state of the session *is* changed, the
transaction has already been started, and its still started.  Therefore
the next time commit:[ "..fixed make some changes to the model.." ] is
run, you have a transaction inside the original transaction, so nothing
actually gets written.  Sneaky!

Since this has occurred several times I thought it worth mentioning as
a tip to watch out for.

Cheers,
  Chris



More information about the Magma mailing list