From: Robert Haas Date: Mon, 20 Sep 2021 18:07:01 +0000 (-0400) Subject: can_allocate_segment could end up true on the first pass through the X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=df6ea196eca8030643f0048e072c5f99bf1dda6e;p=users%2Frhaas%2Fpostgres.git can_allocate_segment could end up true on the first pass through the loop, when we don't hold an exclusive lock. fix. --- diff --git a/src/backend/access/conveyor/conveyor.c b/src/backend/access/conveyor/conveyor.c index f4c78e495a..aa56050bf6 100644 --- a/src/backend/access/conveyor/conveyor.c +++ b/src/backend/access/conveyor/conveyor.c @@ -254,7 +254,8 @@ ConveyorBeltGetNewPage(ConveyorBelt *cb, CBPageNo *pageno) * only true if we've verified that the size of the relation on disk * is large enough. */ - can_allocate_segment = (free_segno != CB_INVALID_SEGMENT) + can_allocate_segment = (mode == BUFFER_LOCK_EXCLUSIVE) + && (free_segno != CB_INVALID_SEGMENT) && (free_segno < next_segno || free_segno < possibly_not_on_disk_segno);