Re: Feature suggestions: "dead letter"-savepoint. - Mailing list pgsql-hackers

From Marko Tiikkaja
Subject Re: Feature suggestions: "dead letter"-savepoint.
Date
Msg-id 3612e660-add2-6541-5fe9-25fe9bd6d162@joh.to
Whole thread Raw
In response to Feature suggestions: "dead letter"-savepoint.  (Terje Elde <terje@elde.net>)
Responses Re: Feature suggestions: "dead letter"-savepoint.  (Terje Elde <terje@elde.net>)
List pgsql-hackers
On 2016-06-23 12:34, Terje Elde wrote:
> Typically the flow would be something like:
>
> BEGIN;
> SELECT id FROM targets WHERE status=‘scheduled’ FOR UPDATE SKIP LOCKED LIMIT 1;
> UPDATE targets SET status=‘in-flight’ WHERE id =%(id);
> COMMIT;
> — Do the work.
> BEGIN;
> UPDATE targets SET status=‘completed’ WHERE id = %(id); — or status=‘failed-foo’, if it fails for reason foo
> COMMIT;
>
>
> What I’m suggesting would be something along the lines of;
>
> BEGIN;
> SELECT id FROM targets WHERE status=‘scheduled’ FOR UPDATE SKIP LOCKED LIMIT 1;
> UPDATE targets SET status=‘failed-unknown’ WHERE id =%(id);
> SAVEPOINT deadletter ON FAILURE COMMIT;
> — Do the work.
> UPDATE targets SET status=‘completed’ WHERE id = %(id); — or status=‘failed-foo'
> COMMIT;

Comparing these two; how is the latter any better?  It's the same number 
of commands, except it's holding a transaction open for longer, it's 
using a non-standard concept and it's arguably more complex.


.m



pgsql-hackers by date:

Previous
From: Terje Elde
Date:
Subject: Feature suggestions: "dead letter"-savepoint.
Next
From: alain radix
Date:
Subject: Re: Requesting external_pid_file with postgres -C when not initialized lead to coredump