File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,26 @@ import (
5
5
"fmt"
6
6
"io/ioutil"
7
7
"os"
8
+ "sync"
8
9
"time"
9
10
10
11
"github.com/ory/dockertest/v3"
11
12
"github.com/ory/dockertest/v3/docker"
12
13
"golang.org/x/xerrors"
13
14
)
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
+
15
23
// Open creates a new PostgreSQL server using a Docker container.
16
24
func Open () (string , func (), error ) {
25
+ createMutex .Lock ()
26
+ defer createMutex .Unlock ()
27
+
17
28
pool , err := dockertest .NewPool ("" )
18
29
if err != nil {
19
30
return "" , nil , xerrors .Errorf ("create pool: %w" , err )
You can’t perform that action at this time.
0 commit comments