Andrew Dunstan <andrew@dunslane.net> writes:
> Tom Lane wrote:
>> One relatively low-impact workaround would be to force a checkpoint
>> (on Windows only) during DROP DATABASE, just before we actually fire
>> the rmtree() operation. The bgwriter is already coded to close all its
>> open files after a checkpoint ...
> Works for me. If someone gives me a patch I'll be happy to test it.
Try putting "RequestCheckpoint(true)" in dbcommands.c just before
remove_dbtablespaces (about line 630).
It looks like the bgwriter is not quite up-to-speed for this, either;
you should rearrange things near line 350 of bgwriter.c so that
smgrcloseall is performed before marking the checkpoint done in shmem.
Else RequestCheckpoint could come back before the files are all closed.
> I did wonder if there should be a call that instead of forcing a flush
> could tell bgwriter just to forget about the file(s) because we're
> discarding them. But that was just idle speculation - I haven't looked
> at bgwriter at all.
Not necessary, as long as you put the checkpoint after the DropBuffers
call in dbcommands.c. The bgwriter won't find anything to write.
regards, tom lane