Andres Freund <and...@anarazel.de> writes: > I'd still like to know which problem we're actually trying to solve > here. I don't understand the "error" issues you mentioned upthread.
If you error out of getting the inner spinlock, the outer spinlock is stuck, permanently, because there is no mechanism for spinlock release during transaction abort. Admittedly it's not very likely for the inner acquisition to fail, but it's possible. Aside from timeout scenarios (e.g., process holding lock gets swapped out to Timbuktu), it could be that both spinlocks are mapped onto a single implementation lock by spin.c, which notes * We map all spinlocks onto a set of NUM_SPINLOCK_SEMAPHORES semaphores. * It's okay to map multiple spinlocks onto one semaphore because no process * should ever hold more than one at a time. You've falsified that argument ... and no, I don't want to upgrade the spinlock infrastructure enough to make this OK. We shouldn't ever be holding spinlocks long enough, or doing anything complicated enough inside them, for such an upgrade to have merit. regards, tom lane