Обсуждение: pgsql: Fix two race conditions between the pending unlink mechanism that

Поиск
Список
Период
Сортировка

pgsql: Fix two race conditions between the pending unlink mechanism that

От
heikki@postgresql.org (Heikki Linnakangas)
Дата:
Log Message:
-----------
Fix two race conditions between the pending unlink mechanism that was put in
place to prevent reusing relation OIDs before next checkpoint, and DROP
DATABASE. First, if a database was dropped, bgwriter would still try to unlink
the files that the rmtree() call by the DROP DATABASE command has already
deleted, or is just about to delete. Second, if a database is dropped, and
another database is created with the same OID, bgwriter would in the worst
case delete a relation in the new database that happened to get the same OID
as a dropped relation in the old database.

To fix these race conditions:
- make rmtree() ignore ENOENT errors. This fixes the 1st race condition.
- make ForgetDatabaseFsyncRequests forget unlink requests as well.
- force checkpoint on in dropdb on all platforms

Since ForgetDatabaseFsyncRequests() is asynchronous, the 2nd change isn't
enough on its own to fix the problem of dropping and creating a database with
same OID, but forcing a checkpoint on DROP DATABASE makes it sufficient.

Per Tom Lane's bug report and proposal. Backpatch to 8.3.

Modified Files:
--------------
    pgsql/src/backend/commands:
        dbcommands.c (r1.206 -> r1.207)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/dbcommands.c?r1=1.206&r2=1.207)
    pgsql/src/backend/storage/smgr:
        md.c (r1.136 -> r1.137)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/smgr/md.c?r1=1.136&r2=1.137)
    pgsql/src/port:
        dirmod.c (r1.53 -> r1.54)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/port/dirmod.c?r1=1.53&r2=1.54)