Too much memory allocated for ReorderBufferDiskChange

From: Antonin Houska <ah(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Too much memory allocated for ReorderBufferDiskChange
Date: 2018-03-05 15:26:23
Message-ID: 5778.1520263583@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2018-03-05 15:38:40 planner failure with ProjectSet + aggregation + parallel query
Previous Message David Steele 2018-03-05 15:25:54 Re: Re: BUGFIX: standby disconnect can corrupt serialized reorder buffers