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 1la51r-0005v1-Do for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Apr 2021 23:16:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1la51q-000865-CC for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Apr 2021 23:16:06 +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 1la4yi-0003FD-Vk for pgsql-hackers@lists.postgresql.org; Fri, 23 Apr 2021 23:12:52 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1la4yg-0003YS-Od for pgsql-hackers@postgresql.org; Fri, 23 Apr 2021 23:12:51 +0000 Received: by mail-ed1-x534.google.com with SMTP id z5so22629497edr.11 for ; Fri, 23 Apr 2021 16:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xIKykXnvIotBSds9Z8yHPXU2dsR+uXK62nsHp7Ztd3U=; b=txu6RHUmr2IB9TsZhlT0Ci1wrJMneuki7qs1yq3PDO351aY7Z9bXKo5OmOqvAR9tc2 9ZvW1LtYVlHbYW/xzEXBIc+q0UZIlhEloIq6xeHxTaIkv5SCWHOYCBnJ3SoKpA/lYmja 9pklIa1DTlhGWEmxL8u7W+i5joRjafd021IlIxiboIEgFzGBwZxjg737qUmViwZZUW7Z 5el/d3h+yNMcTHapRT0PcJ+W9/tD741wh/TR0Um+ybORBK3I0k7yhscmik8Kx4PvG4uI A7H0UkORcDmMWQxiNe6T1JSEjMpqDKXejD3Dttx9by9eVPWFzywjk5A5bdvdVSOOcdMM 2uIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xIKykXnvIotBSds9Z8yHPXU2dsR+uXK62nsHp7Ztd3U=; b=jL/to2sCVBlEFnNddOyrLoDpAyqT3XZdkx81sHi3A+x6jB/S06UR378CYZkxKJ5p83 DaWLyqa5Rc6kPEeo1oEE8rmwRdHOLMeUaXDA1hFVAGK5DA89L353ZhX5B/72pne3ZAwr zHE5YDcRqqaupCjg3XULZQM1p6tbEDWQyvhCNjPPjOB7q0Ty5zf1GnUBJMn5VkoysI9U QPv0xblKces+OARHp2XY3AJKO3K5H1ZZI58PEEwzapczUshnhRarSHToO79qXjgPWq1N UHiIpf4obuxqGuK1R7pQ6wk0P6kL+O1wQNMbvPCyHfCK/O1vDR1IR+WvaJ10vYPl1YzJ XdbQ== X-Gm-Message-State: AOAM531Lu58YYVXQGoEj3Gh7e/Jk+RnYchGE+eYjxzD3nCP8DRK2PtFU WJY5G3oNVDCv8bYmiq0dy5fK/8TctYFbyvGyTMhBPVWFnBs= X-Google-Smtp-Source: ABdhPJyNxCo/JbqAbCGUYM8+NTu7U5teZTvSoAFBJ4Cn3zVHPouzz9S6bARob2jbYkodvW+W1HirGhzbBQ2Mu4LXt7M= X-Received: by 2002:a05:6402:1d26:: with SMTP id dh6mr7243433edb.341.1619219569016; Fri, 23 Apr 2021 16:12:49 -0700 (PDT) MIME-Version: 1.0 References: <20210423204306.5osfpkt2ggaedyvy@alap3.anarazel.de> In-Reply-To: <20210423204306.5osfpkt2ggaedyvy@alap3.anarazel.de> From: Peter Geoghegan Date: Fri, 23 Apr 2021 16:12:33 -0700 Message-ID: Subject: Re: Testing autovacuum wraparound (including failsafe) To: Andres Freund Cc: 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 Fri, Apr 23, 2021 at 1:43 PM Andres Freund wrote: > I started to write a test for $Subject, which I think we sorely need. +1 > Currently my approach is to: > - start a cluster, create a few tables with test data > - acquire SHARE UPDATE EXCLUSIVE in a prepared transaction, to prevent > autovacuum from doing anything > - cause dead tuples to exist > - restart > - run pg_resetwal -x 2000027648 > - do things like acquiring pins on pages that block vacuum from progressing > - commit prepared transaction > - wait for template0, template1 datfrozenxid to increase > - wait for relfrozenxid for most relations in postgres to increase > - release buffer pin > - wait for postgres datfrozenxid to increase Just having a standard-ish way to do stress testing like this would add something. > 2) FAILSAFE_MIN_PAGES is 4GB - which seems to make it infeasible to test the > failsafe mode, we can't really create 4GB relations on the BF. While > writing the tests I've lowered this to 4MB... The only reason that I chose 4GB for FAILSAFE_MIN_PAGES is because the related VACUUM_FSM_EVERY_PAGES constant was 8GB -- the latter limits how often we'll consider the failsafe in the single-pass/no-indexes case. I see no reason why it cannot be changed now. VACUUM_FSM_EVERY_PAGES also frustrates FSM testing in the single-pass case in about the same way, so maybe that should be considered as well? Note that the FSM handling for the single pass case is actually a bit different to the two pass/has-indexes case, since the single pass case calls lazy_vacuum_heap_page() directly in its first and only pass over the heap (that's the whole point of having it of course). > 3) pg_resetwal -x requires to carefully choose an xid: It needs to be the > first xid on a clog page. It's not hard to determine which xids are but it > depends on BLCKSZ and a few constants in clog.c. I've for now hardcoded a > value appropriate for 8KB, but ... Ugh. > For 2), I don't really have a better idea than making that configurable > somehow? That could make sense as a developer/testing option, I suppose. I just doubt that it makes sense as anything else. > 2021-04-23 13:32:30.899 PDT [2027738] LOG: automatic aggressive vacuum to prevent wraparound of table "postgres.public.small_trunc": index scans: 1 > pages: 400 removed, 28 remain, 0 skipped due to pins, 0 skipped frozen > tuples: 14000 removed, 1000 remain, 0 are dead but not yet removable, oldest xmin: 2000027651 > buffer usage: 735 hits, 1262 misses, 874 dirtied > index scan needed: 401 pages from table (1432.14% of total) had 14000 dead item identifiers removed > index "small_trunc_pkey": pages: 43 in total, 37 newly deleted, 37 currently deleted, 0 reusable > avg read rate: 559.048 MB/s, avg write rate: 387.170 MB/s > system usage: CPU: user: 0.01 s, system: 0.00 s, elapsed: 0.01 s > WAL usage: 1809 records, 474 full page images, 3977538 bytes > > '1432.14% of total' - looks like removed pages need to be added before the > percentage calculation? Clearly this needs to account for removed heap pages in order to consistently express the percentage of pages with LP_DEAD items in terms of a percentage of the original table size. I can fix this shortly. -- Peter Geoghegan