Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jEE4s-0003iY-CJ for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Mar 2020 15:24:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jEE4r-0007QK-4J for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Mar 2020 15:24:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jEE4q-0007QD-Jo for pgsql-hackers@lists.postgresql.org; Tue, 17 Mar 2020 15:24:20 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jEE4j-00042N-74 for pgsql-hackers@lists.postgresql.org; Tue, 17 Mar 2020 15:24:19 +0000 Received: by mail-qk1-x743.google.com with SMTP id f3so33108926qkh.1 for ; Tue, 17 Mar 2020 08:24:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YVW14HjBecU0vP+WWIvO95K1jGpCmnv8kFcUa+M7iXA=; b=jDrymMcA8RG0y2HwZZpMvCsiXqf/DM06HuF6YZzlXqOWdogX8qxGNORVJUIzIjp2lT pwT7k0/ilQ6Sz9VAj332BgXpf4pqy2r6WjumLpoVuvy0nxeLTCg6NJkiNl0bFnVnXvF3 Z3oq26+zqRkOtvdGsCp8/b9zc12ZLTbtCBkH2Tew0TzM2NDOBBGyudT7O6la4ucjjpi4 vpKl4iSv7Bgo6rJdEZJ5CEQ+XhgvZ6+JKq4q7JtuJ4e/7yQ2icbbIiedmfa547JjdAGW Wd2xSasNMhclNanrQnDclJ78zlj9bKTolxsCQGLUjnTRNbQxWV+8NCDBUtSB4oqYM7s3 qaqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YVW14HjBecU0vP+WWIvO95K1jGpCmnv8kFcUa+M7iXA=; b=Bd9efWTf8qDJjdlc/UKYUafmMYGQwQnUjsSod66OmZU3dbL6LHJ0bRCGubjxki8XlP g6EeMaRfE0bz3E+toJy/eXXWxdO1ST4cJZFBZmn84GY+as3xoiIrohSo7Yxpsilxbb4u tPlm9M2t2byoyYPLZ79aKQkI0nrmCA8+cioQLkmlwcoXIRTzZilbcBDzTLWlVG57NEel NcZIU6Ocromgig25CCwXpWZOLYSZuXmc/qfvUEjmmAspPR3lvtA41n4KeOhyV7Bh5Q0N NA0UzdRUxOcy1AbbrUSOe2wmOYoVzm2NBz+IpnfQ5xpT8eoI33mQf9euXDQy0sQjxt4V ljPg== X-Gm-Message-State: ANhLgQ0YKNWQhgzm6Tviyz9GDzQQQxND0w05O3KeyFx89XmqaCIlK41X 3CPHl0u8F7Tdyeb7XW+ikFG3Zg== X-Google-Smtp-Source: ADFU+vuVsiK86fHVaIWGioknfNypVT8PZ69HIF9zcxirr9SZSSOtvmkSgckIC+JWIF2xkRuC1SNOdg== X-Received: by 2002:ae9:e88c:: with SMTP id a134mr5507384qkg.183.1584458652126; Tue, 17 Mar 2020 08:24:12 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id e2sm2133317qkb.112.2020.03.17.08.24.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Mar 2020 08:24:10 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id 3227C800CF1; Tue, 17 Mar 2020 10:24:09 -0500 (CDT) Date: Tue, 17 Mar 2020 10:24:09 -0500 From: Justin Pryzby To: Laurenz Albe Cc: Andres Freund , Masahiko Sawada , David Rowley , Tomas Vondra , Amit Kapila , Masahiko Sawada , Darafei =?utf-8?Q?Kom=D1=8Fpa?= Praliaskouski , PostgreSQL Developers , Alvaro Herrera , Michael Banck Subject: Re: Berserk Autovacuum (let's save next Mandrill) Message-ID: <20200317152409.GW26184@telsasoft.com> References: <20200316124713.GH26184@telsasoft.com> <9c9b7d19d17ad5e4e0ee10b8426fa1b78dd24c0a.camel@cybertec.at> <20200316201315.dgkeedl6rp2wdjje@alap3.anarazel.de> <19be41199e7b303bbecc1066bd9f011d95882aa8.camel@cybertec.at> <20200316213459.kh6xln3z35hgjodd@alap3.anarazel.de> <7c132215f0e947af7d9ccb7a340ad6e81b369c24.camel@cybertec.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7c132215f0e947af7d9ccb7a340ad6e81b369c24.camel@cybertec.at> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Mar 17, 2020 at 01:14:02AM +0100, Laurenz Albe wrote: > lazy_check_needs_freeze() is only called for an aggressive vacuum, which > this isn't. > --- a/src/backend/access/heap/vacuumlazy.c > +++ b/src/backend/access/heap/vacuumlazy.c > @@ -1388,17 +1388,26 @@ lazy_scan_heap(Relation onerel, VacuumParams *params, LVRelStats *vacrelstats, > else > { > bool tuple_totally_frozen; > + bool freeze_all; > > num_tuples += 1; > hastup = true; > > + /* > + * If any tuple was already frozen in the block and this is > + * an insert-only vacuum, we might as well freeze all other > + * tuples in that block. > + */ > + freeze_all = params->is_insert_only && has_dead_tuples; > + You're checking if any (previously-scanned) tuple was *dead*, but I think you need to check nfrozen>=0. Also, this will fail to freeze tuples on a page which *could* be oppotunistically-frozen, but *follow* the first tuple which *needs* to be frozen. I think Andres was thinking this would maybe be an optimization independent of is_insert_only (?) > /* > * Each non-removable tuple must be checked to see if it needs > * freezing. Note we already have exclusive buffer lock. > */ > if (heap_prepare_freeze_tuple(tuple.t_data, > relfrozenxid, relminmxid, > - FreezeLimit, MultiXactCutoff, > + freeze_all ? 0 : FreezeLimit, > + freeze_all ? 0 : MultiXactCutoff, > &frozen[nfrozen], > &tuple_totally_frozen)) > + /* normal autovacuum shouldn't freeze aggressively */ > + *insert_only = false; Aggressively is a bad choice of words. In the context of vacuum, it usually means "visit all pages, even those which are allvisible". -- Justin