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 1jgvYb-0002Rm-07 for pgsql-general@arkaria.postgresql.org; Thu, 04 Jun 2020 19:29:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jgvYZ-0002dP-Is for pgsql-general@arkaria.postgresql.org; Thu, 04 Jun 2020 19:29:39 +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 1jgvYY-0002dI-JN for pgsql-general@lists.postgresql.org; Thu, 04 Jun 2020 19:29:39 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jgvYR-0003II-N9 for pgsql-general@lists.postgresql.org; Thu, 04 Jun 2020 19:29:37 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 9E5F55C018F; Thu, 4 Jun 2020 15:29:30 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 04 Jun 2020 15:29:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=C 6GZgvL9YIYe5TgVY1rfHQ2dyj2P/SGGIbKg8wIZfJI=; b=klna753DGONSKCD0D jGFrfN7Z2Q4OLy8Op/k60ruo/pk6h4meHP0MD56fMqgjJ0Cb6vvC1dHtMeDsE4EC jQiGiDJ89yFwqMNlITrSwY9/XVfwTZM8SK9Dpvi1wLdrtt1p239lhtDoMJgN3c9a ouzxrb/T9hvdKQmsazCluhM8uaQC4Cf2+6wblnZKLpfWiRb/c3NgQ2cXN/ftsXxi zS6twGpR+HfUADDGypoBDeXVp1GT5S/0nFS2DwlAp4SmHhm+TRbLGuSewWQRqhtP bHmPMYTIUKnABl3nMf516mwpXfbhRnFr/Lkj5huOcWijrybxtmvz8kByAKQlDdKH LflXA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=C6GZgvL9YIYe5TgVY1rfHQ2dyj2P/SGGIbKg8wIZf JI=; b=kpA6Fu8DhvVU2SqyNsokv1oNuLngPoqu65mwJtAgfnpucNz04AsrW/O1J J7E/S0jlZG7UUY9L9/YPCIRHjA9gyM+Jhs9fKiPiuongnR5SO6cTsQv2NKjY4fhw fedHBksmcI7H7ckpE9sFmNlAFCA+/PPblmzTeGJ1ucVYUUkm+kF9NYzGFRoCTvDp WD8BsFwqUeDIOVa1eftGx2yvY3bGVOrZPT7xXmiop5g5Dhxj2LCs3CCZZhJgrvGq r3NA+wFcXpD2NS589TD3jwOKq+zO7bReYfAa4ZJoBCAXwhUbosaIHFKatvZmK7xQ u34EuD9yT9Bfgen34DaUBID1fl0nQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeguddguddvlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesth ejredttdefjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdr khhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeevteejtd eikeetfefhhffhteelvdekffevudegjeeukefhgfdvieeliedtkeevhfenucffohhmrghi nhepphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejhedrudejvddrhedrvdefudenuc evlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgr nhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id EDF783280068; Thu, 4 Jun 2020 15:29:29 -0400 (EDT) Subject: Re: Monitoring for long running transactions To: Samuel Smith , pgsql-general References: From: Adrian Klaver Message-ID: Date: Thu, 4 Jun 2020 12:29:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6/4/20 10:00 AM, Samuel Smith wrote: > We had a customer complaining of random data loss for the last 6 months > or so. We eventually tracked it down to a combination of bad coding and > a couple of bugs with the ORM. Basically, 'BEGIN' was being emitted by > the web app when viewing a certain page and 'COMMIT' was never emitted > after that. So once the app would get restarted, all data changes would > be lost. Definitely worst case scenario. > > So the question is, what is the best way to monitor for this scenario > going forward? Are there any plugins or community recommended scripts > already made? https://www.postgresql.org/docs/12/monitoring-stats.html#PG-STAT-ACTIVITY-VIEW " state text Current overall state of this backend. Possible values are: active: The backend is executing a query. idle: The backend is waiting for a new client command. idle in transaction: The backend is in a transaction, but is not currently executing a query. idle in transaction (aborted): This state is similar to idle in transaction, except one of the statements in the transaction caused an error. fastpath function call: The backend is executing a fast-path function. disabled: This state is reported if track_activities is disabled in this backend. " > > Regards, > > > > -- Adrian Klaver adrian.klaver@aklaver.com