Re: how to serialize insert followed by read(select) by different clients

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: how to serialize insert followed by read(select) by different clients
Дата
Msg-id 21823.1470584598@sss.pgh.pa.us
обсуждение исходный текст
Ответ на how to serialize insert followed by read(select) by different clients  (Sandeep Gupta <gupta.sandeep@gmail.com>)
Ответы Re: how to serialize insert followed by read(select) by different clients
Список pgsql-general
Sandeep Gupta <gupta.sandeep@gmail.com> writes:
>  First program, lets say the writer, (using psql) appends to a table
> in the  database.
>  Second program, the reader, (python using alchemy) reads the data.
>  This happens in loop, one for each day.The programs are fired in that order
>  and the first program always commits after it inserts new rows.

>  The problem is that the second program does not see the updates of the first
> program consistently.

There are only two possible explanations for that:

1. The writer isn't actually issuing a COMMIT when you think it is.

2. The reader is using a stale snapshot, ie it's using SERIALIZABLE
or REPEATABLE READ transaction mode and its transaction started before
the writer committed.

If you're having trouble identifying the cause of the problem you
might try setting "log_statement = all" and looking at where BEGINs
and COMMITs get issued.

(Well, I guess that only exhausts the possibilities as long as this is
happening on a single database server.  If the reader is reading from
a hot-standby slave then replication delays might explain your problem.
But that would be a rather material omission of facts.)

            regards, tom lane


В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Should a DB vacuum use up a lot of space ?
Следующее
От: Philippe Girolami
Дата:
Сообщение: Re: Should a DB vacuum use up a lot of space ?