bug in clusto's transaction handling

6 views
Skip to first unread message

Lex Linden

unread,
Jun 29, 2011, 4:36:41 PM6/29/11
to clusto
I came across a sneaky little bug in clusto's transaction functions,
triggered by a bug in my code. It looked like this:

TransactionException: Negative transaction counter! SHOULD NEVER HAPPEN!

It shouldn't, but it did :)

Here's how to trigger the bug:

1. Start a transaction with clusto.begin_transaction()
2. Do stuff.
3. Commit the transaction: clusto.commit()
4. Try to roll it back: clusto.rollback_transaction() (no exception thrown)
5. Now try to start a new transaction: clusto.begin_transaction()

You'll get the above error. The problem is that rollback_transaction()
doesn't handle the case that the transaction counter exists but it's at
0, which is what happens after the first transaction is committed. It
merrily decrements the transaction counter to -1, and all hell breaks loose.

I'm busy trying to fix the code that caused me to find this bug in the
first place, but I just wanted to get this out there now before I forget
about it. Sometime soon, I'll fix this bug and send the fix along.

Ron

unread,
Jul 6, 2011, 2:41:05 AM7/6/11
to clusto
I've got a fix for this. Basically, it'll raise the exception at step
#4. I'll push it soon.
Reply all
Reply to author
Forward
0 new messages