Alvaro Herrera <[EMAIL PROTECTED]> writes:
> I'm cooking a patch for this which seems pretty reasonable, but I'm
> having a problem: what mechanism do we have for waiting until a process
> exits?

None, and I think you probably don't want to sit on the database lock
while waiting, either.  I was envisioning a simple sleep loop, viz

        for(;;)
        {
                acquire database lock;
                foreach(PGPROC entry in that database)
                {
                        if (it's autovac)
                                send sigint;
                        else
                                fail;
                }
                if (found any autovacs)
                {
                        release database lock;
                        sleep(100ms or so);
                        /* loop back and try again */
                }
                else
                        break;
        }

Also see Peter's nearby suggestion that we ought to wait instead of fail
for *all* cases of somebody attached to the database.  This would adapt
readily enough to that.

I was complaining elsewhere that I didn't want to use a sleep loop
for fixing the fsync-synchronization issue, but CREATE/DROP DATABASE
seems a much heavier-weight operation, so I don't feel that a sleep
is inappropriate here.

> Maybe make autovacuum acquire an LWLock at start, which it then
> keeps until it's gone, but it seems wasteful to have a lwlock just for
> that purpose.

And it doesn't scale to multiple autovacs anyway, much less the wait-for-
everybody variant.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to