From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Streaming replication and non-blocking I/O |
Date: | 2009-12-18 02:42:19 |
Message-ID: | 3f0b79eb0912171842l76eda1bdj703a933fccbacd24@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, Dec 17, 2009 at 10:25 PM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> Fujii Masao wrote:
>> I'm thinking of making the standby send the "walsender-switch-code" the same way
>> as application_name; walreceiver always specifies the option like
>> "replication=on"
>> in conninfo string and calls PQconnectdb(), which sends the code as a part of
>> startup packet. And, the environment variable for that should not be defined to
>> avoid user's mis-configuration, I think.
>
> Sounds good.
Okey. Design clarification again;
0. Begin by connecting to the master using PQconnectdb() with new conninfo
option specifying the request of replication. The startup packet with the
request is sent to the master, then the backend switches to the walsender
mode. The walsender goes into the main loop and wait for the request from
the walreceiver.
1. Get the system identifier of the master.
Slave -> Master: Query message, with a query string like
"GET_SYSTEM_IDENTIFIER"
Master -> Slave: RowDescription, DataRow CommandComplete, and
ReadyForQuery messages. The system identifier is returned in the DataRow
message.
2. Another query exchange like above, for timeline ID.
Slave -> Master: Query message, with a query string like
"GET_TIMELINE"
Master -> Slave: RowDescription, DataRow CommandComplete, and
ReadyForQuery messages. The timeline ID is returned in the DataRow
message.
3. Request a backup history file, if needed:
Slave -> Master: Query message, with a query string like
"GET_BACKUP_HISTORY_FILE XXX" where XXX is XLogRecPtr.
Master -> Slave: RowDescription, DataRow CommandComplete and
ReadyForQuery messages as usual. The file contents are returned in the
DataRow message.
In 1, 2, 3, the walreceiver uses PQexec() to send Query message and receive
the results.
4. Start replication
Slave -> Master: Query message, with query string "START REPLICATION:
XXXX", where XXXX is the RecPtr of the starting point.
Master -> Slave: CopyOutResponse followed by a continuous stream of
CopyData messages with WAL contents.
Regards,
--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2009-12-18 03:09:31 | Re: [PATCH] remove redundant ownership checks |
Previous Message | Robert Haas | 2009-12-18 02:28:10 | Re: [PATCH] remove redundant ownership checks |