From: Samuel Smith <pgsql@net153.net>
To: pgsql-general@lists.postgresql.org
Subject: Re: Monitoring for long running transactions
Date: Thu, 4 Jun 2020 14:59:51 -0500
Message-ID: <920bb4ce-6ba8-2888-6239-52a15474fc58@net153.net> (raw)
In-Reply-To: <d2b17c01-bde0-7860-80d0-753d5c99a602@aklaver.com>
References: <d2f5ded1-7820-e25f-2477-403283fbb2d0@net153.net>
<d2b17c01-bde0-7860-80d0-753d5c99a602@aklaver.com>
On 6/4/20 2:29 PM, Adrian Klaver wrote:
> 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,
>>
>>
>>
>>
>
>
Sorry, I should have clarified that I was aware of the pg_stat_activity
table. That is how we found the problem in the first place. And yes I
could just write a bash script and run it in cron. I just didn't know if
there was a more "official" way to go about this since it is probably a
common monitoring point and/or if something like this was already made.
Regards,
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: pgsql@net153.net
Subject: Re: Monitoring for long running transactions
In-Reply-To: <920bb4ce-6ba8-2888-6239-52a15474fc58@net153.net>
References: <d2f5ded1-7820-e25f-2477-403283fbb2d0@net153.net> <d2b17c01-bde0-7860-80d0-753d5c99a602@aklaver.com> <920bb4ce-6ba8-2888-6239-52a15474fc58@net153.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox