2

V1 呼び出し規約を使用して、PG 用の C 拡張ライブラリを作成しました。私のデータベースはバージョン8.4です。新しい関数の作成に成功しました。

ただし、新しい関数を呼び出すと、サーバーがクラッシュし、次のメッセージがコンソールに送信されます。

The connection to the server was lost. Attempting reset: Failed.

サーバー ログには次の行が含まれます。

server process (PID 14751) was terminated by signal 11: Segmentation fault

gdb を postgres プロセスにアタッチし、スタック トレースを取得できるかどうかを確認して、デバッグを開始したいと考えています。ただし、実行すると

ps補助 | grep postgres

postgres プロセスを特定しようとすると、postgres と呼ばれるプロセスがいくつかあるようです。

上記のデバッグ目的で (再起動後に) postgres サーバー プロセスを正しく識別するにはどうすればよいですか?

4

2 に答える 2

2

私はちょうどこれに対する答えを見つけました。データベース名も ps aux 出力の一部です。

例えば:

postgres  1071  0.0  0.1 101120  5360 ?        S    Jan03   0:01 /usr/lib/postgresql/8.4/bin/postgres -D /var/lib/postgresql/8.4/main -c config_file=/etc/postgresql/8.4/main/postgresql.conf
postgres 11866  0.0  0.1  68444  4340 pts/1    S+   10:16   0:00 /usr/lib/postgresql/8.4/bin/psql postgres
postgres 14856  0.0  0.1 103612  4716 ?        Ss   14:56   0:00 postgres: postgres mydatabase [local] idle  
postgres 14894  0.0  0.0 101120  1640 ?        Ss   15:05   0:00 postgres: writer process  

この場合のプロセス ID は 14856 です。

于 2012-01-04T15:10:49.867 に答える
1

次のように、現在のバックエンドのPIDを取得できます。

select pg_backend_pid();
于 2012-01-04T15:19:35.880 に答える