> First and foremost is to define what an orphaned transaction is. At > this stage, I believe any prepared transaction that has been there > for more than X time may be considered as an orphan. X may be defined > as an integer in seconds (a GUC perhaps). May be there are better > ways to define this. Please feel free to chime in.
What about specifying a timeout when starting the prepared transaction? I can imagine situations where a timeout of hours might be needed/anticipated (e.g. really slow external systems) and situations where the developer knows that the other systems are never slower than a few seconds. Something like: prepare transaction 42 timeout interval '2 days'; or prepare transaction 42 timeout interval '30 second'; Or maybe even with a fixed timestamp instead of an interval? prepare transaction 42 timeout timestamp '2020-01-30 14:00:00'; Thomas