When we are using Database.insert() or Database.update() with a false option(In any service) then it returns a success or failure result. We know in the insert if any lines fail, delete the header and sibling line which is OK, but in case of an update we want to restore the previous state (not to delete).
we need a solution to rollback partially. Salesforce does not provide it natively. What it provides is entire rollback using Savepoints. But it does provides partial commits using allOrNone = true/false.
So we want to develop a solution that commits partially using Database.insert/update (allOrNone as false). And then we put a savepoint before firing this DML, and then we rollback to this Savepoint without loosing the successfully committed data. We just want to rollback the bad records chain that could not go through. We are OK with insert even without a proper solution (we can just delete them). But updates and deletes are pain point. Deletes can not be undeleted so easily (triggers, and the entire system is not very supportive of undelete). Same with updates. We don't know what target state to rollback if we have to do it manually. Solution approach we thought of- We set savepoint. -> fire DML -> fail and rollback -> filter out the records that caused errors and reattempt the DML with happy records. But this approach will actually breakdown. See, error happens in least scenarios. So if we are reverting bulk transaction for a few handful errors, and then retrying it then it increases the limits by 3X (X original + X rollback + X retry) depending on where we got the error and at what point of flow in the entire transaction, we plan to rollback (we may want to accumulate error until a break point beyond which we think we can not handle things)