Proseslerin İzlenmesi

Linux işletim sistemlerindeki C/C++ debugging aracı “rr” (recort & replay) ile postgres
backend prosesler
izlenebilir.
Postgres’in debugger seçeneği ile kurulmuş olması gerekir (enable-debug kaynak
koddan kurulum adımlarında detay mevcut).

postgres@T470s:~$ rr record -M /pg/home/13.6/bin/postgres \

-D $PGDATA \

--log_line_prefix=”%m %p “ \

--effective_cache_size=1GB \

--random_page_cost=4.0 \

--work_mem=4MB \

--maintenance_work_mem=64MB \

--fsync=off \

--log_statement=all \

--log_min_messages=DEBUG5 \

--max_connections=50 \

--shared_buffers=1024MB

rr: Saving execution to trace directory `/pg/home/.local/share/
rr/postgres-3’.
[rr 28166 1310989] 07:21 28166 DEBUG: pg_toast_6000: vac: 0
(threshold 50), ins: 0 (threshold 1000), anl: 0 (threshold 50)
[rr 28166 1310993] 07:21 28166 DEBUG: pg_toast_2396: vac: 0
(threshold 50), ins: 0 (threshold 1000), anl: 0 (threshold 50)
[rr 28166 1310997] 07:21 28166 DEBUG: pg_toast_3592: vac: 0
(threshold 50), ins: 0 (threshold 1000), anl: 0 (threshold 50)
[rr 28166 1311001] 07:21 28166 DEBUG: pg_toast_6100: vac: 0
(threshold 50), ins: 0 (threshold 1000), anl: 0 (threshold 50)
[rr 28166 1311005] 07:21 28166 DEBUG: pg_toast_1213: vac: 0
(threshold 50), ins: 0 (threshold 1000), anl: 0 (threshold 50)

postgres=# SELECT pg_backend_pid() ;

pg_backend_pid

----------------

29557

postgres=# insert into heartbeat values (now());

[rr 29557 13106] DEBUG: StartTransaction(1) name: unnamed; blockState:
DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0
[rr 29557 13110] LOG: statement: insert into heartbeat values (now());
[rr 29557 13130] DEBUG: CommitTransaction(1) name: unnamed;
blockState: STARTED; state: INPROGRESS, xid/subid/cid: 15764/1/0 (used)
[rr 29552 13156] DEBUG: snapshot of 0+0 running transaction ids (lsn
0/1088E4F0 oldest xid 15765 latest complete 15764 next xid 15765)
[rr 29557 14484] DEBUG: StartTransaction(1) name: unnamed; blockState:
DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0
[rr 29557 14488] LOG: statement: commit ;
[rr 29557 14492] WARNING: there is no transaction in progress
[rr 29557 14496] DEBUG: CommitTransaction(1) name: unnamed;
blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0

CTRL C ile sonlandırılabilir.

ya da

pg_ctl -D /pg/data/13.6/ -l pg.log stop ile sonlandırılabilir.

# Belirli bir event ID’ ye gitmek için

postgres@T470s:~$ rr replay -M -g 29557

# Auto pilot

postgres@T470s:~$ rr replay -M -a &> rr.log

# Detay için

man rr

Loglar, çalıştıran kullanıcının home klasörüne yazılır ($HOME/.local/share/rr/).
Log satıları köşeli parentez ile başlar. İlk numara PID (process ID) , ikinci numara event
numarısıdır.
Replay ile logları tekrar ekrana yazdırmak mümkündür.

# Belirli bir event ID’ ye gitmek için

postgres@T470s:~$ rr replay -M -g 29557

# Auto pilot

postgres@T470s:~$ rr replay -M -a &> rr.log

# Detay için

man rr

postgres@T470s:~$ cd /pg/home/setup/postgresql-13.6

postgres@T470s:~$ make installcheck

…
test tuplesort ... ok 1366 ms
test explain ... ok 218 ms
test event_trigger ... ok 339 ms
test fast_default ... ok 489 ms
test stats ... ok 596 ms

=======================
All 201 tests passed.
=======================

make[1]: Leaving directory ‘/pg/home/setup/postgresql-13.6/src/test/regress’

Postgres rr ile çalıştırıldığında make installcheck ile genel kontrol yapılabilir.
Böylece hangi işlemi ne kadar sürede tamamladığı tespit edilebilir.

Kategori seçin...