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 1klDRD-0002Iw-4K for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Dec 2020 15:56:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1klDRB-0005tC-BA for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Dec 2020 15:56:01 +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 1klDRA-0005sU-Vr for pgsql-hackers@lists.postgresql.org; Fri, 04 Dec 2020 15:56:01 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1klDR6-0003Ft-5z for pgsql-hackers@lists.postgresql.org; Fri, 04 Dec 2020 15:55:59 +0000 Received: by mail-ed1-x52c.google.com with SMTP id k4so6354969edl.0 for ; Fri, 04 Dec 2020 07:55:55 -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=IOxCDNSFGtVj+p5/URCut2aAziHFHgfREUQek7/IFjo=; b=PRESGbFAteQY2YXj8OyY8QCg/uMf71bQaOI0Dsl000hrP63WHAPFgNyRQmd5+sp/6N S2g1a9Ze9RHBv5RqiU1WvqPoYPSEwBZPy+mKRsVryurnbLiA1ivYJoll+cEcyRA47zK0 7n/wSU/gdY/8roje0Ur10i4sdG8cScPy5ekdA4gZ5Chij3k4pfbPz1N01nN267R5hEdr vIHtEvqew3g87Y+3YRS/UxkD3Te4s4NwO1FIwmwGZyxqG2qp3wrtxXe2aaP3QlOxW4Z0 h7/K+EwCBd0iNWJG6m34WvBaWnRNR2lRCkoy+nysfp0fB6qXPLeNPD5CuOweUbrUZOAT PhaA== 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=IOxCDNSFGtVj+p5/URCut2aAziHFHgfREUQek7/IFjo=; b=gtlfCl5KCVP8TfQhHgqJ8+CN87aBn71hO0e43hF3XOCp31kOry9Sj2TegUgfX4RItV HP9+7JYQ6gDvn2/IBM9SZcdDtZzO6sHg7woHtK3MjvWi8s3/z6F8ZO3a/9KRjam/CF6o 436DWjFNlZtdSR4MX35NB/Lz/llmn6lSLN+cuecEocH5O5jPZV+ANx47Z9wttMdUOttL ONvatWTynDnwnqzE3W1QXtYf1cUqoP0r4YcaRxwu3NZf6ReknfTP4kD2dECWt4i788Gs LVpWzcKA8TFGPvPyl2PAGaKh+1+DZGCFhPWMNV8ZVWYWY8Pr823CKPHm/0fSBLY+2Gd4 Ydvw== X-Gm-Message-State: AOAM5316OOkuWEllHRAL7lVdjh18c7pos7o9u/xIkfzZ40CNaRra8AQv xjSvV/tzJaLl1Yh0DLI0Fyovng== X-Google-Smtp-Source: ABdhPJxlZhjJEO15B0mjZPb9KFjD8JIg7sIX1RlBaJKm/oxh1LhULIc1tyGSJmoOicHcQmHbj23ZJQ== X-Received: by 2002:a50:e60a:: with SMTP id y10mr7893984edm.157.1607097354303; Fri, 04 Dec 2020 07:55:54 -0800 (PST) Received: from localhost.localdomain (217-149-169-75.nat.highway.telekom.at. [217.149.169.75]) by smtp.gmail.com with ESMTPSA id a13sm3644618edb.76.2020.12.04.07.55.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2020 07:55:53 -0800 (PST) Message-ID: <6fac65dcf175175f95d5fb2aeae731b70bec0a58.camel@cybertec.at> Subject: Re: Add session statistics to pg_stat_database From: Laurenz Albe To: Magnus Hagander Cc: Ahsan Hadi , Justin Pryzby , Soumyadeep Chakraborty , Masahiro Ikeda , PostgreSQL Hackers Date: Fri, 04 Dec 2020 16:55:52 +0100 In-Reply-To: <27530e647d14ef49199694ea3c376935fa7285e8.camel@cybertec.at> References: <68050bc3d927050061d0b106905d69b3bb39fed2.camel@cybertec.at> <70a90a9b4a7e1df47ede3b01774608246bd929ee.camel@cybertec.at> <95a4c49710cdf8be220bc8267872b171c2e3f182.camel@cybertec.at> <20201013225548.GQ9241@telsasoft.com> <9e1c7bf4a654e50973b1be7770dda31431538351.camel@cybertec.at> <2099659e5d679d070f0bb2edb573f296f3c9813f.camel@cybertec.at> <27530e647d14ef49199694ea3c376935fa7285e8.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 2020-12-03 at 13:22 +0100, Laurenz Albe wrote: > > Basically, that would change pgStatSessionDisconnectedNormally into instead being an > > enum of reasons, which could be normal disconnect, abnormal disconnect and admin. > > And we'd track all those three as separate numbers in the stats file, meaning we could > > then calculate the crash by subtracting all three from the total number of sessions? > > I think at least "closed by admin" might be interesting; I'll have a look. > I don't think we have to specifically count "closed by normal disconnect", because > that should be the rule and could be more or less deduced from the other numbers > (with the uncertainty mentioned above). > > > (Let me know if you think the idea could work and would prefer it if I worked up a > > complete suggestion based on it rather than just spitting ideas) > > Thanks for the offer, and I'll get back to it if I get stuck. Ok, I could use a pointer. I am considering the cases 1) client just went away (currently "aborted") 2) death by FATAL error 3) killed by the administrator (or shutdown) What is a good place in the code to tell 2) or 3) so that I can set the state accordingly? Yours, Laurenz Albe