質問編集履歴

1 直接接続する方向に変更しました。

退会済みユーザー

退会済みユーザー

2017/02/12 20:19  投稿

perl からpgpoolへの接続について
#### 困ったこと
perlのDBD::Pgからpgpoolを通しqueryを流すと帰ってこない現象がおきております。
参考にデバッグの出力を添付します。
どなたかこの問題を解消してdbへqueryを投げ結果を取得できる方法をご存知ないでしょうか?
`DEBUG: selecting load balance node
DETAIL: selected backend id is 0
DEBUG: initializing session context
DETAIL: selected load balancing node: 0
DEBUG: session context: unsetting query in progress. DONE
DEBUG: session context: clearing transaction isolation. DONE
DEBUG: session context: clearing writing transaction. DONE
DEBUG: session context: clearing failed transaction. DONE
DEBUG: session context: clearing failed transaction. DONE
DEBUG: session context: clearing skip reading from backends. DONE
DEBUG: session context: clearing ignore till sync. DONE
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 0 doing extended query: 0
DEBUG: reading backend data packet kind
DETAIL: master node id: 0
DEBUG: reading backend data packet kind
DETAIL: backend:0 kind:'Z'
DEBUG: reading backend data packet kind
DETAIL: backend:0 of 2 kind = 'Z'
DEBUG: read_kind_from_backend max_count:1.000000 num_executed_nodes:1
DEBUG: processing backend response
DETAIL: received kind 'Z'(5a) from backend
DEBUG: processing backend response
DETAIL: Ready For Query received
DEBUG: session context: clearing ignore till sync. DONE
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 0 doing extended query: 0
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 0 doing extended query: 0
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 0 doing extended query: 0
DEBUG: reading message length
DETAIL: slot: 0 length: 5
DEBUG: processing ReadyForQuery
DETAIL: transaction state '
DEBUG: processing frontend response
DETAIL: received kind 'Q'(51) from frontend
DEBUG: session context: clearing doing extended query messaging. DONE
LOG: statement: begin
DEBUG: session context: setting query in progress. DONE
DEBUG: decide where to send the queries
DETAIL: destination = 3 for query= "begin"
LOG: DB node id: 0 backend pid: 5688 statement: begin
DEBUG: pool_write: to backend: 0 kind:Q
DEBUG: waiting for query response
DETAIL: waiting for backend:0 to complete the query
DEBUG: pool_read: read 17 bytes from backend 0
DEBUG: detect error: kind: C
DEBUG: detect error: kind: C
DEBUG: detect error: kind: C
DEBUG: detect error: kind: C
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 1 doing extended query: 0
DEBUG: reading backend data packet kind
DETAIL: master node id: 0
DEBUG: reading backend data packet kind
DETAIL: backend:0 kind:'C'
DEBUG: reading backend data packet kind
DETAIL: backend:0 of 2 kind = 'C'
DEBUG: read_kind_from_backend max_count:1.000000 num_executed_nodes:1
DEBUG: processing backend response
DETAIL: received kind 'C'(43) from backend
DEBUG: session context: clearing writing transaction. DONE
DEBUG: session context: clearing failed transaction. DONE
DEBUG: session context: clearing failed transaction. DONE
DEBUG: session context: setting command success. DONE
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 1 doing extended query: 0
DEBUG: reading backend data packet kind
DETAIL: master node id: 0
DEBUG: reading backend data packet kind
DETAIL: backend:0 kind:'Z'
DEBUG: reading backend data packet kind
DETAIL: backend:0 of 2 kind = 'Z'
DEBUG: read_kind_from_backend max_count:1.000000 num_executed_nodes:1
DEBUG: processing backend response
DETAIL: received kind 'Z'(5a) from backend
DEBUG: processing backend response
DETAIL: Ready For Query received
DEBUG: session context: clearing ignore till sync. DONE
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 1 doing extended query: 0
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 1 doing extended query: 0
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 1 doing extended query: 0
DEBUG: reading message length
DETAIL: slot: 0 length: 5
DEBUG: processing ReadyForQuery
DETAIL: transaction state 'T'(54)
DEBUG: session context: clearing writing transaction. DONE
DEBUG: session context: clearing failed transaction. DONE
DEBUG: session context: clearing failed transaction. DONE
DEBUG: session context: unsetting query in progress. DONE
DEBUG: session context: unsetting query in progress. DONE
DEBUG: processing frontend response
DETAIL: received kind 'P'(50) from frontend
DEBUG: session context: clearing doing extended query messaging. DONE
DEBUG: session context: setting doing extended query messaging. DONE
DEBUG: Parse: statement name <>
DEBUG: session context: setting query in progress. DONE
DEBUG: checking if query has INSERT INTO, FOR SHARE or FOR UPDATE
DETAIL: result = 0
DEBUG: decide where to send the queries
DETAIL: destination = 2 for query= "SELECT version();"
DEBUG: do_query: extended:1 query:"SELECT current_setting('transaction_isolation')"
DEBUG: pool_write: to backend: 0 kind:P
DEBUG: pool_write: to backend: 0 kind:B
DEBUG: pool_write: to backend: 0 kind:C
DEBUG: pool_write: to backend: 0 kind:S
DEBUG: pool_write: to backend: 0 kind:E
DEBUG: pool_write: to backend: 0 kind:C
DEBUG: pool_write: to backend: 0 kind:P
DEBUG: pool_write: to backend: 0 kind:S
DEBUG: pool_read: read 65 bytes from backend 0
DEBUG: do_query: kind: '1'
DEBUG: do_query: received PARSE COMPLETE ('1')
DEBUG: do_query: kind: '2'
DEBUG: do_query: received BIND COMPLETE ('2')
DEBUG: do_query: kind: '3'
DEBUG: do_query: received CLOSE COMPLETE ('3')
DEBUG: do_query: kind: 'D'
DEBUG: do_query: received DATA ROW ('D')
DEBUG: do_query: kind: 'C'
DEBUG: do_query: received COMMAND COMPLETE ('C')
DEBUG: do_query: kind: '3'
DEBUG: do_query: received CLOSE COMPLETE ('3')
DEBUG: do_query: kind: 'Z'
DEBUG: do_query: received READY FOR QUERY ('Z')
DEBUG: do_query: all state completed. returning
DEBUG: function call walker, function name: "version"
DEBUG: comparing function name in blacklist/whitelist regex array
DETAIL: pattern_compare: black_function_list (^nextval$) not matched: version
DEBUG: comparing function name in blacklist/whitelist regex array
DETAIL: pattern_compare: black_function_list (^setval$) not matched: version
DEBUG: comparing function name in blacklist/whitelist regex array
DETAIL: pattern_compare: black_function_list (^nextval$) not matched: version
DEBUG: comparing function name in blacklist/whitelist regex array
DETAIL: pattern_compare: black_function_list (^setval$) not matched: version
DEBUG: Parse: waiting for master completing the query
LOG: DB node id: 0 backend pid: 5688 statement: Parse: SELECT version();
DEBUG: pool_send_and_wait: pool_set_sync_map: 0
DEBUG: pool_write: to backend: 0 kind:P
DEBUG: pool_write: to backend: 0 kind:H
DEBUG: waiting for query response
DETAIL: waiting for backend:0 to complete the query
DEBUG: pool_read: read 5 bytes from backend 0
DEBUG: detect error: kind: 1
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 1 doing extended query: 1
DEBUG: reading backend data packet kind
DETAIL: master node id: 0
DEBUG: reading backend data packet kind
DETAIL: backend:0 kind:'1'
DEBUG: reading backend data packet kind
DETAIL: backend:0 of 2 kind = '1'
DEBUG: read_kind_from_backend max_count:1.000000 num_executed_nodes:1
DEBUG: processing backend response
DETAIL: received kind '1'(31) from backend
DEBUG: called by pool_add_sent_message: sent message: address: 0x2399fc0 kind: P name: ==
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 1 doing extended query: 1
DEBUG: SimpleForwardToFrontend: packet:1 length:0
DEBUG: session context: setting command success. DONE
DEBUG: pool_use_sync_map: we cannot use sync map because STREAM: 0 query in progress: 1 doing extended query: 1
DEBUG: reading backend data packet kind
DETAIL: master node id: 0
`
#### コード
`sub get_dbh
{
my $dbh = undef;
eval{
$dbh = DBI->connect("dbi:Pg:dbname=".$self->commons_config->{'database'}->{'dbname'}.";host=".$self->commons_config->{'database'}->{'host'},
$self->commons_config->{'database'}->{'user'},
$self->commons_config->{'database'}->{'password'},
{AutoCommit => 1, RaiseError => 1, PrintError => 0});
};
local $@;
if ($@){
$u->logger($@);
exit 1;
}
local $@;
eval{
my $sth = $dbh->prepare("SELECT version();");# <-ここで固まる
$sth->execute;
};
if ($@){
# $u->logger($@);
$u->logger('DB connection error');
exit 1;
}
return $dbh;
}`
  • Perl

    583 questions

    Perlは多目的に使用される実用性が高い動的プログラミング言語のひとつです。

  • PostgreSQL

    2146 questions

    PostgreSQLはオープンソースのオブジェクトリレーショナルデータベース管理システムです。 Oracle Databaseで使われるPL/SQLを参考に実装されたビルトイン言語で、Windows、 Mac、Linux、UNIX、MSなどいくつものプラットフォームに対応しています。

思考するエンジニアのためのQ&Aサイト「teratail」について詳しく知る