POC and rebased patch for CSN based snapshots

From: Movead Li <movead(dot)li(at)highgo(dot)ca>
To: "pgsql-hackers" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: POC and rebased patch for CSN based snapshots
Date: 2020-05-08 12:43:50
Message-ID: 171f45038c4.bf66538a492783.4211925925146471362@highgo.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello hackers,

I have read the community mail from 'postgrespro' which the link

below ①, a summary for the patch, it generals a CSN by timestamp

when a transaction is committed and assigns a special value as CSN

for abort transaction, and record them in CSN SLRU file. Now we can

judge if a xid available in a snapshot with a CSN value instead of by

xmin,xmax and xip array so that if we hold CSN as a snapshot which

can be export and import.

CSN may be a correct direction and an important part to implement

distributed of PostgreSQL because it delivers few data among cross-nodes

for snapshot, so the patch is meant to do some research.

We want to implement Clock-SI base on the patch.However the patch

is too old, and I rebase the infrastructure part of the patch to recently

commit(7dc37ccea85).

The origin patch does not support csn alive among database restart

because it will clean csnlog at every time the database restart, it works

well until a prepared transaction occurs due to the csn of prepare

transaction cleaned by a database restart. So I add wal support for

csnlog then csn can alive all the time, and move the csnlog clean work

to auto vacuum.

It comes to another issue, now it can't switch from a xid-base snapshot

to csn-base snapshot if a prepare transaction exists because it can not

find csn for the prepare transaction produced during xid-base snapshot.

To solve it, if the database restart with snapshot change to csn-base I

record an 'xmin_for_csn' where start to check with csn snapshot. 

Some issues known about the current patch:

1. The CSN-snapshot support repeatable read isolation level only, we

should try to support other isolation levels.

2. We can not switch fluently from xid-base->csn-base, if there be prepared

transaction in database.

 

What do you think about it, I want try to test and improve the patch step
by step. 

①https://www.postgresql.org/message-id/21BC916B-80A1-43BF-8650-3363CCDAE09C%40postgrespro.ru 

-----------
Regards,

Highgo Software (Canada/China/Pakistan)

URL : http://www.highgo.ca/

EMAIL: mailto:movead(dot)li(at)highgo(dot)ca

Attachment Content-Type Size
0001-CSN-base-snapshot.patch application/octet-stream 49.0 KB
0002-Wal-for-csn.patch application/octet-stream 26.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message godjan • 2020-05-08 13:25:02 Is it possible to find out write_lsn on standby?
Previous Message Matt Daw 2020-05-08 11:58:39 Re: Improving estimates for TPC-H Q2