[pgcluster: 655] pgcluster-1.0.8でレプリケーションが崩れる問題について

Masayuki Ookubo ookubo @ kme.co.jp
2005年 1月 20日 (木) 20:23:47 JST


いつもお世話になります。大窪です。
先日から引き続きpgclusterの検証を行なっていますが、
レプリケーションが崩れる事態に遭遇し対応に苦慮しています。
解決方法がありましたらご教授願います。
以下に詳細を記述致します。

[環境]
1.全体構成
  クラスタサーバ×3、レプリケーションサーバ×1
2.各システムの構成
  クラスタ1(マスタ)
   hostname: cl1.postgres.jp
   OS: FreeBSD4.10-STABLE
   CPU: Intel(R) Pentium(R) 4 CPU 2.80GHz (2800.11-MHz 686-class CPU)
   real memory  = 1056899072 (1032128K bytes)
  クラスタ2
   hostname: cl2.postgres.jp
   OS: FreeBSD4.10-STABLE
   CPU: Intel(R) Pentium(R) 4 CPU 2.80GHz (2800.11-MHz 686-class CPU)
   real memory  = 1056899072 (1032128K bytes)
  クラスタ3
   hostname: cl3.postgres.jp
   OS: FreeBSD4.2-RELEASE
   CPU: Pentium III/Pentium III Xeon/Celeron (1365.77-MHz 686-class CPU)
   real memory  = 50331648 (49152K bytes)
   ※これはWin2KをホストマシンとするVMWare上のマシン
  レプリケーション
   クラスタ1のマシンに同居

  検証したpgclusterのバーション
   pgcluster-1.0.8 フルパッケージ版
   pgcluster-1.0.8dフルパッケージ版

3.構成図
                              psqlからaccess           psqlからaccess
                                    |                        |
 ((  Cluster DB 1    ))   ((  Cluster DB 2    ))   ((  Cluster DB 3    ))
 ( hostname:  cl1     )   ( hostname:  cl2     )   ( hostname:  cl3     )
 ( receive port: 5432 )   ( receive port:5432  )   ( receive port:5432  )
 ( recovery port:7779 )   ( recovery port 7779 )   ( recovery port 7779 )
          |                         |                        |
----------+-------------+-----------+------------+-----------+------------
          |
 ((Replication Server))
 ( hostname:  cl1      )
 ( receive port:8777   )
 ( recovery port:7778  )

[問題点]
クラスタのリカバリ起動時に他のクラスタから更新処理が実行されると
レプリケーションが崩れる場合がある。

[問題のあったバーション]
pgcluster-1.0.8
pgcluster-1.0.8d

[検証手順]
1.レプリケーションサーバを起動
%/usr/local/pgsql/bin/pgreplicate -D /usr/local/pgsql/etc -n -v

2.クラスタ1(マスタ)を起動
%/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -o "-i"

3.クラスタ2を起動
%/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -o "-i"

4.クラスタ2でpgqlを起動し更新処理の準備
%psql testdb1
Welcome to psql 7.3.8, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help on internal slash commands
       \g or terminate with semicolon to execute query
       \q to quit

testdb1=#

5.クラスタ3をリカバリモードで起動
%/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -o "-i -R"

6.クラスタ3の画面に次のメーセージが出始めた瞬間に
OK!  The data synchronization with Master DB was finished.
LOG:  database system was interrupted at 2005-01-20 19:54:34 JST
LOG:  checkpoint record is at 0/3E280E0
LOG:  redo record is at 0/3E280E0; undo record is at 0/0; shutdown FALSE
LOG:  next transaction id: 166624; next oid: 410192
LOG:  database system was not properly shut down; automatic recovery in progress
LOG:  ReadRecord: record with zero length at 0/3E28120
LOG:  redo is not required

  クラスタ2のpsqlから更新処理を実行
testdb1=# \i test_insert_10.sql
INSERT 418384 1
INSERT 418385 1
INSERT 418386 1
INSERT 418387 1
INSERT 418388 1
INSERT 418389 1
INSERT 418390 1
INSERT 418391 1
INSERT 418392 1
INSERT 418393 1

7.クラスタ3起動後に件数確認
クラスタ1(マスタ)
testdb1=# select count(*) from t1 ;
 count
-------
     4
(1 row)

クラスタ2
testdb1=# select count(*) from t1 ;
 count
-------
    10
(1 row)

クラスタ3
testdb1=# select count(*) from t1 ;
 count
-------
     4
(1 row)

※登録件数の結果はそのときどきで違う場合もありますが
 クラスタ毎の整合性は崩れています。

[テストデータ]
・データベース
testdb1=# \d
       List of relations
 Schema | Name | Type  | Owner
--------+------+-------+-------
 public | t1   | table | pgsql
(1 row)

testdb1=# \d t1
      Table "public.t1"
 Column |  Type   | Modifiers
--------+---------+-----------
 a1     | text    |
 a2     | integer |

・更新データ
%cat test_insert_10.sql
insert into t1 values ('a',1);
insert into t1 values ('a',1);
insert into t1 values ('a',1);
insert into t1 values ('a',1);
insert into t1 values ('a',1);
insert into t1 values ('a',1);
insert into t1 values ('a',1);
insert into t1 values ('a',1);
insert into t1 values ('a',1);
insert into t1 values ('a',1);





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