2012-01-04 64 views
2

我已經使用V1調用約定爲PG編寫了一個C擴展庫。我的數據庫是8.4版本。 我已成功創建新功能。調試postgreSQL服務器進程(如何識別正確的進程ID)

然而,當我調用我的新功能,它崩潰的服務器,以發送到控制檯以下消息:

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

服務器日誌包含行:

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

我想將gdb附加到postgres進程,並查看是否可以獲取堆棧跟蹤,以幫助我開始調試。但是,當我跑

ps aux | grep postgres

要嘗試找到postgres進程,似乎有幾個進程稱爲postgres。

如何才能正確識別postgres服務器進程(重新啓動後)用於調試目的,如上所述?

回答

1

我剛剛發現了答案。數據庫名稱也是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

1

你可以得到當前後端這樣的PID:

select pg_backend_pid(); 
+0

有用的 - 我沒有我知道。 – 2012-01-05 09:34:18