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 1nK1dg-00065Q-A1 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Feb 2022 17:29:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nK1df-0001W3-4V for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Feb 2022 17:29:19 +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 1nK1de-0001Vu-Lw for pgsql-hackers@lists.postgresql.org; Tue, 15 Feb 2022 17:29:18 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nK1db-0001vh-J0 for pgsql-hackers@lists.postgresql.org; Tue, 15 Feb 2022 17:29:17 +0000 Received: by mail-ej1-x629.google.com with SMTP id hw13so17183983ejc.9 for ; Tue, 15 Feb 2022 09:29:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pHYF3v7kdSvs9lpnsz2l83U/7ifTQhkP6IodZmE12PQ=; b=fq8ynKNfHzHVhGyM6C8Fb7ph9KZRIU1/PhCOjW77uUi62OWfpdAAIFtEEXaGiqFcKO llcHBSInkt2QzJpLpuekgFyFUiCK5cYw3A9W0JVH4Gr8z0sA1OCNE54eWbxmhY2FueAd FDQTAq35Y3Bh+V0UN9Z90bsu9Pjv2OVB5RsmI92m7HeQHYAQrA5pCJqdejC9cbDXbpxz B8whX5m1sGR1QjEQM+8w+n5wGoLdRbr5C/OljGjeNtPHjfzRUWkvaSSD6DpDe+a98fkQ qx1mYB+FalyCcXIzkhHbX87Rw7+iLhUm8Tvh89Xt6hcIhRs+RMO3ckfpZmyoVVBqvbGz zACw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pHYF3v7kdSvs9lpnsz2l83U/7ifTQhkP6IodZmE12PQ=; b=zjYbPBh5sAWffEYeyHUfPrXo5djYiWWV7kz4CHA2kuFEmpamLMO/okf9XxD/kpthiE +p5lv09MD2dpbSLDIr2GT4HULtxA7afvHZkNajzK7bIVuXbvSWhB/r1FvnO5Vo+/8GBl MYtRvguV0OC/c4Mq5GAmicOGUqxdI8FotxrPgwdWb2uQt9eHeAylSS6sKFsgd6BD30+O ZS78Q0j/nuRD1zfYcjdRByAwRmoZCG+EJEp3iUBGNT6S44zGDZbD76JUHF0ff8wVJ+fx qbJy7oWx6srQY8IDXiBgAtaf82gXJXhnQjup0aomwetgXaYHZGeEqm1aUHgTDVQ85DLK /GmA== X-Gm-Message-State: AOAM532jjz8h6xIGH78u9G7VZ3+HRXiqAHtTfgFTG1rRuYDPOSfbYsNe MeksHZj1D/G4KYwn9AdAk4iAd8fAsupfpd21eiHIqg== X-Google-Smtp-Source: ABdhPJz4czM7kA7bOv6RULcEi8kAVQVgDkBRP0trwESC6vfIVNjHjjFGnH7jvBaZnvVAf5fyqAg1mgCWcDIPFGk9WEE= X-Received: by 2002:a17:907:72ca:: with SMTP id du10mr99311ejc.101.1644946153863; Tue, 15 Feb 2022 09:29:13 -0800 (PST) MIME-Version: 1.0 References: <20211210015616.o242b4xchhpglfcy@alap3.anarazel.de> <20220203215048.rmwjzixdzaetedxq@alap3.anarazel.de> In-Reply-To: From: Peter Geoghegan Date: Tue, 15 Feb 2022 09:28:47 -0800 Message-ID: Subject: Re: do only critical work during single-user vacuum? To: John Naylor Cc: Andres Freund , Robert Haas , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Feb 14, 2022 at 10:04 PM John Naylor wrote: > Well, the point of inventing this new vacuum mode was because I > thought that upon reaching xidStopLimit, we couldn't issue commands, > period, under the postmaster. If it was easier to get a test instance > to xidStopLimit, I certainly would have discovered this sooner. I did notice from my own testing of the failsafe (by artificially inducing wraparound failure using an XID burning C function) that autovacuum seemed to totally correct the problem, even when the system had already crossed xidStopLimit - it came back on its own. I wasn't completely sure of how robust this effect was, though. > When > Andres wondered about getting away from single user mode, I assumed > that would involve getting into areas too deep to tackle for v15. As > Robert pointed out, lazy_truncate_heap is the only thing that can't > happen for vacuum at this point, and fully explains why in versions < > 14 our client's attempts to vacuum resulted in error. Since the > failsafe mode turns off truncation, vacuum should now *just work* near > wraparound. If there is any doubt, we can tighten the check for > entering failsafe. Obviously having to enter single user mode is horrid. If we can reasonably update the advice to something more reasonable now, then that would help users that find themselves in this situation a great deal. > Now, it's certainly possible that autovacuum is either not working at > all because of something broken, or is not working on the oldest > tables at the moment, so one thing we could do is to make VACUUM [with > no tables listed] get the tables from pg_class in reverse order of > max(xid age, mxid age). That way, the horizon will eventually pull > back over time and the admin can optionally cancel the vacuum at some > point. Since the order is harmless when it's not needed, we can do > that unconditionally. My ongoing work on freezing/relfrozenxid tends to make the age of relfrozenxid much more indicative of the amount of work that VACUUM would have to do when run -- not limited to freezing. You could probably do this anyway, but it's nice that that'll be true. -- Peter Geoghegan