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 1m4Q7s-0003wl-CP for pgsql-general@arkaria.postgresql.org; Fri, 16 Jul 2021 15:51:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m4Q7r-00027U-4r for pgsql-general@arkaria.postgresql.org; Fri, 16 Jul 2021 15:51:43 +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 1m4Q7q-00027L-Pv for pgsql-general@lists.postgresql.org; Fri, 16 Jul 2021 15:51:42 +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 1m4Q7o-0004aU-6E for pgsql-general@postgresql.org; Fri, 16 Jul 2021 15:51:41 +0000 Received: by mail-ej1-x629.google.com with SMTP id nd37so15850545ejc.3 for ; Fri, 16 Jul 2021 08:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=TGPNLxBgQfhZEf55bgdiMJPinhPi84+X71QEfGRuEWM=; b=oz5lqkuNf/06+zPT/+h20fcJK1FMQjrDoTdz66/Av74SePauIVrJbTMmOCptmbgfZD fmy3xqpcRSQTNdV0dj/PP859qtYYcl7K0wVkbGxfSJPTDC3ke1mdH1ipZFhk+I7dz81i byKRQiR0YVNSRnlDFr4yGLsySN51jA7gZV4PTQCdxHH/lz++7erAAN52sU7KVbtinEh4 zq1oYAEvt5Xc/SDw2B8e/Jn+COxEz+tbHSW0Cybb97Jx4dTQ0YopTOBmvOwHmUFmcM94 aK/Q8Gk17jLDLvXpWIJhJ55bPGmHCaW+huZDa0Yw5dr8Q8OXxw7MJdkb3+luf/vYHqK8 hjYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=TGPNLxBgQfhZEf55bgdiMJPinhPi84+X71QEfGRuEWM=; b=b/b2MzMCE8XU6B1Tkj2r/zuZqciqW8FGGpRdHoPvavOPWeUsaGkzEYdQos+dF/v0Mw sxRETb1QYNPDE/7RY1YMTRLT8RbG9mIdTC8tgwXFkRdXQNyfJGUc85uoR13URajWeLk3 GOsZLWPqot/tAcamb8FVne+rxbYv+8LrZOVfll6ndCo/1kYBHbRXwaBA9fUQi+eIE31X Z5KuLsAi8ub3xVphPPoDzwsG8V906NLfX07Op16wBL9NCklIyIQIDXhTgqOWrhkSJKAb Qi08NtYwHfo5335Mnpm1FdjcHo7c3URTQvAyO2KSABuSZqwSMim/0o1VsckJ9q0jVbGM MpSQ== X-Gm-Message-State: AOAM533mXTlx2JYS1Si6x/vyhS0aEmiY0sno+k57MCFRt1iUOEKCn5K0 cCoFWCR/23BcWCxkngFW3T4= X-Google-Smtp-Source: ABdhPJzXrmfcNGvnyRa+r7meCR9u0mj/7RmG9BT5qHuj/9pVzUp+tOIhCKCNegsBm9rpH69e4trRlA== X-Received: by 2002:a17:907:724b:: with SMTP id ds11mr12864892ejc.192.1626450698589; Fri, 16 Jul 2021 08:51:38 -0700 (PDT) Received: from smtpclient.apple (ip-94-112-9-129.net.upcbroadband.cz. [94.112.9.129]) by smtp.gmail.com with ESMTPSA id m15sm3894067edp.73.2021.07.16.08.51.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Jul 2021 08:51:37 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\)) Subject: Re: ERROR: cannot freeze committed xmax From: Sasha Aliashkevich In-Reply-To: <202107151341.z63mfqvq3vrs@alvherre.pgsql> Date: Fri, 16 Jul 2021 17:51:36 +0200 Cc: pgsql-general@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <9B3A7380-97C0-4654-A4EA-2D96D0B6BDB4@gmail.com> References: <202107151341.z63mfqvq3vrs@alvherre.pgsql> To: Alvaro Herrera X-Mailer: Apple Mail (2.3654.80.0.2.43) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Alvaro, glad to hear from you! This database is relatevely young, it was initdb'ed about a year ago or = so and it was initially at 10.x. I don't know the exact minor version = but the major version was 10 for sure.=20 The problematic row is actually visible: SELECT COUNT(*) FROM pg_proc WHERE ctid =3D '(75,19)' count=20 ------- 1 (1 row)=20 And it refers to a known custom stored function. Also I'm not sure if I can really skip freezing at this point because = this table is already over autovacuum_freeze_max_age (correct me if I'm = wrong): SELECT age(c.relfrozenxid), s.setting autovacuum_freeze_max_age=20 FROM pg_class c, pg_settings s=20 WHERE c.relname =3D 'pg_proc' AND s.name =3D = 'autovacuum_freeze_max_age'; age | autovacuum_freeze_max_age=20 -----------+--------------------------- 213791108 | 200000000 (1 row) This is a production database which I can not restart at any point = unfortunately, so I can't change the global settings atm. We can sacrifice that function and recreate it, but unfortunately when I = execute DROP it fails with the error: ERROR: could not find tuple for rule 16396 I guess it's because of the broken pages at pg_depend. Do you think it is safe to execute DELETE on the corresponding records = in pr_proc and pro_depend? Would it update the broken xmax? I feel like I'm dealing hear with some sort of data curruption. I recall that few months ago we already had issues with the same = function and view based on it. At that point for some reason it just = stopped working. So we had to DROP and RECREATE it. It fixed the issue, but apparently the data inconsistency stayed on disk = and now we've got to the situation where AUTOVACUUM stopped working and = it makes me really nervous. > On 15 Jul 2021, at 15:41, Alvaro Herrera = wrote: >=20 > One thing I forgot is that these XIDs are fairly old, perhaps dating > back to when this database was freshly initdb'd if there has been no = XID > wraparound. In that case you were probably running a version much = older > than 10.14 when they were written. Do you happen to know when did you > initdb this, with what version, when did you upgrade this to 10.14? > That may help search the commit log for bugfixes that might explain = the > bug. I just remembered this one as my favorite candidate: >=20 > Author: Alvaro Herrera > Branch: master Release: REL_11_BR [d2599ecfc] 2018-05-04 18:24:45 = -0300 > Branch: REL_10_STABLE Release: REL_10_4 [e1d634758] 2018-05-04 = 18:23:58 -0300 > Branch: REL9_6_STABLE Release: REL9_6_9 [3a11485a5] 2018-05-04 = 18:23:30 -0300 >=20 > Don't mark pages all-visible spuriously >=20 > Dan Wood diagnosed a long-standing problem that pages containing = tuples > that are locked by multixacts containing live lockers may = spuriously end > up as candidates for getting their all-visible flag set. This has = the > long-term effect that multixacts remain unfrozen; this may = previously > pass undetected, but since commit XYZ it would be reported as > "ERROR: found multixact 134100944 from before relminmxid = 192042633" > because when a later vacuum tries to freeze the page it detects = that a > multixact that should have gotten frozen, wasn't. >=20 > Dan proposed a (correct) patch that simply sets a variable to its > correct value, after a bogus initialization. But, per discussion, = it > seems better coding to avoid the bogus initializations altogether, = since > they could give rise to more bugs later. Therefore this fix = rewrites > the logic a little bit to avoid depending on the bogus = initializations. >=20 > This bug was part of a family introduced in 9.6 by commit = a892234f830e; > later, commit 38e9f90a227d fixed most of them, but this one was > unnoticed. >=20 > Authors: Dan Wood, Pavan Deolasee, =C3=81lvaro Herrera > Reviewed-by: Masahiko Sawada, Pavan Deolasee, =C3=81lvaro Herrera > Discussion: = https://postgr.es/m/84EBAC55-F06D-4FBE-A3F3-8BDA093CE3E3@amazon.com >=20 >=20 > --=20 > =C3=81lvaro Herrera PostgreSQL Developer =E2=80=94 = https://www.EnterpriseDB.com/ > "El n=C3=BAmero de instalaciones de UNIX se ha elevado a 10, > y se espera que este n=C3=BAmero aumente" (UPM, 1972)