Re: When is newly inserted data visible to another connection? - Mailing list pgsql-general

From fkater@googlemail.com
Subject Re: When is newly inserted data visible to another connection?
Date
Msg-id 20100818125753.GB2581@comppasch2
Whole thread Raw
In response to Re: When is newly inserted data visible to another connection?  (Yeb Havinga <yebhavinga@gmail.com>)
Responses Re: When is newly inserted data visible to another connection?
Re: When is newly inserted data visible to another connection?
List pgsql-general
Yeb Havinga:

> fkater@googlemail.com wrote:

[...]

> > We have done a test with two connections to the database
> > on different computers.  After the first client (writer)
> > had inserted new data into a quite simple table, it told
> > another client (by TCP communication) to be ready,
> > however, this second client (reader) did not see the
> > data then immediately in the database. So we delayed the
> > reading client from 2 to 5s to have it see all data in
> > the table.

> Essential information is missing. Did the first client
> COMMIT before toggling client 2?

Yes, of course, the commit was done before toggling client
2. I would like to mention that the table itself is simple
however contains a bytea column and some of the inserted
rows contain some MBs of binary data which usually take a
while.  But, yes, we trigger client 2 only *after* the
commit was done and returned successfully (using v8.2.4 on
win32 via libpq).

> Also you might find the information from
> http://developer.postgresql.org/pgdocs/postgres/transaction-iso.html
> interesting, since that specifies how to control behaviour
> of concurrent transactions looking at each others data.

Thank you for the interesting link. I think, though, that
this does not address the question why there is a delay
between the point in time A that client 1 has successfully
commited and the point in time B when client 2 can see all
new rows! Even in pure serialization it should be possible
that client 2 can immediately start reading *after* client 1
has completely commited, shouldn't it? FYI: We are using the
default setup for transaction isolation.


> > Secondly: If yes, is there a way to determine when newly
> > inserted data is visible to other clients?
> >
> Not before it is committed. To which clients the just
> committed data is visible depends on the transaction
> isolation level (see link above).

Hm, I do not get it -- AFAIK the article you mentioned deals
with the question what a concurrent transaction can see from
another one which is pending/not committed. But this is not
the case here. The first transaction is commited before.

To sum up our question:

If client 1 has commited some rows, when is the moment that
client 2 can see/read all that data? Do we have to consider
a gap and if yes how to determine it?

Thank You!
 Felix



pgsql-general by date:

Previous
From: Jeremy Palmer
Date:
Subject: Re: Win32 Backend Cash - pre-existing shared memory block is still in use
Next
From: Sergey Sergeev
Date:
Subject: pgsql-general@postgresql.org