[pgcluster: 830] PGCluster1.3.0cでのシーケンスの同期について

YANAGIDA, Kentaro k-yanagida @ xml.mapple.com
2005年 10月 27日 (木) 11:59:12 JST


柳田と申します。
いつもお世話になっております。

はじめて投稿させていただきます。
シーケンスの同期についてお聞きしたいことがあります。

<<質問内容>>
下記の環境において、PGReplicateの動作を確認していたところ、
serial型の列を含むテーブルの内容が同期しませんでした。

下記の手順にて動作確認を行っていたのですが、この動きは正しいもの
なのでしょうか。

片方のクラスターDBを復旧モードで起動しなおした場合に、insert文を
実行したら、serial型の列の値が一致することを期待しているのですが、
何か設定や、操作に間違いがありますでしょうか。

過去ログで[pgcluster: 580]シーケンスの整合性が崩れるというメールを
拝見しましたが、今回はPGClusterのバージョンが違うため、質問させて
いただきました。
(もし、既出の内容であれば、すみません)

どなたかアドバイスいただければと思います。
よろしくお願い申し上げます。


以下、動作環境、確認手順、設定ファイルの内容を記述します。

<<動作環境>>
2台のマシンを使って動作の確認をしています。
構成は以下のとおりです。

CentOS4.1(kernel 2.6.9-22.EL)
pgcluster-1.3.0cをインストール済み
詳細な設定内容は、文末に記載します。

レプリケーションサーバ、クラスターDB
host : pgcluster01.grss.local
  ip : 192.168.2.231

クラスターDB
host : pgcluster02.grss.local
  ip : 192.168.2.232

<<動作確認の手順>>
1.各クラスターDBで initdb -E EUC_JP --no-locale を実行
2.レプリケーションサーバを起動 pgreplicate -nvl -D /usr/local/pgsql/data
3.各クラスターDBでpostmaster を起動 pg_ctl start -o "-i"

4.pgcluster01でcreatedbを実行 createdb testdb
->pgcluster02にもtestdbが作成されます
->pgcluster01,pgcluster02ともにpsqlでtestdbへの接続を確認

5.pgcluster01でテーブルを作成 create table taba (id serial, num int4);
->pgcluster02にもtabaが作成されます

6.pgcluster01でinsert文を実行 insert into taba (num) values (1);
->insertする値を1〜5まで変えて実行します
->pgcluster02でも同じ値がinsertされています

7.pgcluster02でも同様にinsert文を実行 insert into taba (num) values (6);
->insertする値を6〜10まで変えて実行します
->pgcluster01でも同じ値がinsertされています

--ここまでは期待していた動作だったのですが、
--pgcluster01のpgreplicateとpostmasterを停止し、pgcluster02でinsert文を
--実行しました。

8.pgcluster01でpostmasterを停止 pg_ctl stop
9.pgcluster01でpgreplicateを停止
->デーモン化していないため、Ctrl-cで停止

10.pgcluster02でinsert文を実行 insert into taba (num) values (11);
->insertする値を11〜15まで変えて実行します
test=# select * from taba;
 id | num
----+-----
  1 |   1
  2 |   2
  3 |   3
  4 |   4
  5 |   5
  6 |   6
  7 |   7
  8 |   8
  9 |   9
 10 |  10
 11 |  11
 12 |  12
 13 |  13
 14 |  14
 15 |  15
(15 rows)

11.pgcluster01でpgreplicateを起動 pgreplicate -nvl -D /usr/local/pgsql/data

12.pgcluster01でクラスターDBを復旧モードで起動 pg_ctl start -o "-i -R"
->特にエラーは出ていません

13.psqlでpgcluster01に接続し、tabaの内容を表示
test=# select * from taba;
 id | num
----+-----
  1 |   1
  2 |   2
  3 |   3
  4 |   4
  5 |   5
  6 |   6
  7 |   7
  8 |   8
  9 |   9
 10 |  10
 11 |  11
 12 |  12
 13 |  13
 14 |  14
 15 |  15
(15 rows)

14.ここで各クラスターDBでtaba.id列に対するシーケンスの内容を比較
->pgcluster01の場合
test=# select sequence_name, last_value, increment_by, log_cnt from
taba_id_seq;
 sequence_name | last_value | increment_by | log_cnt
---------------+------------+--------------+---------
 taba_id_seq   |         45 |            1 |       0
(1 row)

