Documentation should state what happens, when a commit fails

2025-05-28 Thread PG Doc comments form
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/17/sql-commit.html
Description:

Deferrable constraints, deadlocks and possibly other deferred or lazily
evaluated rules are checked upon commit.
What happens if they are not met and the commit statement fails? Does the
transaction then implicitly rollback? Or do I need an explicit rollback?


Re: Documentation should state what happens, when a commit fails

2025-05-28 Thread Laurenz Albe
On Wed, 2025-05-28 at 11:09 -0400, Dave Cramer wrote:
> Somewhat annoying feature of this behaviour is that when COMMIT is issued on 
> an aborted transaction no error is reported.
> Most drivers work around this problem by keeping track of the previous error 
> and reporting an error on the COMMIT.

We have been there before:
https://postgr.es/m/b9fb50dc-0f6e-15fb-6555-8ddb86f4aa71%40postgresfriends.org
Nothing came of that discussion though.

Yours,
Laurenz Albe




Re: Documentation should state what happens, when a commit fails

2025-05-28 Thread David G. Johnston
On Wed, May 28, 2025 at 7:47 AM mark maker  wrote:

> Wow, great improvement, thanks!
>
> The "tutorial-transactions" opens a new question that might be useful to
> know: when a transaction enters the aborted state at an early point in time
> (as has now become clear), does this mean it will also relinquish any locks
> and predicate locks early, or will it still hold onto those until
> explicitly rolled back by command?
>

I suppose if the system knows there are no savepoints in progress it could
release the locks and whatnot...not sure if it knows that and acts upon
that knowledge if it does.  Easy enough to test with two psql sessions if
you want to give it a go before I or someone else gets around to it.

David J.


Re: Documentation should state what happens, when a commit fails

2025-05-28 Thread David G. Johnston
On Wednesday, May 28, 2025, Laurenz Albe  wrote:

> On Wed, 2025-05-28 at 08:08 +, PG Doc comments form wrote:
> > The following documentation comment has been logged on the website:
> >
> > Page: https://www.postgresql.org/docs/17/sql-commit.html
> > Description:
> >
> > Deferrable constraints, deadlocks and possibly other deferred or lazily
> > evaluated rules are checked upon commit.
> > What happens if they are not met and the commit statement fails? Does the
> > transaction then implicitly rollback? Or do I need an explicit rollback?
>
> I think it would be good to mention that a failed COMMIT automatically
> performs a ROLLBACK.  Do you want to suggest a patch?


Feel free to review mine for this topic and suggest additions.

 https://commitfest.postgresql.org/patch/5546/

David J.


logial replication - drop subscription.

2025-05-28 Thread PG Doc comments form
The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/16/sql-droppublication.html
Description:

Hi,
I'm using a lot the logical replication.
I have to do some DDL changes, via an automatic process, on the primary.
That process drop the existing publication, which will stop the
subscription.
I kept the LSN information on the primary, perform the DDL changes on the
replica.
Than I recreate the publication, use the pg_replication_slot_advance using
the savec LSN.
When I re-enable the subscription, I have an error message in the postgres
log saying that the publication doesn't exist. However, it does have the
same name.
Can a note be added on the "DROP PUBLICATION" page to mention that dropping
a publication will compromise the logical replication process event if the
publication is recreated with the same name.
Thanks.


Re: Documentation should state what happens, when a commit fails

2025-05-28 Thread Dave Cramer
On Wed, 28 May 2025 at 10:59, David G. Johnston 
wrote:

> On Wed, May 28, 2025 at 7:47 AM mark maker  wrote:
>
>> Wow, great improvement, thanks!
>>
>> The "tutorial-transactions" opens a new question that might be useful to
>> know: when a transaction enters the aborted state at an early point in time
>> (as has now become clear), does this mean it will also relinquish any locks
>> and predicate locks early, or will it still hold onto those until
>> explicitly rolled back by command?
>>
>
> I suppose if the system knows there are no savepoints in progress it could
> release the locks and whatnot...not sure if it knows that and acts upon
> that knowledge if it does.  Easy enough to test with two psql sessions if
> you want to give it a go before I or someone else gets around to it.
>

Somewhat annoying feature of this behaviour is that when COMMIT is issued
on an aborted transaction no error is reported.
Most drivers work around this problem by keeping track of the previous
error and reporting an error on the COMMIT.
Dave


RE: Documentation should state what happens, when a commit fails

2025-05-28 Thread mark maker

Wow, great improvement, thanks!

The "tutorial-transactions" opens a new question that might be useful to 
know: when a transaction enters the aborted state at an early point in 
time (as has now become clear), does this mean it will also relinquish 
any locks and predicate locks early, or will it still hold onto those 
until explicitly rolled back by command?


_Mark


*From:* David G. Johnston 

*Sent:* Wednesday, May 28, 2025 at 4:04 PM UTC+2

*To:* Laurenz Albe 

*Cc:* m...@makr.zone , pgsql-docs@lists.postgresql.org 



*Subject:* RE: Documentation should state what happens, when a commit fails



On Wednesday, May 28, 2025, Laurenz Albe  wrote:

On Wed, 2025-05-28 at 08:08 +, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/17/sql-commit.html

> Description:
>
> Deferrable constraints, deadlocks and possibly other deferred or
lazily
> evaluated rules are checked upon commit.
> What happens if they are not met and the commit statement fails?
Does the
> transaction then implicitly rollback? Or do I need an explicit
rollback?

I think it would be good to mention that a failed COMMIT automatically
performs a ROLLBACK.  Do you want to suggest a patch?


Feel free to review mine for this topic and suggest additions.

https://commitfest.postgresql.org/patch/5546/

David J.


Re: Documentation should state what happens, when a commit fails

2025-05-28 Thread Laurenz Albe
On Wed, 2025-05-28 at 08:08 +, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
> 
> Page: https://www.postgresql.org/docs/17/sql-commit.html
> Description:
> 
> Deferrable constraints, deadlocks and possibly other deferred or lazily
> evaluated rules are checked upon commit.
> What happens if they are not met and the commit statement fails? Does the
> transaction then implicitly rollback? Or do I need an explicit rollback?

I think it would be good to mention that a failed COMMIT automatically
performs a ROLLBACK.  Do you want to suggest a patch?

Yours,
Laurenz Albe