Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tQveJ-0066HP-Al for pgsql-general@arkaria.postgresql.org; Thu, 26 Dec 2024 21:44:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tQveI-004v8i-5V for pgsql-general@arkaria.postgresql.org; Thu, 26 Dec 2024 21:44:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tQveH-004v4d-LE for pgsql-general@lists.postgresql.org; Thu, 26 Dec 2024 21:44:05 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tQve8-001lhs-Uy for pgsql-general@lists.postgresql.org; Thu, 26 Dec 2024 21:44:02 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-21634338cfdso114424225ad.2 for ; Thu, 26 Dec 2024 13:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ardentperf-com.20230601.gappssmtp.com; s=20230601; t=1735249435; x=1735854235; darn=lists.postgresql.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=XlflxfgshdARLlriZwmbqzoC2J3bsn9ZbYKvGqfEn/0=; b=RaM1yRDPiw+XMf3vs6cfVQpvT4/eNHkM23ZpOg9uUmSXk1iNReFafuK1f/e4UNSh1H kzIasmW3VQZJ4LEQEeTWqdEoE0tAFwz42YPg+jfACmrOm86fi94/NSRnvO0cLY1ARXl5 z8DGYQgAYkgHRXUCZA4Z1cZ0Uw1X3QUsGi9uKODsJEvZGoGGivlE2jptvugHI7fX0T7P B3ADX+9pP7BCEz9ZIKpHwooIO2vmaDYA4DDv35kL2NMT0qrJjtqzRnvpA5jiv5KRuaT3 lsr6rVC1mxSs9ZVS05lexS53mmRTet2o6aZvjlap1mmeEEl1zzN3qkmmAtJtytnhLxh5 IWZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735249435; x=1735854235; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XlflxfgshdARLlriZwmbqzoC2J3bsn9ZbYKvGqfEn/0=; b=RC/4RfRKM3C2Tm8/2m2v0/oO0vMRljXz2jTshC05uRKB7NCl4lhSgUfJQbKbJkGVBP W8LP+8LzQzPQV0/48ZabgsAXKdKSlculvcBIS23+2/5XQ6oJXqQMGfV3QuPD/bwZmIgZ FFQ0rAcmgfqUCAQiSkjI4tSo33v4K5eoVsamhyGBHoX7FSkUSzi4CbG06wuDKZF1R+mP /W9ak2B4gqquZS3XU7tTUhRnZt+wZiDvgMobtMTRy/7YKxCxB73egUkGpHEumWFK/FBb rqPw0fZD0FyZDEiDh/z8nyNOKbpCCglHYJ8XOFF2cwbc2wFUViDOgggxGitbzBE4DQDN tR0w== X-Gm-Message-State: AOJu0YzApuJ5EivmXQ9OkowEGJQwHaRJxo7FS+uMxjrNRzGcETFIz9TZ rtUud3yaauyBwweyOyTSyWNb/Iwfa9cYpIxLX0YbfjWqOEVtLgqkltP5TOVqAbGUxhzlYR2O7uX qOg== X-Gm-Gg: ASbGncsikMCO/HA7Y6SiSpM5uXpcFHYWGva3txNIpOR8abMcHFRXGqPcKNiNpDnv/m/ 13NRz37elTWjdR4/zfZP6It6gJtTgRORaqa7TjbbWZ/GkwmH1I53IS9FsnTeM0S//ljEgb8+dYB r4Z812ngouDNKBjg3b7M/QpTUS4U1QQ/UVsYN4oTBl9AQVPEH1CLByomf4JalLTkkdJHsXvWOqi VIB/p93R5sPMukAvE79d9z6zJRLWhRb7irZKRc4dBO8ezlQsWV/rj8kAb6T2oJ/zr6VZx2ROUSh 3qQdsbem/tZU8RFJ0nNi8dFUzw== X-Google-Smtp-Source: AGHT+IE5RVBFQ1Lt9zkzZ4YBj6k7yqblf43E2VS72GQvjwMFOezBbbVA6KZmCoathFzEzivJ1+A4uw== X-Received: by 2002:a05:6a20:9185:b0:1e5:7db5:d6e7 with SMTP id adf61e73a8af0-1e5e083f019mr47706698637.46.1735249435187; Thu, 26 Dec 2024 13:43:55 -0800 (PST) Received: from jeremy-ThinkPad-T430s (97-113-75-71.tukw.qwest.net. [97.113.75.71]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8dbcbbsm13278659b3a.97.2024.12.26.13.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Dec 2024 13:43:54 -0800 (PST) Date: Thu, 26 Dec 2024 13:43:52 -0800 From: Jeremy Schneider To: Will Storey Cc: pgsql-general@lists.postgresql.org Subject: Re: Disabling vacuum truncate for autovacuum Message-ID: <20241226134352.42423ffa@jeremy-ThinkPad-T430s> In-Reply-To: References: <20241226122108.33e906a3@jeremy-ThinkPad-T430s> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 26 Dec 2024 13:24:03 -0800 Will Storey wrote: > My incident was actually not caused by autovacuum. A VACUUM was run > against the primary by a cronjob. A web service running read queries > against hot standbys went down for several minutes as its queries > were stuck in a lock queue. > > ... > > As I recall, I confirmed the cause via query logs. I noticed the > table was vacuumed at the time, which lead me to learning about the > page truncation behaviour. It has been a couple years though. Ah - thanks - this is very helpful. I have also seen issues specifically with hot standbys, which continue holding the exclusive lock even when the primary read-write instance releases the lock. A better solution in my opinion would be to enhance the WAL replay process so that it can somehow temporarily relinquish the exclusive lock under contention, similar to what the primary read-write instance is able to do. This is not an easy enhancement to make. Maybe we'd need the primary to put more information into the WAL than it does today. Maybe we'd need to leverage hot_standby_feedback to enable standbys to signal a primary to release the lock. Anyway thanks for the report - we need people reporting these issues on the lists so that there's a little visibility into the impact. Personally I'm still hesitant about the idea of globally disabling vacuum truncation. That was never the goal of the old_snapshot_threshold feature, interesting that you were able to capitalize on the side-effect. Personally I'd still favor disabling it only on the tables that are both frequently vacuumed and also frequently queried on hot standbys. In a pinch, you could disable it for all tables with a bit of dynamic SQL and ensuring that new tables created in the future include the syntax to disable it too. -Jeremy