Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lK2pY-0001lb-D6 for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 17:41:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lK2pX-00081r-BJ for pgsql-general@arkaria.postgresql.org; Wed, 10 Mar 2021 17:41:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lK2pW-00081k-Up for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 17:41:07 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lK2pR-00057E-Rq for pgsql-general@lists.postgresql.org; Wed, 10 Mar 2021 17:41:05 +0000 Received: by mail-ej1-x62d.google.com with SMTP id dx17so40400887ejb.2 for ; Wed, 10 Mar 2021 09:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=C8wzLqktcFPJx2CiQcrlNmYo6f3bvooroP8M11v5sXg=; b=GWGp+me38qnkulMh/572T3ULT4H2JtBV1VsqAU5tDSoAgGP6ID/SyyfNzaiuoJpTRe 5hRzt4M+0KHsthg9QNzgGaJ2NHiQ2fM5kEfG/CxwBZ4YRwPZpARJzxCCZREF15Uusf2k P4HR7BkOao7XDYe/hoT6yIeFMeQUTZRvhIMEHJG6b0+oPJjSLXLV3YZJseLbsIexSFVe s+UIE/qCskpTeZSMtPuvPJBtKGrxuTNeUb3vh5gJVJ2hqFFT4YRuC5KOnHD0n75kJVAt /icAnijmQVhqulq3vubAc8Ni5x7J0GG7ZqusYme8N6UV+2Lt0PyRTJcH8/PHeNCE7bSc TtKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=C8wzLqktcFPJx2CiQcrlNmYo6f3bvooroP8M11v5sXg=; b=nssbqXPDcgTfMwro8Ecg1FEiG4X+Cb85JdehSFts/aHeMCxF5CZRj3zpuMinmN/FvU +L5G8G59+tBnX3eOA5NrDaI+ZWnvIgFDstp4QX7ELlr/GQJm+ChwXqIHCFBsV6jMr5yF uYwrKCrNq1e8FBs5W00rJD8i+y7c6CCe9HWGS+8FrSZT/V1C83lv3K+VQtANvkrlkQLn cqmOgp8cT4cHAQr6wbDxI5AWsMsgOspqlQ3AQz1hftMZrfGd9GImoW5Nu8NOqmDTAkqq 1pB4nDWTeQWCh3IkdPtOPO7UWoRkK0adZQmhpghzNeXLZZlnKEuc1qWHA4KcXQHlWXIh 9Alw== X-Gm-Message-State: AOAM531okeAkE25dIFSs3cuUJ+ktvkml9zgnpu9N3SdvpILKMhRa/rJ0 vO0DvzdL/RCFoJzobdAZtUkIZQ== X-Google-Smtp-Source: ABdhPJwwskUDU4YQOQ2b3GSaoze2tfxOBh5S6IjIBUTE1Ucwvi9XkEqn+dmEG9xYBgVNz8ObvWkY4Q== X-Received: by 2002:a17:906:1a16:: with SMTP id i22mr4891477ejf.522.1615398059074; Wed, 10 Mar 2021 09:40:59 -0800 (PST) Received: from localhost.localdomain (217-149-172-42.nat.highway.telekom.at. [217.149.172.42]) by smtp.gmail.com with ESMTPSA id i11sm69558ejf.76.2021.03.10.09.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 09:40:58 -0800 (PST) Message-ID: <7eee13c535a2f1de6e8dece0791531f3dc7f2c0e.camel@cybertec.at> Subject: Re: WAL-files is not removing authomaticaly From: Laurenz Albe To: Forum Writer , "pgsql-generallists.postgresql.org" Date: Wed, 10 Mar 2021 18:40:58 +0100 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2021-03-10 at 14:34 +0200, Forum Writer wrote: > Have Streaming replica with 2 hosts, master and slave with PostgreSQL 10.6. > Replica works fine and data from master copying to slave without any problem, > but on slave have a problem: wal-files in catalog ${PGDATA}/pg_wal is not > removing authomaticaly and may be collects over some years. > > Both, master (1.1.1.1) and slave (2.2.2.2), have simmilar replication slots: > > master=# select * from pg_replication_slots; > slot_name | plugin | slot_type | datoid | database | temporary | active | active_pid | xmin | catalog_xmin | restart_lsn | confirmed_flush_lsn > ---------------------+--------+-----------+--------+----------+-----------+--------+------------+------+--------------+-------------+--------------------- > standby_slot | | physical | | | f | t | 1184 | | | 8/1C16C508 | > (1 row) > > and seted in ${PGDATA}/recovery.conf on slave: > > standby_mode = 'on' > primary_conninfo = 'user=pgadmin host=2.2.2.2 port=5432 user=pgadmin sslmode=prefer sslcompression=1' > recovery_target_timeline = 'latest' > trigger_file = 'failover' > restore_command = 'cp /opt/archivelog/%f %p' > archive_cleanup_command = '/usr/pgsql-10/bin/pg_archivecleanup /opt/archivelog %r' > primary_slot_name = 'standby_slot' > > In ${PGDATA}/postgresql.conf on both hosts sets: > > max_wal_size = 8GB > wal_keep_segments = 32 > > But yesterday pg_wal was 16G and had 1018 files inside, thats why there was no other > way except deleting its manualy, but not of all, > just 6 hundreds files, which had modification time before September 2020 except > 000000010000000000000034.00000028.backup. > Trying to rebuild slave from master with: making pg_start_backup, copying ${PGDATA} > files from master to slave (without removing on slave any files in ${PGDATA}), > pg_stop_backup, tunning settings on slave and run it again had no any success, > wal-files still is not removing automaticaly. > Does anybody knows how to fix it ? Never, ever, remove WAL files manually. A crash might render your database unrecoverable. You'll have to figure out what is blocking WAL removal. Are there archive failures reported in "pg_stat_archiver" and the log? You say that replication is working fine, but try SELECT pg_current_wal_lsn(); on the primary and compare that with the "restart_lsn" of the replication slot. Look for strange messages in the log file on both servers. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com