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 1lpdtK-0007CB-84 for pgsql-bugs@arkaria.postgresql.org; Sat, 05 Jun 2021 21:31:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lpdtJ-00011e-27 for pgsql-bugs@arkaria.postgresql.org; Sat, 05 Jun 2021 21:31:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lpdtI-00011W-Rf for pgsql-bugs@lists.postgresql.org; Sat, 05 Jun 2021 21:31:36 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lpdtG-0005Mh-Li for pgsql-bugs@lists.postgresql.org; Sat, 05 Jun 2021 21:31:36 +0000 Received: by mail-pg1-x531.google.com with SMTP id i5so10784628pgm.0 for ; Sat, 05 Jun 2021 14:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=JXG9Ljm66fX01l8gyfyGhXPOHN6JnuJlbCAUffDxBhk=; b=JjqOz025BEmem28FpDWcqCVec+vm+Jjo+BbrjCy5iRMdl8D2o1rsRSuTSz7ocKg1Om ND0vKHp9+td7NG6YVWCLs9j7cs4o7n0rp4KPps7owCZwNw219ULMF+WvV2OgEqK84OGX QFeTeIGFtzgvDlKy8rRyT/fheX4Xmoofw8ye0= 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=JXG9Ljm66fX01l8gyfyGhXPOHN6JnuJlbCAUffDxBhk=; b=C0c+6BHld3o0Fe+DSc+/PpAIv5XYpwI0yapjUGTzm77MJGxdkyn3z0FXjCvv3oNEOP pqJmG/xenC96ReJXFOgRGNiJ+DM/wLG6/MtEpInsLT65RrIdikCvAVz9Te8Z8fZSd4e4 9+yAuAXTfmU6R0z7n+zIBW4CRFJG5/8SemEgTC00xoo/pHYKkLrZEcVSrB0v9i/d/bx1 +lQo5ToJsNX0vrXQbeDICO8z1M/ADQlNyyIxI8ROvlInF+V/tTivor+pAZZ4qzARe1sN ZXI9/D97trFWiUIGOh+kuJI1yMsP5ZvnGVwETFoDQrGYkZ09QImjTTnIuoy7NacJygIQ rxhw== X-Gm-Message-State: AOAM532Dd+6hPZEni/1PLRWdp05YusK9lFAJv4eNBSPih9KnFktv+/hX 8D7OLpFB6Zxu4UnKjlKahKy7AQ== X-Google-Smtp-Source: ABdhPJzQqf9s2N+mrGdlS46/NvoGPXnGc8wmoqAKDAev8UEHlhit+Vne6713QpU4SpoKcAAhkBgJvw== X-Received: by 2002:a62:31c7:0:b029:2e9:2c05:52d3 with SMTP id x190-20020a6231c70000b02902e92c0552d3mr10443387pfx.78.1622928691835; Sat, 05 Jun 2021 14:31:31 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id o20sm7848833pjq.4.2021.06.05.14.31.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Jun 2021 14:31:31 -0700 (PDT) Date: Sat, 5 Jun 2021 14:31:28 -0700 From: Noah Misch To: Tom Lane Cc: Stepan Yankevych , Stepan Yankevych , "sergii.zhuravlev@smartnet.ua" , "pgsql-bugs@lists.postgresql.org" Subject: Re: BUG #16961: Could not access status of transaction Message-ID: <20210605213128.GF228552@rfd.leadboat.com> References: <16961-25f29f95b3604a8a@postgresql.org> <1618416199.969761000.ago134mu@frv53.fwdcdn.com> <20210605205545.GE228552@rfd.leadboat.com> <566324.1622928339@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <566324.1622928339@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Jun 05, 2021 at 05:25:39PM -0400, Tom Lane wrote: > Noah Misch writes: > > On Mon, Apr 19, 2021 at 06:49:15PM +0000, Stepan Yankevych wrote: > >> The issue happening each morning when application starts on the production DataBase during about a month. > >> Always the same transaction id is mentioned in the error (1954017648) > >> We tried to do UNLISTEN - no changes. the same issue. > >> LISTEN works good for any other channels. > > > ... > > On the other hand, if that's what happened, your report that "LISTEN works > > good for any other channels" surprises me. Perhaps something completely > > different happened on your system. > > I suspect the true state of affairs was more like "LISTEN works good in > any other databases". The described symptoms are consistent with there > being a message in the NOTIFY queue that has a pruned-away xid. An > incoming listener would try to scan over already-committed notify > messages, but testing to see whether this stale message is committed > would fail. However, since asyncQueueProcessPageEntries just ignores > messages not targeted for the current database, incoming listeners > in other databases wouldn't notice the problem. > > ISTM the interesting question here is what was holding back truncation > of the NOTIFY queue. Could there have been an open transaction somewhere > that was failing to collect NOTIFY data? Open transactions always decline to collect notify data, don't they? See ProcessNotifyInterrupt(). > But a transaction sitting open > for a month is likely to cause far more severe problems than that one. True. > > We could prevent the trouble if vac_truncate_clog() had access to the oldest > > xid in the notification queue; it would set frozenXID to that value if > > frozenXID would otherwise be older. > > Perhaps. I'm not sure how hard it is to extract the oldest xid in the > queue (where "oldest" is defined as "numerically smallest"). The entries > are in xid commit order which is a different thing. Yeah, it wouldn't be cheap in the general case. The value could be a field in pg_control, updated by a separate VACUUM NOTIFY, which autovacuum would also run roughly as often as autovacuum visits template0.