[pgsql-jp: 34356] Re: pgpool 2.3.1 で縮退運転に失敗します

Tatsuo Ishii t-ishii @ sra.co.jp
2004年 11月 30日 (火) 21:16:39 JST


石井です.

詳細な情報,ありがとうございます.マスタ側が落ちたときとセカンダリが落
ちたときで,縮退がうまく行かない原因が違うことが分かりました.お手数で
すが,確認のために以下をテストしていただけますか?

1) マスタ側が落ちたとき

SIGQUITで落ちるときのケースを想定してませんでした.SIGQUITではなく,
SIGINT(fast shutdown)でマスタを落としたときにうまくいくかどうか,うま
くいかないときはデバッグ出力を見せていただけますか?

2) セカンダリ側が落ちたとき

子プロセスが死んだときにあがるSIGCHLDと,フェイルオーバリクエスト用の
シグナルSIGUSR2の上がるタイミングが悪さをして,wait(2)の中でブロックし
ているようです.添付のパッチをmain.cにあて,状況が改善されるかどうか確
認していただけますでしょうか?
--
Tatsuo Ishii

> > 2) -n -d オプションを付けて詳しいデバッグログを見せてください.
> 
> 前回のテスト内容に合わせてログを記述しました。
> 
> 0.pgpool とMaster, Secondary のpostmaster を起動。
> 
> 1.Master 側を停止した場合
> 
> 1.1.pgpool 経由でデータベースにアクセスする
> psql -p 9999
> ---
> DEBUG: pid 550: I am 550 accept fd 6
> DEBUG: pid 550: Protocol Major: 3 Minor: 0 database: postgres user: postgres
> DEBUG: pid 550: name: client_encoding value: SQL_ASCII
> DEBUG: pid 550: name: DateStyle value: ISO, MDY
> DEBUG: pid 550: name: is_superuser value: on
> DEBUG: pid 550: name: server_version value: 7.4.3
> DEBUG: pid 550: name: session_authorization value: postgres
> DEBUG: pid 550: read kind from backend pending data Z len: 5 po: 160
> DEBUG: pid 550: ReadyForQuery: message length: 5
> DEBUG: pid 550: ReadyForQuery: transaction state: I
> ---
> 
> 1.2.Kill -QUIT でMaster 側のpostmaster を停止
> ---
> DEBUG: pid 550: read kind from backend N
> DEBUG: pid 550: pool_process_query: waiting for secondary for data ready
> ERROR: pid 550: pool_check_fd: data is not ready tp->tv_sec 5 tp->tp_usec 0
> ERROR: pid 550: pool_process_query: secondary data is not ready at
> synchronous p
> oint. abort this session
> ERROR: pid 550: pool_process_query: kind does not match between backends
> master(
> N) secondary()
> ---
> 
> 1.3.データベースへアクセスするが、反応が返ってこない
> ---
> postgres=# select * from test;
> 
> (このコマンドを実行して30分間待ったが応答なし)
> (デバッグモードにも応答なし)
> 
> 
> 2.Secondary 側を停止した場合
> 
> 2.1.pgpool 経由でデータベースにアクセスする
> psql -p 9999
> ---
> DEBUG: pid 349: I am 349 accept fd 6
> DEBUG: pid 349: Protocol Major: 3 Minor: 0 database: postgres user: postgres
> DEBUG: pid 349: name: client_encoding value: SQL_ASCII
> DEBUG: pid 349: name: DateStyle value: ISO, MDY
> DEBUG: pid 349: name: is_superuser value: on
> DEBUG: pid 349: name: server_version value: 7.4.3
> DEBUG: pid 349: name: session_authorization value: postgres
> DEBUG: pid 349: read kind from backend pending data Z len: 5 po: 160
> DEBUG: pid 349: ReadyForQuery: message length: 5
> DEBUG: pid 349: ReadyForQuery: transaction state: I
> ---
> 
> 2.2.Kill -QUIT でSecondary 側のpostmaster を停止
> 
> 2.3.データベースへアクセスする
> ・1回目:失敗
> ---
> postgres=# select * from test;
> ERROR:  kind mismatch between backends
> HINT:  check data consistency between master and secondary
> server closed the connection unexpectedly
>         This probably means the server terminated abnormally
>         before or while processing the request.
> The connection to the server was lost. Attempting reset: Failed.
> !>
> ---
> DEBUG: pid 349: read kind from frontend Q(51)
> DEBUG: pid 349: Query: select * from test;
> DEBUG: pid 349: read kind from backend T
> DEBUG: pid 349: pool_process_query: waiting for secondary for data ready
> ERROR: pid 349: pool_process_query: kind does not match between backends
> master(
> T) secondary(N)
> DEBUG: pid 349: len:386
> LOG: pid 349: do_child: exits with status 1 due to error
> DEBUG: pid 348: I am 348 accept fd 6
> DEBUG: pid 348: Protocol Major: 3 Minor: 0 database: postgres user: postgres
> DEBUG: pid 317: child 349 exits with status 256 by signal 0
> ERROR: pid 348: connect_inet_domain_socket: connect() failed: Connection
> refused
> LOG: pid 348: notice_backend_error: master: 0 fail over request from pid 348
> DEBUG: pid 353: I am 353
> DEBUG: pid 317: failover_handler called
> LOG: pid 317: starting degeneration. shutdown secondary host
> Secondary_Host(5432)
> ---
> 
> ・2回目:失敗
> ---
> ishikawa$ psql -p 9999
> psql: server closed the connection unexpectedly
>         This probably means the server terminated abnormally
>         before or while processing the request.
> ---
> DEBUG: pid 353: I am 353 accept fd 6
> DEBUG: pid 353: Protocol Major: 3 Minor: 0 database: postgres user: postgres
> ERROR: pid 353: connect_inet_domain_socket: connect() failed: Connection
> refused
> LOG: pid 353: notice_backend_error: master: 0 fail over request from pid 353
> User Signal 2
> 
> (デバッグモードが解除される)
> ---
> 
> 
> > 3) pgpool.confの内容を見せてください.
> 
> 初期設定を修正したのは下記の箇所です。
> 
> listen_address = '*'
> backend_host_name = 'Master_Host'
> secondary_backend_host_name = 'Secondary_Host'
> secondary_backend_port = 5432
> replication_mode = true
> logdir = '/var/log/pgpool'

