Re: [HACKERS] Serialization exception : Who else was involved?

2014-12-30 Thread Olivier MATROT
Indeed, NOTICE is wrong because it would doom the transaction that sets the 
flag if it should be later PREPARED.
I think that reporting the PIDs and the current activity of each process would 
be nice. DeadLoackReport() is using pgstat_get_backend_current_activity() to 
get the process activity.

I'll see what I could come up with.

Thanks,
om

-Message d'origine-
De : Noah Misch [mailto:n...@leadboat.com] 
Envoyé : samedi 27 décembre 2014 10:51
À : Olivier MATROT
Cc : pgsql-hackers@postgresql.org
Objet : Re: Serialization exception : Who else was involved?

On Tue, Dec 02, 2014 at 11:17:43AM +0100, Olivier MATROT wrote:
 Serialization conflict detection is done in 
 src/backend/storage/lmgr/predicate.c, where transactions that are 
 doomed to fail are marked as such with the SXACT_FLAG_DOOMED flag.
  
 I simply added elog(...) calls with the NOTIFY level, each time the 
 flag is set, compiled the code and give it a try.

 I would like to see this useful and simple addition in a future 
 version of PostgreSQL.
 Is it in the spirit of what is done when it comes to ease the work of 
 the developer ?
 May be the level I've chosen is not appropriate ?

I would value extra logging designed to help users understand the genesis of 
serialization failures.  A patch the community would adopt will probably have 
more complexity than your quick elog(NOTICE, ...) addition.  I don't have a 
clear picture of what the final patch should be, but the following are some 
thoughts to outline the problem space.  See [1] for an earlier discussion.
The logging done in DeadLockReport() is a good baseline; it would be best to 
consolidate a similar level of detail and report it all as part of the main 
serialization failure report.  That may prove impractical.  If transaction TA 
marks transaction TB's doom, TA can be long gone by the time TB reports its 
serialization failure.  TA could persist the details needed for that future 
error report, but that may impose costs out of proportion with the benefit.
If so, we can fall back on your original idea of emitting a message in the 
command that performs the flag flip.  That would need a DEBUG error level, 
though.  Sending a NOTICE to a client when its transaction dooms some other 
transaction would add noise in the wrong place.

Thanks,
nm

[1] 
http://www.postgresql.org/message-id/flat/AANLkTikF-CR-52nWAo2VG_348aTsK_+0i=chbpnqd...@mail.gmail.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Serialization exception : Who else was involved?

2014-12-29 Thread Kevin Grittner
Craig Ringer cr...@2ndquadrant.com wrote:

 I don't see how that'd necessarily correctly identify the
 query/queries in the other tx that're involved, though.

 Perhaps I'm thinking in terms of more complicated serialization
 failures?

Yeah, it might be possible to provide useful information about
specific conflicting queries in some cases, but I'm skeptical that
it would be available in the majority of cases.  In most cases you
can probably identify one or two other transactions that are
involved.  In at least some cases you won't even have that.

For one fun case to think about, see this example where a read-only
transaction fails with on conflict with two already-committed
transactions:

https://wiki.postgresql.org/wiki/SSI#Rollover

Also consider when there is a long-running transactions and SSI
falls back to SLRU summarization.

If we can find a way to provide some useful information in some
cases without harming performance, that's fine as long as nobody
expects that it will be available in all cases.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Serialization exception : Who else was involved?

2014-12-27 Thread Noah Misch
On Tue, Dec 02, 2014 at 11:17:43AM +0100, Olivier MATROT wrote:
 Serialization conflict detection is done in
 src/backend/storage/lmgr/predicate.c, where transactions that are doomed
 to fail are marked as such with the SXACT_FLAG_DOOMED flag.
  
 I simply added elog(...) calls with the NOTIFY level, each time the flag
 is set, compiled the code and give it a try.

 I would like to see this useful and simple addition in a future version
 of PostgreSQL.
 Is it in the spirit of what is done when it comes to ease the work of
 the developer ?
 May be the level I've chosen is not appropriate ?

I would value extra logging designed to help users understand the genesis of
serialization failures.  A patch the community would adopt will probably have
more complexity than your quick elog(NOTICE, ...) addition.  I don't have a
clear picture of what the final patch should be, but the following are some
thoughts to outline the problem space.  See [1] for an earlier discussion.
The logging done in DeadLockReport() is a good baseline; it would be best to
consolidate a similar level of detail and report it all as part of the main
serialization failure report.  That may prove impractical.  If transaction TA
marks transaction TB's doom, TA can be long gone by the time TB reports its
serialization failure.  TA could persist the details needed for that future
error report, but that may impose costs out of proportion with the benefit.
If so, we can fall back on your original idea of emitting a message in the
command that performs the flag flip.  That would need a DEBUG error level,
though.  Sending a NOTICE to a client when its transaction dooms some other
transaction would add noise in the wrong place.

Thanks,
nm

[1] 
http://www.postgresql.org/message-id/flat/AANLkTikF-CR-52nWAo2VG_348aTsK_+0i=chbpnqd...@mail.gmail.com


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Serialization exception : Who else was involved?

2014-12-27 Thread Craig Ringer
On 12/02/2014 06:17 PM, Olivier MATROT wrote:

 I was wondering if there was a log level in PostgreSQL that could tell
 me which query was the trigger of a doomed transaction.

It's not necessarily possible to tell which *query* in another
transaction caused the current one to fail. It might not be a single
query in the local session or the other session.

What can be identified is the other transaction ID. If you set
log_line_prefix to include the txid and pid, and you log_statement =
'all', you can examine the logs to see what happened.

I admit it's pretty clumsy. It'd be very nice to provide more
information on the causes of failures - but I suspect doing so
*efficiently*, without making serializable a huge impact on performance,
would be quite challenging.


-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training  Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] Serialization exception : Who else was involved?

2014-12-27 Thread Craig Ringer
On 12/02/2014 06:17 PM, Olivier MATROT wrote:
 Serialization conflict detection is done in
 *src/backend/storage/lmgr/predicate.c*, where transactions that are
 doomed to fail are marked as such with *the SXACT_FLAG_DOOMED* flag.
 
 I simply added elog(...) calls with the NOTIFY level, each time the flag
 is set, compiled the code and give it a try.

I don't see how that'd necessarily correctly identify the query/queries
in the other tx that're involved, though.

Perhaps I'm thinking in terms of more complicated serialization
failures? What sorts of failures are you actually running into?

-- 
 Craig Ringer   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training  Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers