SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
What Do You Mean my Database
Server Core Dumped?
How to Inspect Postgres Core Dumps
Syed Faisal Akber
VMware, Inc.
2014-05-23
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 1 / 33
1 Introduction
2 What is a core dump?
3 Inspecting Core Dumps
4 Basic Core Dump Analysis
5 Postgres Core Dumps Specifics
6 Case Study
7 Advanced Topics
8 Conclusions
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 2 / 33
Introduction
Quick introduction to core dump analysis
Requires knowledge of application source code
Proper analysis can take time
Knowledge of C is essential
Knowledge of assembly is recommended
Sometimes it is better to look at the “environment”
instead
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 3 / 33
What is a core dump?
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 4 / 33
What is a core dump?
A core dump is a copy of
memory contents
CPU registers
and other information
stored in a disk file
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 4 / 33
Why does a core dump get generated?
A program did something bad
Divide by zero
Bus errors (Segmentation violations)
Someone or something forced it
SIGABRT (Abort)
SIGSEGV (Segmentation Violation)
SIGFPE (Floating-Point Error)
SIGILL (Illegal Instruction)
Hardware issues?
See signal(7), kill(1), and kill(2) manual pages for
more information.
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 5 / 33
Ensuring a core dump is generated
User limit (ulimit) or resource limit (rlimit)
must be set
On sh or bash, run ulimit -c unlimited
On csh, run limit -c unlimited
On tcsh, run limit coredumpsize unlimited
Have enough space on disk
Ensure that ulimit is setup in the shell before
starting Postgres
Core dump will be in $PGDATA
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 6 / 33
Inspecting Core Dumps
Basic inspection involves usage of a few tools
Detailed review requires GDB
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 7 / 33
Basic Inspection Tools I
file
$ file core
core: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from
’/opt/postgres/bin/postgres -D /var/postgres’
readelf
$ readelf -h core
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2’s complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: CORE (Core file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x0
Start of program headers: 64 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 35
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 8 / 33
Basic Inspection Tools II
Size of section headers: 0 (bytes)
Number of section headers: 0
Section header string table index: 0
Other tools such as objdump are useful as well
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 9 / 33
Core Dump Analysis – Prerequisites I
GDB (GNU Debugger)
Source code
An unstripped binary equivalent to what was in
memory
$ cd src/backend
$ file postgres
postgres: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically
linked (uses shared libs), for GNU/Linux 2.6.24,
BuildID[sha1]=90b4b71f515c653a7ce50f0474741852bf873505, not stripped
postgres: file format elf64-x86-64
$ objdump -h postgres
Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 0000001c 0000000000400238 0000000000400238 00000238 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
...
12 .text 002e07ba 00000000004590c0 00000000004590c0 000590c0 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
...
23 .data 0000cbe0 0000000000afc7c0 0000000000afc7c0 004fc7c0 2**5
CONTENTS, ALLOC, LOAD, DATA
24 .bss 0005b068 0000000000b093a0 0000000000b093a0 005093a0 2**5
ALLOC
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 10 / 33
Core Dump Analysis – Prerequisites II
...
26 .debug_aranges 00006790 0000000000000000 0000000000000000 005093c4 2**0
CONTENTS, READONLY, DEBUGGING
27 .debug_info 0088e8e4 0000000000000000 0000000000000000 0050fb54 2**0
CONTENTS, READONLY, DEBUGGING
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 11 / 33
Core Dump Analysis – Invoking GDB
$ gdb src/backend/postgres -c /var/postgres/core
GNU gdb (Ubuntu 7.7-0ubuntu3) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./postgres...done.
[New LWP 2368]
Core was generated by ‘/opt/postgres/bin/postgres -D /var/postgres’.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007f8e6c4fac13 in __select_nocancel ()
at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb)
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 12 / 33
Basic GDB Commands - backtrace
(gdb) bt
#0 fib (n=6) at multi0.c:14
#1 0x00000000004006aa in fib (n=7) at multi0.c:16
#2 0x00000000004006aa in fib (n=8) at multi0.c:16
#3 0x00000000004006c5 in fib (n=10) at multi0.c:16
#4 0x00000000004006c5 in fib (n=12) at multi0.c:16
#5 0x00000000004006c5 in fib (n=14) at multi0.c:16
...
#87 0x00000000004006aa in fib (n=110) at multi0.c:16
#88 0x00000000004005ea in main (argc=3, argv=0x7fff84af3bd8) at multi.c:16
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 13 / 33
Basic GDB Commands - frame
(gdb) f 0
#0 fib (n=6) at multi0.c:14
14 if ((i == 100) && (n == 0))
(gdb)
...
(gdb) f 88
#88 0x00000000004005ea in main (argc=3, argv=0x7fff84af3bd8) at multi.c:16
16 y = fib(b);
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 14 / 33
Basic GDB Commands - print
(gdb) p x
$13 = 1.5882455415227421e+178
(gdb) p/x x
$14 = 0x8000000000000000
(gdb) p &x
$15 = (double *) 0x7fff84af3ad8
(gdb) printf "a is %dnb is %dn", a, b
a is 110
b is 110
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 15 / 33
Basic GDB Commands - x
(gdb) x/xg 0x7fff84af3ae0
0x7fff84af3ae0: 0x405b800000000000
(gdb) x/f 0x7fff84af3ae0
0x7fff84af3ae0: 110
(gdb) x/i 0x00000000004005ea
=> 0x4005ea <main+102>: movsd %xmm0,-0x20(%rbp)
(gdb) x/i 0x00000000004006aa
0x4006aa <fib+138>: movsd %xmm0,-0x10(%rbp)
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 16 / 33
Basic GDB Commands - info
registers I
(gdb) info reg rsp
rsp 0x7fff84af3ab0 0x7fff84af3ab0
(gdb) info reg rip
rip 0x4005ea 0x4005ea <main+102>
(gdb) info reg rax
rax 0xb800000000000 3236962232172544
(gdb) info reg
rax 0xb800000000000 3236962232172544
rbx 0x0 0
rcx 0x0 0
rdx 0x405b800000000000 4637440978796412928
rsi 0xfffff00000000 4503595332403200
rdi 0x7fff84af3a50 140735419464272
rbp 0x7fff84af2fc0 0x7fff84af2fc0
rsp 0x7fff84af2fb0 0x7fff84af2fb0
r8 0x0 0
r9 0x0 0
r10 0x2 2
r11 0x7fff84af39a8 140735419464104
r12 0x4004a0 4195488
r13 0x7fff84af3bd0 140735419464656
r14 0x0 0
r15 0x0 0
rip 0x40065e 0x40065e <fib+62>
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 17 / 33
Basic GDB Commands - info
registers II
eflags 0x203 [ CF IF ]
cs 0x33 51
ss 0x2b 43
ds 0x0 0
es 0x0 0
fs 0x0 0
gs 0x0 0
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 18 / 33
Basic GDB Commands - disassemble I
(gdb) disassemble
Dump of assembler code for function fib:
0x0000000000400620 <+0>: push %rbp
0x0000000000400621 <+1>: mov %rsp,%rbp
0x0000000000400624 <+4>: sub $0x10,%rsp
0x0000000000400628 <+8>: movsd %xmm0,-0x8(%rbp)
0x000000000040062d <+13>: xorpd %xmm0,%xmm0
0x0000000000400631 <+17>: ucomisd -0x8(%rbp),%xmm0
0x0000000000400636 <+22>: jne 0x400643 <fib+35>
0x0000000000400638 <+24>: jp 0x400643 <fib+35>
0x000000000040063a <+26>: xorpd %xmm0,%xmm0
0x000000000040063e <+30>: jmpq 0x4006ca <fib+170>
0x0000000000400643 <+35>: movsd 0x1cd(%rip),%xmm0 # 0x400818
0x000000000040064b <+43>: ucomisd -0x8(%rbp),%xmm0
0x0000000000400650 <+48>: jne 0x40065e <fib+62>
0x0000000000400652 <+50>: jp 0x40065e <fib+62>
0x0000000000400654 <+52>: movsd 0x1bc(%rip),%xmm0 # 0x400818
0x000000000040065c <+60>: jmp 0x4006ca <fib+170>
=> 0x000000000040065e <+62>: movsd 0x2009e2(%rip),%xmm0 # 0x601048 <i>
0x0000000000400666 <+70>: ucomisd 0x1b2(%rip),%xmm0 # 0x400820
0x000000000040066e <+78>: jne 0x400694 <fib+116>
0x0000000000400670 <+80>: jp 0x400694 <fib+116>
0x0000000000400672 <+82>: xorpd %xmm0,%xmm0
0x0000000000400676 <+86>: ucomisd -0x8(%rbp),%xmm0
0x000000000040067b <+91>: jne 0x400694 <fib+116>
0x000000000040067d <+93>: jp 0x400694 <fib+116>
0x000000000040067f <+95>: movsd 0x2009c1(%rip),%xmm0 # 0x601048 <i>
0x0000000000400687 <+103>: divsd -0x8(%rbp),%xmm0
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 19 / 33
Basic GDB Commands - disassemble II
0x000000000040068c <+108>: movsd %xmm0,0x2009ac(%rip) # 0x601040 <k>
0x0000000000400694 <+116>: movsd -0x8(%rbp),%xmm0
0x0000000000400699 <+121>: movsd 0x177(%rip),%xmm1 # 0x400818
0x00000000004006a1 <+129>: subsd %xmm1,%xmm0
0x00000000004006a5 <+133>: callq 0x400620 <fib>
0x00000000004006aa <+138>: movsd %xmm0,-0x10(%rbp)
0x00000000004006af <+143>: movsd -0x8(%rbp),%xmm0
0x00000000004006b4 <+148>: movsd 0x16c(%rip),%xmm1 # 0x400828
0x00000000004006bc <+156>: subsd %xmm1,%xmm0
0x00000000004006c0 <+160>: callq 0x400620 <fib>
0x00000000004006c5 <+165>: addsd -0x10(%rbp),%xmm0
0x00000000004006ca <+170>: leaveq
0x00000000004006cb <+171>: retq
End of assembler dump.
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 20 / 33
Basic GDB Commands - list I
(gdb) l
11 // strcpy(end, argv[1]);
12 a = strtod(argv[1], &g);
13 b = strtod(argv[2], &h);
14
15 x = fact(a);
16 y = fib(b);
17
18 printf("%f! = %fnfib(%f) = %fn", a, x, b, y);
19 exit(0);
20 }
(gdb) l -
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4 #include "multi.h"
5
6 int main(int argc, char *argv[])
7 {
8 double a, b, x, y;
9 char *g, *h;
10
(gdb) l fact
4 *
5 */
6 #include "multi.h"
7
8 double fact(double n)
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 21 / 33
Basic GDB Commands - list II
9 {
10 if (n == 0)
11 return 1;
12 return n * fact(n - 1);
13 }
(gdb) l multi0.c:5
1 /*
2 *
3 * multi0.h - Example for calculating fibonacci numbers.
4 *
5 */
6 #include "multi.h"
7
8 double fib(double n)
9 {
10 if (n == 0)
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 22 / 33
Analyzing the Collected Information
Start with backtrace
Observe using print and x
Compare inputs and outputs of each frame
Use list and disassemble to follow the flow
Note where things don’t match up to the source
code
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 23 / 33
Postgres Core Dumps Specifics I
Core dump will only contain information from one
process not all
Core dump contains shared memory areas
(gdb) p AutoVacuumShmem
$3 = (AutoVacuumShmemStruct *) 0x7fd47aee3388
(gdb) p *AutoVacuumShmem
$4 = {av_signal = {0, 0}, av_launcherpid = 1348, av_freeWorkers = {head = {
prev = 0x7fd47aee33c0, next = 0x7fd47aee3430}}, av_runningWorkers = {
head = {prev = 0x7fd47aee33a8, next = 0x7fd47aee33a8}},
av_startingWorker = 0x0}
Global variables will allow easier access to status
Logs may provide more context
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 24 / 33
Case Study I
This is a case study of a Postgres process that was killed
intentionally. In this case, it is hypothetically assumed
that a client connection is unresponsive.
Use ps to find process
$ ps -ef
...
pgcon 2625 1343 0 06:02 ? 00:00:00 postgres: pgcon postgres [local]
...
Kill the process
$ kill -6 2625
Start GDB
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 25 / 33
Case Study II
/var/postgres$ gdb ~/postgresql/src/backend/postgres -c core
GNU gdb (Ubuntu 7.7-0ubuntu3) 7.7
...
Core was generated by ‘postgres: pgcon postgres [local] idle ’.
Program terminated with signal SIGABRT, Aborted.
#0 0x00007fd47b38821d in __libc_recv (fd=9,
buf=buf@entry=0xb12560 <PqRecvBuffer>, n=n@entry=8192, flags=-1,
flags@entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:29
29 ../sysdeps/unix/sysv/linux/x86_64/recv.c: No such file or directory.
(gdb)
Look at the stacktrace
(gdb) bt
#0 0x00007fd47b38821d in __libc_recv (fd=9,
buf=buf@entry=0xb12560 <PqRecvBuffer>, n=n@entry=8192, flags=-1,
flags@entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:29
#1 0x000000000059b583 in recv (__flags=0, __n=8192,
__buf=0xb12560 <PqRecvBuffer>, __fd=<optimized out>)
at /usr/include/x86_64-linux-gnu/bits/socket2.h:44
#2 secure_read (port=0xf21360, ptr=0xb12560 <PqRecvBuffer>, len=8192)
at be-secure.c:304
#3 0x00000000005a2f0b in pq_recvbuf () at pqcomm.c:854
#4 0x00000000005a3a65 in pq_getbyte () at pqcomm.c:895
#5 0x000000000064577a in SocketBackend (inBuf=0x7fffd21495c0)
at postgres.c:344
#6 ReadCommand (inBuf=0x7fffd21495c0) at postgres.c:492
#7 PostgresMain (argc=<optimized out>, argv=argv@entry=0xf021a8,
dbname=0xf02058 "postgres", username=<optimized out>) at postgres.c:3958
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 26 / 33
Case Study III
#8 0x000000000045a487 in BackendRun (port=0xf21360) at postmaster.c:3996
#9 BackendStartup (port=0xf21360) at postmaster.c:3685
#10 ServerLoop () at postmaster.c:1586
#11 0x0000000000606df5 in PostmasterMain (argc=argc@entry=3,
argv=argv@entry=0xf00f40) at postmaster.c:1253
#12 0x000000000045adbb in main (argc=3, argv=0xf00f40) at main.c:206
(gdb)
Inspect a few frames
(gdb) f 8
#8 0x000000000045a487 in BackendRun (port=0xf21360) at postmaster.c:3996
3996 PostgresMain(ac, av, port->database_name, port->user_name);
(gdb) p port->database_name
$2 = 0xf02058 "postgres"
(gdb) p port->user_name
$3 = 0xf02040 "pgcon"
(gdb) p *port
$4 = {sock = 9, noblock = 0 ’000’, proto = 196608, laddr = {addr = {
ss_family = 1, __ss_align = 3336130842095267443,
__ss_padding = "5432", ’000’ <repeats 107 times>}, salen = 21},
raddr = {addr = {ss_family = 1, __ss_align = 0,
__ss_padding = ’000’ <repeats 111 times>}, salen = 2},
remote_host = 0xf1e770 "[local]", remote_hostname = 0x0,
remote_hostname_resolv = 0, remote_port = 0xf1e690 "",
canAcceptConnections = CAC_OK, database_name = 0xf02058 "postgres",
user_name = 0xf02040 "pgcon", cmdline_options = 0x0, guc_options = 0xf020c8,
hba = 0xf237f0, md5Salt = "#230", <incomplete sequence 352240>,
SessionStartTime = 453992550897907, default_keepalives_idle = 0,
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 27 / 33
Case Study IV
default_keepalives_interval = 0, default_keepalives_count = 0,
keepalives_idle = 0, keepalives_interval = 0, keepalives_count = 0,
gss = 0x0}
(gdb) p *inBuf
$6 = {data = 0xfafc90 "", len = 0, maxlen = 1024, cursor = 0}
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 28 / 33
Advanced Topics
Below are some topics to research afterwards
For Extensions, load “symbols” using
add-symbol-file in GDB
Future feature enhancement to generate a core
dump containing all of the running threads
Determine which global variables are useful
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 29 / 33
Conclusions
What a core dump is
How to ensure a core dump gets generated
Basic GDB usage
Tips for understanding output from GDB
Techniques for Postgres Core Dumps
Case Study
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 30 / 33
Questions?
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 31 / 33
References
Debugging with GDB http://bit.ly/1o56H1z
GDB Reference Card http://bit.ly/1lOZzBz
Matloff,Norman and Peter Jay Salzman. 2008. The
Art of Debugging with Gdb, Ddd, and Eclipse. No
Starch Press, San Francisco, CA, USA.
Momjian, Bruce. Inside PostgreSQL Shared Memory
http://momjian.us/main/writings/pgsql/inside_
Krosing, Hannu and Kirk Roybal. 2013. PostgreSQL
Server Programming. Packt Publishing, Birmingham,
U.K.
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 32 / 33
Contact Information
E-mail: fakber@vmware.com
IRC: In #postgresql on Freenode as sfa
Twitter: @vCoreDump
S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 33 / 33

Weitere ähnliche Inhalte

Was ist angesagt?

Open Source Backup Cpnference 2014: Bareos in scientific environments, by Dr....
Open Source Backup Cpnference 2014: Bareos in scientific environments, by Dr....Open Source Backup Cpnference 2014: Bareos in scientific environments, by Dr....
Open Source Backup Cpnference 2014: Bareos in scientific environments, by Dr....
NETWAYS
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
Ontico
 
Tuning parallelcodeonsolaris005
Tuning parallelcodeonsolaris005Tuning parallelcodeonsolaris005
Tuning parallelcodeonsolaris005
dflexer
 
David container security-with_falco
David container security-with_falcoDavid container security-with_falco
David container security-with_falco
Lorenzo David
 
Device-specific Clang Tooling for Embedded Systems
Device-specific Clang Tooling for Embedded SystemsDevice-specific Clang Tooling for Embedded Systems
Device-specific Clang Tooling for Embedded Systems
emBO_Conference
 
Profiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsProfiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf Tools
emBO_Conference
 

Was ist angesagt? (20)

Open Source Backup Cpnference 2014: Bareos in scientific environments, by Dr....
Open Source Backup Cpnference 2014: Bareos in scientific environments, by Dr....Open Source Backup Cpnference 2014: Bareos in scientific environments, by Dr....
Open Source Backup Cpnference 2014: Bareos in scientific environments, by Dr....
 
Unix v6 セミナー vol. 5
Unix v6 セミナー vol. 5Unix v6 セミナー vol. 5
Unix v6 セミナー vol. 5
 
FreeBSD on Cavium ThunderX System on a Chip
FreeBSD on Cavium ThunderX System on a ChipFreeBSD on Cavium ThunderX System on a Chip
FreeBSD on Cavium ThunderX System on a Chip
 
Performance Analysis Tools for Linux Kernel
Performance Analysis Tools for Linux KernelPerformance Analysis Tools for Linux Kernel
Performance Analysis Tools for Linux Kernel
 
Streams for the Web
Streams for the WebStreams for the Web
Streams for the Web
 
Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)Performance tweaks and tools for Linux (Joe Damato)
Performance tweaks and tools for Linux (Joe Damato)
 
Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)Performance Wins with eBPF: Getting Started (2021)
Performance Wins with eBPF: Getting Started (2021)
 
Tuning parallelcodeonsolaris005
Tuning parallelcodeonsolaris005Tuning parallelcodeonsolaris005
Tuning parallelcodeonsolaris005
 
BPF Internals (eBPF)
BPF Internals (eBPF)BPF Internals (eBPF)
BPF Internals (eBPF)
 
David container security-with_falco
David container security-with_falcoDavid container security-with_falco
David container security-with_falco
 
eBPF Workshop
eBPF WorkshopeBPF Workshop
eBPF Workshop
 
re:Invent 2019 BPF Performance Analysis at Netflix
re:Invent 2019 BPF Performance Analysis at Netflixre:Invent 2019 BPF Performance Analysis at Netflix
re:Invent 2019 BPF Performance Analysis at Netflix
 
Device-specific Clang Tooling for Embedded Systems
Device-specific Clang Tooling for Embedded SystemsDevice-specific Clang Tooling for Embedded Systems
Device-specific Clang Tooling for Embedded Systems
 
Kernel development
Kernel developmentKernel development
Kernel development
 
YOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems Performance
 
BPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLabBPF / XDP 8월 세미나 KossLab
BPF / XDP 8월 세미나 KossLab
 
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
 
eBPF Trace from Kernel to Userspace
eBPF Trace from Kernel to UserspaceeBPF Trace from Kernel to Userspace
eBPF Trace from Kernel to Userspace
 
Profiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf ToolsProfiling your Applications using the Linux Perf Tools
Profiling your Applications using the Linux Perf Tools
 
eBPF Perf Tools 2019
eBPF Perf Tools 2019eBPF Perf Tools 2019
eBPF Perf Tools 2019
 

Ähnlich wie PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspect Postgres Core Dumps

Crash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_TizenCrash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_Tizen
Lex Yu
 
LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness
Peter Griffin
 
Share the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development BoardShare the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development Board
Jian-Hong Pan
 
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPFUSENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
Brendan Gregg
 
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Anne Nicolas
 
Kernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPFKernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPF
Brendan Gregg
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux Awareness
Peter Griffin
 

Ähnlich wie PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspect Postgres Core Dumps (20)

Crash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_TizenCrash_Report_Mechanism_In_Tizen
Crash_Report_Mechanism_In_Tizen
 
Next Stop, Android
Next Stop, AndroidNext Stop, Android
Next Stop, Android
 
LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness LAS16-403 - GDB Linux Kernel Awareness
LAS16-403 - GDB Linux Kernel Awareness
 
LAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel AwarenessLAS16-403: GDB Linux Kernel Awareness
LAS16-403: GDB Linux Kernel Awareness
 
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
 
Docker 활용법: dumpdocker
Docker 활용법: dumpdockerDocker 활용법: dumpdocker
Docker 활용법: dumpdocker
 