Index: main.c
===================================================================
RCS file: /home/t-ishii/repository/pgpool/main.c,v
retrieving revision 1.22
diff -c -r1.22 main.c
*** main.c	12 Nov 2004 11:45:40 -0000	1.22
--- main.c	30 Nov 2004 10:51:27 -0000
***************
*** 537,543 ****
--- 537,545 ----
  
  static RETSIGTYPE exit_handler(int sig)
  {
+ #ifdef NOT_USED
  	int i;
+ #endif
  
  	/*
  	 * this could happend in a child process if a signal has been sent
***************
*** 553,558 ****
--- 555,561 ----
  
  	exiting = 1;
  
+ #ifdef NOT_USED
  	for (i = 0; i < pool_config.num_init_children; i++)
  	{
  		pid_t pid = pids[i];
***************
*** 561,566 ****
--- 564,571 ----
  			kill(pid, sig);
  		}
  	}
+ #endif
+ 	kill(0, sig);
  	while (wait(NULL) > 0)
  		;
  
***************
*** 645,656 ****
--- 650,664 ----
  		}
  
  		/* kill all children */
+ 		kill(0, SIGTERM);
+ #ifdef NOT_USED
  		for (i = 0; i < pool_config.num_init_children; i++)
  		{
  			pid_t pid = pids[i];
  			if (pid)
  				kill(pid, SIGTERM);
  		}
+ #endif
  		while (wait(NULL) > 0)
  			;
  
[t-ishii @ srapc2345 pgpool]$ 



pgsql-jp メーリングリストの案内