->pgcluster02の場合
test=# select sequence_name, last_value, increment_by, log_cnt from
taba_id_seq;
 sequence_name | last_value | increment_by | log_cnt
---------------+------------+--------------+---------
 taba_id_seq   |         15 |            1 |      30
(1 row)

15.上記でシーケンスのlast_valueの値が各クラスターDBで異なるため、
   この状態でtabaにinsert文を実行すると、tabaのid列の値が一致しません。

16.この後、再度pgcluster01のpostmasterを復旧モードで起動しなおすと、両者
のtaba_id_seqの内容が一致します。
->pgcluster01
test=# select sequence_name, last_value, increment_by, log_cnt from
taba_id_seq;
 sequence_name | last_value | increment_by | log_cnt
---------------+------------+--------------+---------
 taba_id_seq   |         15 |            1 |      30
(1 row)

->pgcluster02
test=# select sequence_name, last_value, increment_by, log_cnt from
taba_id_seq;
 sequence_name | last_value | increment_by | log_cnt
---------------+------------+--------------+---------
 taba_id_seq   |         15 |            1 |      30
(1 row)


<<各種設定ファイル>>
[レプリケーションサーバ、クラスターDB]
host : pgcluster01.grss.local
  ip : 192.168.2.231
--pgreplicate.confの内容--
<Cluster_Server_Info>
    <Host_Name>pgcluster01.grss.local</Host_Name>
    <Port>5432</Port>
    <Recovery_Port>7101</Recovery_Port>
    <LifeCheck_Port>7201</LifeCheck_Port>
</Cluster_Server_Info>
<Cluster_Server_Info>
    <Host_Name>pgcluster02.grss.local</Host_Name>
    <Port>5432</Port>
    <Recovery_Port>7101</Recovery_Port>
    <LifeCheck_Port>7201</LifeCheck_Port>
</Cluster_Server_Info>

<Status_Log_File>/usr/local/pgsql/data/pgreplicate.sts</Status_Log_File>
<Error_Log_File>/usr/local/pgsql/data/pgreplicate.log</Error_Log_File>
<Replication_Port>8001</Replication_Port>
<Recovery_Port>8101</Recovery_Port>
<LifeCheck_Port>8201</LifeCheck_Port>
<RLOG_Port>8301</RLOG_Port>
<Response_Mode>normal</Response_Mode>
<Use_Replication_Log>no</Use_Replication_Log>
<Reserved_Connections>1</Reserved_Connections>

--cluster.confの内容--
<Replicate_Server_Info>
    <Host_Name>pgcluster01.grss.local</Host_Name>
    <Port>8001</Port>
    <Recovery_Port>8101</Recovery_Port>
    <LifeCheck_Port>8201</LifeCheck_Port>
</Replicate_Server_Info>

<Recovery_Port>7101</Recovery_Port>
<LifeCheck_Port>7201</LifeCheck_Port>
<Rsync_Path>/usr/bin/rsync</Rsync_Path>
<Rsync_Option>ssh -1</Rsync_Option>
<When_Stand_Alone>read_write</When_Stand_Alone>
<Status_Log_File>/usr/local/pgsql/data/cluster.sts</Status_Log_File>
<Error_Log_File>/usr/local/pgsql/data/cluster.log</Error_Log_File>

[クラスターDB]
host : pgcluster02.grss.local
  ip : 192.168.2.232

--cluster.confの内容--
<Replicate_Server_Info>
    <Host_Name>pgcluster01.grss.local</Host_Name>
    <Port>8001</Port>
    <Recovery_Port>8101</Recovery_Port>
    <LifeCheck_Port>8201</LifeCheck_Port>
</Replicate_Server_Info>

<Recovery_Port>7101</Recovery_Port>
<LifeCheck_Port>7201</LifeCheck_Port>
<Rsync_Path>/usr/bin/rsync</Rsync_Path>
<Rsync_Option>ssh -1</Rsync_Option>
<When_Stand_Alone>read_write</When_Stand_Alone>
<Status_Log_File>/usr/local/pgsql/data/cluster.sts</Status_Log_File>
<Error_Log_File>/usr/local/pgsql/data/cluster.log</Error_Log_File>


-- 
株式会社昭文社
GRSSプロジェクト
柳田 健太郎 / YANAGIDA Kentaro
k-yanagida @ xml.mapple.com
102-8238 東京都千代田区麹町3-1 2F
TEL:03-3556-5970 FAX:03-3556-5971




pgcluster メーリングリストの案内