|
36 | 36 | *
|
37 | 37 | *
|
38 | 38 | * IDENTIFICATION
|
39 |
| - * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.97 2007/09/2017:56:31 tgl Exp $ |
| 39 | + * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.98 2007/09/2021:43:27 tgl Exp $ |
40 | 40 | *
|
41 | 41 | *-------------------------------------------------------------------------
|
42 | 42 | */
|
@@ -855,8 +855,13 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats)
|
855 | 855 | */
|
856 | 856 | RelationTruncate(onerel,new_rel_pages);
|
857 | 857 |
|
858 |
| -/* Now we're OK to release the lock. */ |
859 |
| -UnlockRelation(onerel,AccessExclusiveLock); |
| 858 | +/* |
| 859 | + * Note: once we have truncated, we *must* keep the exclusive lock |
| 860 | + * until commit. The sinval message that will be sent at commit |
| 861 | + * (as a result of vac_update_relstats()) must be received by other |
| 862 | + * backends, to cause them to reset their rd_targblock values, before |
| 863 | + * they can safely access the table again. |
| 864 | + */ |
860 | 865 |
|
861 | 866 | /*
|
862 | 867 | * Drop free-space info for removed blocks; these must not get entered
|
|