调试postgreSQL服务器进程(如何识别正确的进程id)
我已经为 PG 编写了一个 C 扩展库,使用 V1 调用约定。我的数据库版本是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 aux | 时grep postgres
尝试定位postgres进程,似乎有几个进程称为postgres。
如上所述,如何正确识别 postgres 服务器进程(重新启动后)以进行调试?
I have written a C extension library for PG, using V1 calling convention. My db is ver 8.4.
I have successfully created the new functions.
However, when I invoke my new functions, it crashes the server, with the following message sent to the console:
The connection to the server was lost. Attempting reset: Failed.
The server log contains the line:
server process (PID 14751) was terminated by signal 11: Segmentation fault
I want to attach gdb to the postgres process, and see if I can obtain a stack trace, to help me start debugging. However, when I run
ps aux | grep postgres
to try to locate the postgres process, there seems to be several processes called postgres.
How may I correctly identify the postgres server process (after restarted) for debugging purposes as described above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚找到了这个问题的答案。数据库名称也是 ps aux 输出的一部分。
例如:
本例中的进程id是14856
I just found out the answer to this. The database name is also part of the ps aux output.
For example:
The process id in this case is 14856
您可以像这样获取当前后端的PID:
You can get the PID of the current backend like this: