Re: [INTERFACES] Proper use of Transactions...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
Cc: Matthew Hagerty <matthew(at)venux(dot)net>, pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] Proper use of Transactions...
Date: 1999-08-09 14:05:20
Message-ID: 23213.934207520@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il> writes:
> I don't think there is damage to the database if a
> transaction is not committed or rolled back before the connection
> terminates - but a guru opinion would have more value than mine.

There is an implicit abort of any transaction-in-progress just before
backend shutdown. The backend's shutdown processing is just about the
same whether it receives an exit command or observes EOF on the client
socket. So a client crash or ungraceful disconnect is no problem: you
will get rolled back.

If you did not issue a BEGIN command, but are simply sending standalone
SQL queries that each implicitly form a transaction, then a disconnect
in the middle of processing a query may or may not cause that query to
be aborted rather than committed. Typically the backend won't notice
your disconnect until it comes back to read another command, so the
current query would get committed (if no error) first. I think there
might be paths where the disconnect would be noticed earlier, however.

Even if the backend itself crashes, an uncommitted transaction will
remain uncommitted, since no entry saying it's committed ever gets
written to pg_log. Any tuples the dead backend did manage to write out
will look like not-yet-committed tuples until the end of time.

BTW, I am not sure whether VACUUM ever realizes it can reclaim those
uncommitted tuples. To do that it'd have to make some kind of
guesstimate that the transaction never is going to be committed.
So you could have some space wastage in the database from a backend
crash.

regards, tom lane

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Vadim Mikheev 1999-08-10 00:50:20 Re: [INTERFACES] Proper use of Transactions...
Previous Message Alex P. Rudnev 1999-08-09 09:43:31 Re: [ANNOUNCE] Re: your mail