Re: Where Can I Find The Code Segment For WAL Control? - Mailing list pgsql-hackers

From Csaba Nagy
Subject Re: Where Can I Find The Code Segment For WAL Control?
Date
Msg-id 1141987193.11827.38.camel@coppola.muc.ecircle.de
Whole thread Raw
In response to Re: Where Can I Find The Code Segment For WAL Control?  (王宝兵 <wangbaobing@gmail.com>)
List pgsql-hackers
Charlie,

I'm currently working on a similar solution (it's true I'm only in the
thinking phase). I don't have too much time to spend on it (~few hours
per week, on the train during commuting), so it's not progressing too
fast...

Nevertheless, I would like to do a first proof-of-concept version in a
contrib module with minimal coding involved. I don't have time right now
to explain all the details how I would like to do it, but in essence I
want to:
- create a few functions which expose the WAL files and the data base
files as streams;
- use the archive_command framework to control when the WAL files can
be recycled, in combination with a WAL subscription system to make sure
the standby won't be missing WAL files (with safeguards so the primary
system will not go out of WAL file system space if the standby can't
keep up with the WAL stream);
- create a standby manager program which only needs to know how to
access the primary server in order to create the standby (by connecting
to it through normal data base connections and using the above mentioned
functions to stream the files);

These are just the main ideas, the devil is in the details.

As per answering your question, a possible starting point would be to
take a look at:

src/backend/postmaster/pg_arch.c

This one deals with archiving WAL files, so it could give you some
insight in how you can deal with the WAL files.

Or just search the source tree for 'WAL' ... I guess there's quite a few
places in the code where WAL is involved.

Next week I'll post more detailed design (some charts I did to better
understand the idea, and some more text to add details), if anybody is
interested in co-working on it, otherwise I'll just keep working in my
own pace until it gets done...

Cheers,
Csaba.


On Fri, 2006-03-10 at 07:34, 王宝兵 wrote:
>
> I am now trying to develop the PG to support real-time backup.My
> architecture is somehow similar to the "Database Mirroring" technology of
> SQL Server 2005.The server end of the system is consisted of two DB servers
> one is the Principal server,the other is the Mirror server.whenever the
> Principal flushes its log buffer to the local log file,it must send the
> content of its buffer to the Mirror simultaneously.After the mirror receives
> the buffer,it write to its own log file and send a response message to the
> Principal,then the Mirror redo/undo its log.By this way, we can guarantee
> the database instances of the two servers identical.
>
> But now I encounter a problem.I don't know where the functions to control
> log buffer are.Which code segment may I refer to?
>
> I have just participated the PG project for a short time,and I will
> appreciate your help very much!
>
> Look forward to you all!
>
>
>
> Charlie Wang
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster



pgsql-hackers by date:

Previous
From: Bernd Helmle
Date:
Subject: Re: Updateable views was:(Re: [HACKERS] Proposal for
Next
From: Matteo Beccati
Date:
Subject: Re: Enhanced containment selectivity function