Question about behavior of snapshot too old feature

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Question about behavior of snapshot too old feature
Date: 2016-10-14 08:10:08
Message-ID: CAD21AoA95eg753tH6E5Bum_7ZxRGAgs12QcvK9DmbRAjqTTPMg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I have a question about behavior of snapshot too old feature.

For example, I set old_snapshot_threshold = 1min and prepare a table
and two terminals.
And I did the followings steps.

1. [Terminal 1] Begin transaction and get snapshot data and wait.
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT * FROM test;

2. [Terminal 2] Another session updates test table in order to make
snapshot dirty.
BEGIN;
UPDATE test SET c = c + 100;
COMMIT;

3. [Terminal 1] 1 minute after, read the test table again in same
transaction opened at #1. I got no error.
SELECT * FROM test;

4. [Terminal 2] Another session reads the test table.
BEGIN;
SELECT * FROM test;
COMMIT;

5. [Terminal 1] 1 minute after, read the test table again, and got
"snapshot error" error.
SELECT * FROM test;

Since #2 makes a snapshot I got at #1 dirty, I expected to get
"snapshot too old" error at #3 where I read test table again after
enough time. But I could never get "snapshot too old" error at #3.
On the other hand, when I set old_snapshot_threshold = 0 I can got the
error at #3.

Is this expected behavior?

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2016-10-14 08:22:10 Re: logical replication connection information management
Previous Message Thomas Kellerer 2016-10-14 08:09:00 Re: proposal: session server side variables