Robert Haas <robertmh...@gmail.com> writes: > I had what I think is a better idea, which is to introduce a notion of > condition variables.
Interesting proposal. > ... Using condition variables here seems to > have a couple of advantages. First, it means that a backend waiting > for buffer I/O to complete is interruptible. Second, it fixes a > long-running bit of nastiness in AbortBufferIO: right now, if a > backend that is doing buffer I/O aborts, the abort causes it to > release all of its LWLocks, including the buffer I/O lock. Everyone > waiting for that buffer busy-loops until the aborting process gets > around to reacquiring the lock and updating the buffer state in > AbortBufferIO. But if we replace the io_in_progress locks with > condition variables, then that doesn't happen any more. Nobody is > "holding" the condition variable, so it doesn't get "released" when > the process doing I/O aborts. Instead, they just keep sleeping until > the aborting process reaches AbortBufferIO, and then it broadcasts on > the condition variable and wakes everybody up, which seems a good deal > nicer. Hmm. I fear the only reason you see an advantage there is that you don't (yet) have any general-purpose mechanism for an aborting transaction to satisfy its responsibilities vis-a-vis waiters on condition variables. Instead, this wins specifically because you stuck some bespoke logic into AbortBufferIO. OK ... but that sounds like we're going to end up with every single condition variable that ever exists in the system needing to be catered for separately and explicitly during transaction abort cleanup. Which does not sound promising from a reliability standpoint. On the other hand, I don't know what the equivalent rule to "release all LWLocks during abort" might look like for condition variables, so I don't know if it's even possible to avoid that. I encourage you to pursue this, because indeed LWLocks aren't always an ideal solution, but I think it requires some careful thought about what transaction aborts will do with condition variables. regards, tom lane -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers