I've inherited some complex logic that does several different DML actions within the same (fairly long) method and if there are failures I need to revert everything that's been previously done. The existing solution involved setting a Database.savepoint at the top of the method, and doing Database.rollback() in the event of failure.
The problem is that while reading through the documentation around these functions, I realized that there's no description of (or ability to define) the scope of the DB snapshot that's taken, and in fact, all available information seems to indicate that it's a global snapshot of the DB. Given that we operate in a multi-tenant environment, this leads me to worry that when you rollback, you would potentially be wiping out unrelated DB changes made by another user during the same window of time.
Well, now I've inherited this tract of code that makes liberal use of the rollback, but with such a sensitive mixture of insert, update, and delete operations going on here, I don't think I have any alternative method of cleanup after failure. So I guess my question is whether anybody out there can confirm or deny this destructive side-effect, preferably with some clear documentation?
PS: I reached out to my Technical Evangelist at the time to confirm this risk, and to my surprise he had never heard anybody bring up such a concern before. Basically, he said that he wasn't certain, but that my concern sounded like a very likely outcome (and in fact the outcome that he would expect, given some thought) and that I should avoid all use of this call.