In order to run integration tests concurrently, I wish to create a sample database at the beginning of every test. Theses test databases are "clones" of an immutable reference database (the template in CREATE test_db Template test_reference
).
The cloning (and dropping at the end) operation remains fast enough.
The problem is, I can't clone that reference database concurrently or I get the same kind of error as in the following question: this is a bottleneck. Is there a way to tell Postgres that I know those concurrent accesses are safe ?
PS: I am not interested for now to change my test setup to the well known strategy which consist in running all my tests in non committing transactions
create database
will connect to the template database to read from. As long as thecreate database
runs, there will be a connection to the template database preventing other CREATE DATABASE statements to use that template.