On Friday of last week we were doing our first code review (well, my first code review at this job). A fun 2600 line package, 42 pages.
As were going through one piece, there's an exception block, with an explicit ROLLBACK, some logging code, and then a COMMIT. Of course the logging code should be an autonomous transactions, but apparently it's a bit sketchy.
Anyway, I blather on about not needing an explicit ROLLBACK after the exception as everything is rolled back prior...
"no it's not."
Me: "Yes it is."
"No, it's not."
Me: "Yes, it is."
We then moved on. I go back to my desk to write up a quick test proving my point.
Of course I was wrong though. If you have thing one and thing two and the exception occurs on thing two, the data/record/whatever for thing one exists. And, if you are going to issue a COMMIT and you don't want that orphaned record out there, you must issue an explicit ROLLBACK.
I sent a note out to everyone saying that my colleague is right, but I was still irked by it somehow.
It just didn't feel right.
So I left for lunch for a bit, still thinking about if of course.
Wait, I was saying one thing but thinking about something else. I was thinking of a logical transaction. Thing two depends on thing one therefore you would never, ever want to COMMIT after the exception. The logging code through me off for some reason.
I of course had to send out another email explaining my thought process and my mistake, in essence making me seem the hard loser. Why do I have to do that? Just let it lie...
Oh well, I've done it before and I'll probably do it again. Thankfully I work with some good people so they won't hold it over my head for too long...