Re: Forcing wal rotation

From: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Postgresql-General <pgsql-hackers(at)postgresql(dot)org>, "A(dot)M(dot)" <agentm(at)themactionfaction(dot)com>
Subject: Re: Forcing wal rotation
Date: 2006-07-14 15:57:50
Message-ID: 44B7BEFE.6090406@phlo.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout wrote:
> On Fri, Jul 14, 2006 at 05:36:58PM +0200, Florian G. Pflug wrote:
>> That was the idea - providing pg_rotate_wal(), which would guarantee that
>> the wal is rotatted at least once if called. Thinking further about this,
>> for a first prove of concept, I'd be enough to write a C function
>> pg_current_walsegment(). pg_rotate_wal() could then be a plpgsql function,
>> that e.g. creates a temporary table, and fills it with data, until the
>> return value of pg_current_walsegment() changes.
>
> Temporary tables don't get xlogged. It would probably be easier to hook
> into the xlog machinery and create NOP records, like you originally
> suggested.

From further sourcecode reading, I got the following implementation plan
.) Add new entry to RmgrTable (Should I add it at the end, or use one of the "reserved" entries?)
.) Create nop_redo and nop_desc - for nop_redo an empty function should be sufficient
.) Create pg_rotate_wal, which calls
XLogInsert(RM_NOP_ID, XLOG_NO_TRAN, rdata)
with
rdata.data = "pointer to WAL_SEGMENT_SIZE zero bytes"
rdata.len = WAL_SEGMENT_SIZE
rdata.buffer = InvalidBuffer
rdata.next = NULL

Since I insert WAL_SIZE bytes, I shouldn't even have to loop, because that records
has no chance to fit into the current wal segment, right?

Am I overlooking something?

greetings, Florian Pflug

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-07-14 16:01:15 Re: contrib promotion?
Previous Message Martijn van Oosterhout 2006-07-14 15:45:41 Re: Forcing wal rotation