Too much memory allocated for ReorderBufferDiskChange - Mailing list pgsql-hackers

From Antonin Houska
Subject Too much memory allocated for ReorderBufferDiskChange
Date
Msg-id 5778.1520263583@localhost
Whole thread Raw
Responses Re: Too much memory allocated for ReorderBufferDiskChange
List pgsql-hackers
I suggest the following change to avoid excessive
allocation. sizeof(ReorderBufferDiskChange) should already be contained in
ondisk->size.

diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
new file mode 100644
index c72a611..84f6e05
*** a/src/backend/replication/logical/reorderbuffer.c
--- b/src/backend/replication/logical/reorderbuffer.c
*************** ReorderBufferRestoreChanges(ReorderBuffe
*** 2366,2373 ****

          ondisk = (ReorderBufferDiskChange *) rb->outbuf;

!         ReorderBufferSerializeReserve(rb,
!                                       sizeof(ReorderBufferDiskChange) + ondisk->size);
          ondisk = (ReorderBufferDiskChange *) rb->outbuf;

          pgstat_report_wait_start(WAIT_EVENT_REORDER_BUFFER_READ);
--- 2366,2372 ----

          ondisk = (ReorderBufferDiskChange *) rb->outbuf;

!         ReorderBufferSerializeReserve(rb, ondisk->size);
          ondisk = (ReorderBufferDiskChange *) rb->outbuf;

          pgstat_report_wait_start(WAIT_EVENT_REORDER_BUFFER_READ);

--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com


pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: Re: BUGFIX: standby disconnect can corrupt serialized reorderbuffers
Next
From: Robert Haas
Date:
Subject: planner failure with ProjectSet + aggregation + parallel query