Share the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development BoardShare the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development Board
 
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPFOSSNA 2017 Performance Analysis Superpowers with Linux BPF
OSSNA 2017 Performance Analysis Superpowers with Linux BPF
 
Adding a BOLT pass
Adding a BOLT passAdding a BOLT pass
Adding a BOLT pass
 
Linux kernel debugging
Linux kernel debuggingLinux kernel debugging
Linux kernel debugging
 
Introduction to Debuggers
Introduction to DebuggersIntroduction to Debuggers
Introduction to Debuggers
 
Scylla Summit 2022: ScyllaDB Rust Driver: One Driver to Rule Them All
Scylla Summit 2022: ScyllaDB Rust Driver: One Driver to Rule Them AllScylla Summit 2022: ScyllaDB Rust Driver: One Driver to Rule Them All
Scylla Summit 2022: ScyllaDB Rust Driver: One Driver to Rule Them All
 
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPFUSENIX ATC 2017 Performance Superpowers with Enhanced BPF
USENIX ATC 2017 Performance Superpowers with Enhanced BPF
 
04 - I love my OS, he protects me (sometimes, in specific circumstances)
04 - I love my OS, he protects me (sometimes, in specific circumstances)04 - I love my OS, he protects me (sometimes, in specific circumstances)
04 - I love my OS, he protects me (sometimes, in specific circumstances)
 
005 skyeye
005 skyeye005 skyeye
005 skyeye
 
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
Kernel Recipes 2017 - Performance analysis Superpowers with Linux BPF - Brend...
 
Kernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPFKernel Recipes 2017: Performance Analysis with BPF
Kernel Recipes 2017: Performance Analysis with BPF
 
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
Kernel Recipes 2015: Linux Kernel IO subsystem - How it works and how can I s...
 
ELC-E Linux Awareness
ELC-E Linux AwarenessELC-E Linux Awareness
ELC-E Linux Awareness
 
07 - Bypassing ASLR, or why X^W matters
07 - Bypassing ASLR, or why X^W matters07 - Bypassing ASLR, or why X^W matters
07 - Bypassing ASLR, or why X^W matters
 

Kürzlich hochgeladen

➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men 🔝Ongole🔝 Escorts S...
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men  🔝Ongole🔝   Escorts S...➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men  🔝Ongole🔝   Escorts S...
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men 🔝Ongole🔝 Escorts S...
amitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
amitlee9823
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
amitlee9823
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
amitlee9823
 
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
gajnagarg
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
amitlee9823
 
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
gajnagarg
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
gajnagarg
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
amitlee9823
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
amitlee9823
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 

Kürzlich hochgeladen (20)

➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men 🔝Ongole🔝 Escorts S...
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men  🔝Ongole🔝   Escorts S...➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men  🔝Ongole🔝   Escorts S...
➥🔝 7737669865 🔝▻ Ongole Call-girls in Women Seeking Men 🔝Ongole🔝 Escorts S...
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Detecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning ApproachDetecting Credit Card Fraud: A Machine Learning Approach
Detecting Credit Card Fraud: A Machine Learning Approach
 
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service BangaloreCall Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
Call Girls Begur Just Call 👗 7737669865 👗 Top Class Call Girl Service Bangalore
 
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
SAC 25 Final National, Regional & Local Angel Group Investing Insights 2024 0...
 
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men  🔝mahisagar🔝   Esc...
➥🔝 7737669865 🔝▻ mahisagar Call-girls in Women Seeking Men 🔝mahisagar🔝 Esc...
 
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
Just Call Vip call girls Erode Escorts ☎️9352988975 Two shot with one girl (E...
 
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
Escorts Service Kumaraswamy Layout ☎ 7737669865☎ Book Your One night Stand (B...
 
Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
VIP Model Call Girls Hinjewadi ( Pune ) Call ON 8005736733 Starting From 5K t...
 
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls Mysore Escorts ☎️9352988975 Two shot with one girl (...
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
Just Call Vip call girls roorkee Escorts ☎️9352988975 Two shot with one girl ...
 
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men  🔝malwa🔝   Escorts Ser...
➥🔝 7737669865 🔝▻ malwa Call-girls in Women Seeking Men 🔝malwa🔝 Escorts Ser...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get CytotecAbortion pills in Doha Qatar (+966572737505 ! Get Cytotec
Abortion pills in Doha Qatar (+966572737505 ! Get Cytotec
 
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
Call Girls Hsr Layout Just Call 👗 7737669865 👗 Top Class Call Girl Service Ba...
 
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night StandCall Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Attibele ☎ 7737669865 🥵 Book Your One night Stand
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 

PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspect Postgres Core Dumps

  • 1. What Do You Mean my Database Server Core Dumped? How to Inspect Postgres Core Dumps Syed Faisal Akber VMware, Inc. 2014-05-23 S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 1 / 33
  • 2. 1 Introduction 2 What is a core dump? 3 Inspecting Core Dumps 4 Basic Core Dump Analysis 5 Postgres Core Dumps Specifics 6 Case Study 7 Advanced Topics 8 Conclusions S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 2 / 33
  • 3. Introduction Quick introduction to core dump analysis Requires knowledge of application source code Proper analysis can take time Knowledge of C is essential Knowledge of assembly is recommended Sometimes it is better to look at the “environment” instead S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 3 / 33
  • 4. What is a core dump? S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 4 / 33
  • 5. What is a core dump? A core dump is a copy of memory contents CPU registers and other information stored in a disk file S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 4 / 33
  • 6. Why does a core dump get generated? A program did something bad Divide by zero Bus errors (Segmentation violations) Someone or something forced it SIGABRT (Abort) SIGSEGV (Segmentation Violation) SIGFPE (Floating-Point Error) SIGILL (Illegal Instruction) Hardware issues? See signal(7), kill(1), and kill(2) manual pages for more information. S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 5 / 33
  • 7. Ensuring a core dump is generated User limit (ulimit) or resource limit (rlimit) must be set On sh or bash, run ulimit -c unlimited On csh, run limit -c unlimited On tcsh, run limit coredumpsize unlimited Have enough space on disk Ensure that ulimit is setup in the shell before starting Postgres Core dump will be in $PGDATA S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 6 / 33
  • 8. Inspecting Core Dumps Basic inspection involves usage of a few tools Detailed review requires GDB S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 7 / 33
  • 9. Basic Inspection Tools I file $ file core core: ELF 64-bit LSB core file x86-64, version 1 (SYSV), SVR4-style, from ’/opt/postgres/bin/postgres -D /var/postgres’ readelf $ readelf -h core ELF Header: Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2’s complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: CORE (Core file) Machine: Advanced Micro Devices X86-64 Version: 0x1 Entry point address: 0x0 Start of program headers: 64 (bytes into file) Start of section headers: 0 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 35 S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 8 / 33
  • 10. Basic Inspection Tools II Size of section headers: 0 (bytes) Number of section headers: 0 Section header string table index: 0 Other tools such as objdump are useful as well S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 9 / 33
  • 11. Core Dump Analysis – Prerequisites I GDB (GNU Debugger) Source code An unstripped binary equivalent to what was in memory $ cd src/backend $ file postgres postgres: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=90b4b71f515c653a7ce50f0474741852bf873505, not stripped postgres: file format elf64-x86-64 $ objdump -h postgres Sections: Idx Name Size VMA LMA File off Algn 0 .interp 0000001c 0000000000400238 0000000000400238 00000238 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA ... 12 .text 002e07ba 00000000004590c0 00000000004590c0 000590c0 2**4 CONTENTS, ALLOC, LOAD, READONLY, CODE ... 23 .data 0000cbe0 0000000000afc7c0 0000000000afc7c0 004fc7c0 2**5 CONTENTS, ALLOC, LOAD, DATA 24 .bss 0005b068 0000000000b093a0 0000000000b093a0 005093a0 2**5 ALLOC S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 10 / 33
  • 12. Core Dump Analysis – Prerequisites II ... 26 .debug_aranges 00006790 0000000000000000 0000000000000000 005093c4 2**0 CONTENTS, READONLY, DEBUGGING 27 .debug_info 0088e8e4 0000000000000000 0000000000000000 0050fb54 2**0 CONTENTS, READONLY, DEBUGGING S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 11 / 33
  • 13. Core Dump Analysis – Invoking GDB $ gdb src/backend/postgres -c /var/postgres/core GNU gdb (Ubuntu 7.7-0ubuntu3) 7.7 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./postgres...done. [New LWP 2368] Core was generated by ‘/opt/postgres/bin/postgres -D /var/postgres’. Program terminated with signal SIGABRT, Aborted. #0 0x00007f8e6c4fac13 in __select_nocancel () at ../sysdeps/unix/syscall-template.S:81 81 ../sysdeps/unix/syscall-template.S: No such file or directory. (gdb) S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 12 / 33
  • 14. Basic GDB Commands - backtrace (gdb) bt #0 fib (n=6) at multi0.c:14 #1 0x00000000004006aa in fib (n=7) at multi0.c:16 #2 0x00000000004006aa in fib (n=8) at multi0.c:16 #3 0x00000000004006c5 in fib (n=10) at multi0.c:16 #4 0x00000000004006c5 in fib (n=12) at multi0.c:16 #5 0x00000000004006c5 in fib (n=14) at multi0.c:16 ... #87 0x00000000004006aa in fib (n=110) at multi0.c:16 #88 0x00000000004005ea in main (argc=3, argv=0x7fff84af3bd8) at multi.c:16 S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 13 / 33
  • 15. Basic GDB Commands - frame (gdb) f 0 #0 fib (n=6) at multi0.c:14 14 if ((i == 100) && (n == 0)) (gdb) ... (gdb) f 88 #88 0x00000000004005ea in main (argc=3, argv=0x7fff84af3bd8) at multi.c:16 16 y = fib(b); S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 14 / 33
  • 16. Basic GDB Commands - print (gdb) p x $13 = 1.5882455415227421e+178 (gdb) p/x x $14 = 0x8000000000000000 (gdb) p &x $15 = (double *) 0x7fff84af3ad8 (gdb) printf "a is %dnb is %dn", a, b a is 110 b is 110 S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 15 / 33
  • 17. Basic GDB Commands - x (gdb) x/xg 0x7fff84af3ae0 0x7fff84af3ae0: 0x405b800000000000 (gdb) x/f 0x7fff84af3ae0 0x7fff84af3ae0: 110 (gdb) x/i 0x00000000004005ea => 0x4005ea <main+102>: movsd %xmm0,-0x20(%rbp) (gdb) x/i 0x00000000004006aa 0x4006aa <fib+138>: movsd %xmm0,-0x10(%rbp) S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 16 / 33
  • 18. Basic GDB Commands - info registers I (gdb) info reg rsp rsp 0x7fff84af3ab0 0x7fff84af3ab0 (gdb) info reg rip rip 0x4005ea 0x4005ea <main+102> (gdb) info reg rax rax 0xb800000000000 3236962232172544 (gdb) info reg rax 0xb800000000000 3236962232172544 rbx 0x0 0 rcx 0x0 0 rdx 0x405b800000000000 4637440978796412928 rsi 0xfffff00000000 4503595332403200 rdi 0x7fff84af3a50 140735419464272 rbp 0x7fff84af2fc0 0x7fff84af2fc0 rsp 0x7fff84af2fb0 0x7fff84af2fb0 r8 0x0 0 r9 0x0 0 r10 0x2 2 r11 0x7fff84af39a8 140735419464104 r12 0x4004a0 4195488 r13 0x7fff84af3bd0 140735419464656 r14 0x0 0 r15 0x0 0 rip 0x40065e 0x40065e <fib+62> S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 17 / 33
  • 19. Basic GDB Commands - info registers II eflags 0x203 [ CF IF ] cs 0x33 51 ss 0x2b 43 ds 0x0 0 es 0x0 0 fs 0x0 0 gs 0x0 0 S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 18 / 33
  • 20. Basic GDB Commands - disassemble I (gdb) disassemble Dump of assembler code for function fib: 0x0000000000400620 <+0>: push %rbp 0x0000000000400621 <+1>: mov %rsp,%rbp 0x0000000000400624 <+4>: sub $0x10,%rsp 0x0000000000400628 <+8>: movsd %xmm0,-0x8(%rbp) 0x000000000040062d <+13>: xorpd %xmm0,%xmm0 0x0000000000400631 <+17>: ucomisd -0x8(%rbp),%xmm0 0x0000000000400636 <+22>: jne 0x400643 <fib+35> 0x0000000000400638 <+24>: jp 0x400643 <fib+35> 0x000000000040063a <+26>: xorpd %xmm0,%xmm0 0x000000000040063e <+30>: jmpq 0x4006ca <fib+170> 0x0000000000400643 <+35>: movsd 0x1cd(%rip),%xmm0 # 0x400818 0x000000000040064b <+43>: ucomisd -0x8(%rbp),%xmm0 0x0000000000400650 <+48>: jne 0x40065e <fib+62> 0x0000000000400652 <+50>: jp 0x40065e <fib+62> 0x0000000000400654 <+52>: movsd 0x1bc(%rip),%xmm0 # 0x400818 0x000000000040065c <+60>: jmp 0x4006ca <fib+170> => 0x000000000040065e <+62>: movsd 0x2009e2(%rip),%xmm0 # 0x601048 <i> 0x0000000000400666 <+70>: ucomisd 0x1b2(%rip),%xmm0 # 0x400820 0x000000000040066e <+78>: jne 0x400694 <fib+116> 0x0000000000400670 <+80>: jp 0x400694 <fib+116> 0x0000000000400672 <+82>: xorpd %xmm0,%xmm0 0x0000000000400676 <+86>: ucomisd -0x8(%rbp),%xmm0 0x000000000040067b <+91>: jne 0x400694 <fib+116> 0x000000000040067d <+93>: jp 0x400694 <fib+116> 0x000000000040067f <+95>: movsd 0x2009c1(%rip),%xmm0 # 0x601048 <i> 0x0000000000400687 <+103>: divsd -0x8(%rbp),%xmm0 S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 19 / 33
  • 21. Basic GDB Commands - disassemble II 0x000000000040068c <+108>: movsd %xmm0,0x2009ac(%rip) # 0x601040 <k> 0x0000000000400694 <+116>: movsd -0x8(%rbp),%xmm0 0x0000000000400699 <+121>: movsd 0x177(%rip),%xmm1 # 0x400818 0x00000000004006a1 <+129>: subsd %xmm1,%xmm0 0x00000000004006a5 <+133>: callq 0x400620 <fib> 0x00000000004006aa <+138>: movsd %xmm0,-0x10(%rbp) 0x00000000004006af <+143>: movsd -0x8(%rbp),%xmm0 0x00000000004006b4 <+148>: movsd 0x16c(%rip),%xmm1 # 0x400828 0x00000000004006bc <+156>: subsd %xmm1,%xmm0 0x00000000004006c0 <+160>: callq 0x400620 <fib> 0x00000000004006c5 <+165>: addsd -0x10(%rbp),%xmm0 0x00000000004006ca <+170>: leaveq 0x00000000004006cb <+171>: retq End of assembler dump. S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 20 / 33
  • 22. Basic GDB Commands - list I (gdb) l 11 // strcpy(end, argv[1]); 12 a = strtod(argv[1], &g); 13 b = strtod(argv[2], &h); 14 15 x = fact(a); 16 y = fib(b); 17 18 printf("%f! = %fnfib(%f) = %fn", a, x, b, y); 19 exit(0); 20 } (gdb) l - 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include "multi.h" 5 6 int main(int argc, char *argv[]) 7 { 8 double a, b, x, y; 9 char *g, *h; 10 (gdb) l fact 4 * 5 */ 6 #include "multi.h" 7 8 double fact(double n) S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 21 / 33
  • 23. Basic GDB Commands - list II 9 { 10 if (n == 0) 11 return 1; 12 return n * fact(n - 1); 13 } (gdb) l multi0.c:5 1 /* 2 * 3 * multi0.h - Example for calculating fibonacci numbers. 4 * 5 */ 6 #include "multi.h" 7 8 double fib(double n) 9 { 10 if (n == 0) S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 22 / 33
  • 24. Analyzing the Collected Information Start with backtrace Observe using print and x Compare inputs and outputs of each frame Use list and disassemble to follow the flow Note where things don’t match up to the source code S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 23 / 33
  • 25. Postgres Core Dumps Specifics I Core dump will only contain information from one process not all Core dump contains shared memory areas (gdb) p AutoVacuumShmem $3 = (AutoVacuumShmemStruct *) 0x7fd47aee3388 (gdb) p *AutoVacuumShmem $4 = {av_signal = {0, 0}, av_launcherpid = 1348, av_freeWorkers = {head = { prev = 0x7fd47aee33c0, next = 0x7fd47aee3430}}, av_runningWorkers = { head = {prev = 0x7fd47aee33a8, next = 0x7fd47aee33a8}}, av_startingWorker = 0x0} Global variables will allow easier access to status Logs may provide more context S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 24 / 33
  • 26. Case Study I This is a case study of a Postgres process that was killed intentionally. In this case, it is hypothetically assumed that a client connection is unresponsive. Use ps to find process $ ps -ef ... pgcon 2625 1343 0 06:02 ? 00:00:00 postgres: pgcon postgres [local] ... Kill the process $ kill -6 2625 Start GDB S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 25 / 33
  • 27. Case Study II /var/postgres$ gdb ~/postgresql/src/backend/postgres -c core GNU gdb (Ubuntu 7.7-0ubuntu3) 7.7 ... Core was generated by ‘postgres: pgcon postgres [local] idle ’. Program terminated with signal SIGABRT, Aborted. #0 0x00007fd47b38821d in __libc_recv (fd=9, buf=buf@entry=0xb12560 <PqRecvBuffer>, n=n@entry=8192, flags=-1, flags@entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:29 29 ../sysdeps/unix/sysv/linux/x86_64/recv.c: No such file or directory. (gdb) Look at the stacktrace (gdb) bt #0 0x00007fd47b38821d in __libc_recv (fd=9, buf=buf@entry=0xb12560 <PqRecvBuffer>, n=n@entry=8192, flags=-1, flags@entry=0) at ../sysdeps/unix/sysv/linux/x86_64/recv.c:29 #1 0x000000000059b583 in recv (__flags=0, __n=8192, __buf=0xb12560 <PqRecvBuffer>, __fd=<optimized out>) at /usr/include/x86_64-linux-gnu/bits/socket2.h:44 #2 secure_read (port=0xf21360, ptr=0xb12560 <PqRecvBuffer>, len=8192) at be-secure.c:304 #3 0x00000000005a2f0b in pq_recvbuf () at pqcomm.c:854 #4 0x00000000005a3a65 in pq_getbyte () at pqcomm.c:895 #5 0x000000000064577a in SocketBackend (inBuf=0x7fffd21495c0) at postgres.c:344 #6 ReadCommand (inBuf=0x7fffd21495c0) at postgres.c:492 #7 PostgresMain (argc=<optimized out>, argv=argv@entry=0xf021a8, dbname=0xf02058 "postgres", username=<optimized out>) at postgres.c:3958 S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 26 / 33
  • 28. Case Study III #8 0x000000000045a487 in BackendRun (port=0xf21360) at postmaster.c:3996 #9 BackendStartup (port=0xf21360) at postmaster.c:3685 #10 ServerLoop () at postmaster.c:1586 #11 0x0000000000606df5 in PostmasterMain (argc=argc@entry=3, argv=argv@entry=0xf00f40) at postmaster.c:1253 #12 0x000000000045adbb in main (argc=3, argv=0xf00f40) at main.c:206 (gdb) Inspect a few frames (gdb) f 8 #8 0x000000000045a487 in BackendRun (port=0xf21360) at postmaster.c:3996 3996 PostgresMain(ac, av, port->database_name, port->user_name); (gdb) p port->database_name $2 = 0xf02058 "postgres" (gdb) p port->user_name $3 = 0xf02040 "pgcon" (gdb) p *port $4 = {sock = 9, noblock = 0 ’000’, proto = 196608, laddr = {addr = { ss_family = 1, __ss_align = 3336130842095267443, __ss_padding = "5432", ’000’ <repeats 107 times>}, salen = 21}, raddr = {addr = {ss_family = 1, __ss_align = 0, __ss_padding = ’000’ <repeats 111 times>}, salen = 2}, remote_host = 0xf1e770 "[local]", remote_hostname = 0x0, remote_hostname_resolv = 0, remote_port = 0xf1e690 "", canAcceptConnections = CAC_OK, database_name = 0xf02058 "postgres", user_name = 0xf02040 "pgcon", cmdline_options = 0x0, guc_options = 0xf020c8, hba = 0xf237f0, md5Salt = "#230", <incomplete sequence 352240>, SessionStartTime = 453992550897907, default_keepalives_idle = 0, S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 27 / 33
  • 29. Case Study IV default_keepalives_interval = 0, default_keepalives_count = 0, keepalives_idle = 0, keepalives_interval = 0, keepalives_count = 0, gss = 0x0} (gdb) p *inBuf $6 = {data = 0xfafc90 "", len = 0, maxlen = 1024, cursor = 0} S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 28 / 33
  • 30. Advanced Topics Below are some topics to research afterwards For Extensions, load “symbols” using add-symbol-file in GDB Future feature enhancement to generate a core dump containing all of the running threads Determine which global variables are useful S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 29 / 33
  • 31. Conclusions What a core dump is How to ensure a core dump gets generated Basic GDB usage Tips for understanding output from GDB Techniques for Postgres Core Dumps Case Study S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 30 / 33
  • 32. Questions? S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 31 / 33
  • 33. References Debugging with GDB http://bit.ly/1o56H1z GDB Reference Card http://bit.ly/1lOZzBz Matloff,Norman and Peter Jay Salzman. 2008. The Art of Debugging with Gdb, Ddd, and Eclipse. No Starch Press, San Francisco, CA, USA. Momjian, Bruce. Inside PostgreSQL Shared Memory http://momjian.us/main/writings/pgsql/inside_ Krosing, Hannu and Kirk Roybal. 2013. PostgreSQL Server Programming. Packt Publishing, Birmingham, U.K. S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 32 / 33
  • 34. Contact Information E-mail: fakber@vmware.com IRC: In #postgresql on Freenode as sfa Twitter: @vCoreDump S. F. Akber (VMware, Inc.) How to Inspect Postgres Core Dumps 2014-05-23 33 / 33