Author Topic: postgresql replicate log make disk full and how to drop  (Read 1940 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
postgresql replicate log make disk full and how to drop
« on: สิงหาคม 19, 2020, 08:57:52 PM »
=== Rootclause  :  PostgreSQL v10 and v11
 ===check replicate log make disk full
 postgres=> select slot_name, pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(),restart_lsn)) as replicationSlotLag, active from pg_replication_slots;

            slot_name             | replicationslotlag | active
----------------------------------+--------------------+--------
 re_sub                | 64 MB              | t
 replication_slot1  | 904 GB             | f
 replication_slot2  | 904 GB             | f

(3 rows)

เราสามารถทำการ drop slot ที่กินพื้นที่ได้ ดังนี้
postgres=# SELECT pg_drop_replication_slot('replication_slot1');
postgres=# SELECT pg_drop_replication_slot('replication_slot2');

แล้วทำการปรับ purge delete log จาก default 3 วัน (4320minute) เป็น 1 วัน (1440minute)ได้ครับ
rds.log_retention_period = 1440
แล้วทำการ  restart service 1 ทีครับ