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.89) (envelope-from ) id 1ieShR-0008OE-D9 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Dec 2019 23:44:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ieShO-0007MN-Ud for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Dec 2019 23:44:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieShO-0007MF-Lm for pgsql-hackers@lists.postgresql.org; Mon, 09 Dec 2019 23:44:18 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ieShI-0008Sq-L5 for pgsql-hackers@postgresql.org; Mon, 09 Dec 2019 23:44:18 +0000 Received: by mail-wm1-x342.google.com with SMTP id g206so1210775wme.1 for ; Mon, 09 Dec 2019 15:44:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=dooFaHPHPr7YLPDqg9mLH7V8mt0oXCGxN+y65XHtWy8=; b=ooy0a2iWC4lUmM9dY1He4RArDnaRUaXlzNRidfVq0TIpjCHt6kiW8lZ38iVICCjHCO 8nbV4JzoSNwuVCaTYlC8xheUce8slqcIFWO6yEqN4eDp7WTl0jc0F6X5WdhvvWkFlVin vM8/4RfDtrtRMshBFONchOYsIb2TRcrG1j5BtR1M4gAoNcwlL+MyTsegmD6NQf3WMiDg uHBeiTe1k9I0NJxRQ9naDA77S698CmFyEsDsSTFb5lklVBdbI/9j1g0KU4Z7JRTpf7lC Vhj1dYX8k7lvj+X/l0ww4xiaOUMMPs60FPaDdxKbDBl2SvDT7XRcQr6AuwbF3rLgoMDt 3WXw== 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:subject:message-id:mime-version :content-disposition; bh=dooFaHPHPr7YLPDqg9mLH7V8mt0oXCGxN+y65XHtWy8=; b=AMAfDWGPy6krOxA02GO19iwCDoqvB9lYVgHSHIs0gIZXgUGG69BDkh/M4mFC62IqPw 7gADBpB1SAmDhskJv/3JmetWgnBHde1CKXYFu/EvSANRrmxUQcnCGPi74l4pPnqCNw1A 6gFMwHs7Nd8RuESLTawbo6YLt2QLiBDbmvAm9EwHJfX3D5TJpOt9u8KjRXvyCHMwrvFg 0IR4GngahuYSXLCqaa+MTt9Kp4yhv2X+8lvW0FgTMIvQZ+Ks9R/oCARbzfqPx36Gil0j DJFw7Tg5G0P0SWOer1CW2YKvzNKWijQdUUBaRSALd5lSYBy211q90Q2vs63mByk7vWXi VLUQ== X-Gm-Message-State: APjAAAUSPLNBRzBfqMcr92sZF3v6H1k4YyiSH7GsQ+mHh/fYUDwQFVUY 6ahpOhSQqeApdw5yDqOI5fsZ1F50UNq7PzXX9Di8Jf4MJ+9eHmTx5XpMWCcPp7OwPIGg8CKXUkq 4E8GuG7bmwzA+8g0YlIvcbFgCqbvq5VSIRyWYkBmkeoWxDpN7WzhYAokKBWLv+9EbORcWuu2LC7 89bCckiiZUrjU= X-Google-Smtp-Source: APXvYqwHaUeqYPiTyMDh36UzU1lJzXX34QXFwceQdqhyt8U6/Q/fr+S8ysRT5uPnBFyRxNAWDqlXFw== X-Received: by 2002:a1c:80d4:: with SMTP id b203mr1606971wmd.102.1575935051083; Mon, 09 Dec 2019 15:44:11 -0800 (PST) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id z4sm1063426wme.17.2019.12.09.15.44.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 15:44:10 -0800 (PST) Date: Tue, 10 Dec 2019 00:44:09 +0100 From: Tomas Vondra To: pgsql-hackers@postgresql.org Subject: xact_start for walsender & logical decoding not updated Message-ID: <20191209234409.exe7osmyalwkt5j4@development> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="7c3xbwnoh322btiw" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --7c3xbwnoh322btiw Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Hi, I think there's a minor bug in pg_stat_activity tracking of walsender processes. The issue is that xact_start is only updated at the very beginning when the walsender starts (so it's almost exactly equal to backend_start) and then just flips between NULL and that value. Reproducing this is trivial - just create a publication/subscription with the built-in logical replication, and run arbitrary workload. You'll see that the xact_start value never changes. I think the right fix is calling SetCurrentStatementStartTimestamp() right before StartTransactionCommand() in ReorderBufferCommit, per the attached patch. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --7c3xbwnoh322btiw Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="reorderbuffer-timestamp-fix.patch" diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index 53affeb877..5235fb31b8 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -1554,7 +1554,10 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid, if (using_subtxn) BeginInternalSubTransaction("replay"); else + { + SetCurrentStatementStartTimestamp(); StartTransactionCommand(); + } rb->begin(rb, txn); --7c3xbwnoh322btiw--