promise postgres that I will only ROLLBACK

From: Gergely Riskó <gergely(dot)risko(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: promise postgres that I will only ROLLBACK
Date: 2020-03-20 11:22:51
Message-ID: CAMhZOOz-2puuxYA57Bs746wK9VvRoYGx_XaqyzCGybXgpmFm5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey,

I have a unit testing framework, where every test is ran in
BEGIN..ROLLBACK, to ensure that data created during testing is never
persisted.

Now, my question is: is there any way to tell postgres that

"Look, I will never ask you for a COMMIT, therefore you don't have to lock
anything for me,
you just have to do a 'snapshot', fake my writes in my view of the world,
then destroy all this on rollback".

This way, I would be able to run my many test cases in parallel, without
worrying about locks/deadlocks between different testcases.

Something like BEGIN READ ONLY TRANSACTION WITH TEMPORARY WRITES...

I of course researched this a little bit, and I know that there are no out
of the box syntax for this, but is there maybe some combinations of options
which I can abuse to provide this?

(I can naturally do this on the filesystem with snapshots and LVM, but I
would like something in postgres, so it doesn't become a sysadmin
nightmare.)

Thank you for your ideas,
Gergely Risko

Browse pgsql-general by date

  From Date Subject
Next Message Mariya Rampurawala 2020-03-20 11:27:24 Wal receiver process listens to physical IP
Previous Message Vlad Bokov 2020-03-20 09:50:04 Partition by hash formula