We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5367d93 commit aa64d28Copy full SHA for aa64d28
database/postgres/postgres.go
@@ -5,15 +5,26 @@ import (
5
"fmt"
6
"io/ioutil"
7
"os"
8
+ "sync"
9
"time"
10
11
"github.com/ory/dockertest/v3"
12
"github.com/ory/dockertest/v3/docker"
13
"golang.org/x/xerrors"
14
)
15
16
+// Locks the creation of a PostgreSQL instance to one-at-a-time.
17
+// We experienced race conditions when creating multiple instances
18
+// at a time. Somehow they were sharing data...
19
+//
20
+// This may be an upstream issue with "dockertest".
21
+var createMutex sync.Mutex
22
+
23
// Open creates a new PostgreSQL server using a Docker container.
24
func Open() (string, func(), error) {
25
+ createMutex.Lock()
26
+ defer createMutex.Unlock()
27
28
pool, err := dockertest.NewPool("")
29
if err != nil {
30
return "", nil, xerrors.Errorf("create pool: %w", err)
0 commit comments