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 1kxKmn-0008Nc-2i for pgsql-general@arkaria.postgresql.org; Thu, 07 Jan 2021 02:12:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kxKmk-0004r0-Vb for pgsql-general@arkaria.postgresql.org; Thu, 07 Jan 2021 02:12:22 +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 1kxKmk-0004qb-NM for pgsql-general@lists.postgresql.org; Thu, 07 Jan 2021 02:12:22 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kxKmh-0001Zn-Vn for pgsql-general@lists.postgresql.org; Thu, 07 Jan 2021 02:12:22 +0000 Received: by mail-wr1-x436.google.com with SMTP id d13so4077019wrc.13 for ; Wed, 06 Jan 2021 18:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=TpMXFJDdcAAOawpauSbHySm05fHd+sfCdOH92a/RKNE=; b=AlFNwmfxFNj82+eMffw1VXKvld0tQbdbsoy14pl/CBP4PZdyOR7wbopN4p8Lb37Tyd pZN7tCYc+TCeG2xiifRW6zNtPi3rmLR8D1tEx6G8E4SP5cUaQHnUveklp5pSHlDhjRGz BimsPxKNKZjtYR++Mfnuz5yzkMRO0bOW0bHH0iO3kx2p7O842xnPuLuUj/EPG7LBxxw9 cOb+/NU/12Q0rXA3PzOaF8cd39sfaYabYEpIl6pZaOcdYGPYiJIp5ZN6HImG5ogPQTN0 ULT0f9pspJSLB3JIvZ5dcdbvG/UnytrCcCEGdK9SDBTQVLX2UndnOmkP9CwERPHlvMFt bP9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=TpMXFJDdcAAOawpauSbHySm05fHd+sfCdOH92a/RKNE=; b=WsKLpJP7yc+4FFsP0Sm9BNiunJO0u369ec0hpREO3hryc7zT5Ebw4JrYvSl0XBsb0D rp3La0mKToeakmXOr1L51Qvhk+oT4PbMlNnOfmdnFvvuchtpCBzHtAAHqdb+tnMMULka Xgk1ri1Jhtii+kxcwudU7gmhhAOSVzM+FN1MIdRANTj945/+Lw3n2R9zv/asDTvrurJe smox23rdnj5ptN0x7BCmVwZXpnOuePZfJ3Cp2ezQaxyGNQCiTFE4P61kNsfcqnjWWwXN tE+jAJK0J1kG3rGyIkq30cfgUvMkUsUxU3+hvTsP8JmNxebh5CSQeh9rrpai4UQqU0Uz g8VQ== X-Gm-Message-State: AOAM533eaWHR6OXAyRN4eTZ1C49XrPOgCu0JncPCNdiZvXYZfeydblwE E8+Ma5yBUC4w33XOXeHfcRxMmA== X-Google-Smtp-Source: ABdhPJxP30pXrtRM696bP7gYIcm+hONlCRPNSkwUqtWJ+AO1fH0PG9K4cqWPdqy9ua8vddfgebUyBg== X-Received: by 2002:adf:c387:: with SMTP id p7mr6694285wrf.95.1609985537698; Wed, 06 Jan 2021 18:12:17 -0800 (PST) Received: from localhost.localdomain (178-190-179-204.adsl.highway.telekom.at. [178.190.179.204]) by smtp.gmail.com with ESMTPSA id h5sm5551111wrp.56.2021.01.06.18.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 18:12:17 -0800 (PST) Message-ID: <74cc5b09ce921e4f57524ed76265847599dd42fc.camel@cybertec.at> Subject: Re: SQL to query running transactions with subtransactions that exceeds 64 From: Laurenz Albe To: Li EF Zhang Cc: pgsql-general@lists.postgresql.org Date: Thu, 07 Jan 2021 03:12:16 +0100 In-Reply-To: References: <7e49c83b1179e052b415eb0f8f78f5f2c0dec734.camel@cybertec.at> , Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, 2021-01-06 at 11:14 +0000, Li EF Zhang wrote: > When I restart secondary node, it reported > "DEBUG: recovery snapshot waiting for non-overflowed snapshot or until oldest active xid on standby is at least 4739126 (now 1422751) > CONTEXT: WAL redo at 4/741941F8 for Standby/RUNNING_XACTS: nextXid 5137417 latestCompletedXid 5137409 oldestRunningXid 1422751; 17 xacts: 2716862 2721890 4665244 2495592 2289138 5137416 2288820 > 2287653 1422751 4280517 2288510 2287620 3297674 1757103 5137219 3320989 2259670; subxid ovf" > I want to find the oldest running transaction(1422751) using the following SQL. > But it showed that there was no transactions that running more than 5 minutes. > How can I find the oldest running transaction? > > SELECT > pid, > now() - pg_stat_activity.query_start AS duration, > query, > state > FROM pg_stat_activity > WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes'; Use xact_start rather than query_start. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com