From df6ea196eca8030643f0048e072c5f99bf1dda6e Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 20 Sep 2021 14:07:01 -0400 Subject: [PATCH] can_allocate_segment could end up true on the first pass through the loop, when we don't hold an exclusive lock. fix. --- src/backend/access/conveyor/conveyor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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); -- 2.39.5