Skip to content

Commit 6497b85

Browse files
authored
Fix connection leak in edgeql-go (#394)
Fixes #387 Query introspection code paths were not returning connections to the pool. If there were more queries than available connections (100 by default) the generator would block indefinitely after using each connection once.
1 parent b39bbb6 commit 6497b85

File tree

2,008 files changed

+54113
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,008 files changed

+54113
-0
lines changed

cmd/edgeql-go/endtoend_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ var tests = []struct {
7373
directory: "testdata/rawmessage",
7474
args: []string{"-rawmessage"},
7575
},
76+
{
77+
// in response to https://github.com/geldata/gel-go/issues/387 which
78+
// was caused by a connection leak in introspection functions.
79+
description: "generate lots and lots of queries",
80+
directory: "testdata/manyqueries",
81+
args: []string{},
82+
},
7683
}
7784

7885
func TestMain(m *testing.M) {

cmd/edgeql-go/testdata/manyqueries/test-project/edgedb.toml

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module test
2+
3+
go 1.19
4+
5+
require github.com/geldata/gel-go v1.1.0
6+
7+
require (
8+
github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d // indirect
9+
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3 // indirect
10+
github.com/xdg/scram v1.0.5 // indirect
11+
github.com/xdg/stringprep v1.0.3 // indirect
12+
golang.org/x/crypto v0.32.0 // indirect
13+
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
14+
golang.org/x/sys v0.29.0 // indirect
15+
golang.org/x/text v0.21.0 // indirect
16+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d h1:S2NE3iHSwP0XV47EEXL8mWmRdEfGscSJ+7EgePNgt0s=
2+
github.com/certifi/gocertifi v0.0.0-20210507211836-431795d63e8d/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA=
3+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4+
github.com/geldata/gel-go v1.1.0 h1:f8Bp9VQbLlcbh4Ip47fxCjFYv0IGXhk5M13uwi3T0P8=
5+
github.com/geldata/gel-go v1.1.0/go.mod h1:1B2DC889nDzTO7ycWNIARTAEAs9G9PdKBvYrMNv4kHI=
6+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7+
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3 h1:aQKxg3+2p+IFXXg97McgDGT5zcMrQoi0EICZs8Pgchs=
8+
github.com/sigurn/crc16 v0.0.0-20211026045750-20ab5afb07e3/go.mod h1:9/etS5gpQq9BJsJMWg1wpLbfuSnkm8dPF6FdW2JXVhA=
9+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
10+
github.com/xdg/scram v1.0.5 h1:TuS0RFmt5Is5qm9Tm2SoD89OPqe4IRiFtyFY4iwWXsw=
11+
github.com/xdg/scram v1.0.5/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
12+
github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4=
13+
github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
14+
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
15+
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
16+
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4=
17+
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
18+
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
19+
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
20+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
21+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
22+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package main
2+
3+
import (
4+
"github.com/geldata/gel-go"
5+
"github.com/geldata/gel-go/gelcfg"
6+
)
7+
8+
func main() {
9+
_, _ = gel.CreateClient(gelcfg.Options{})
10+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select 1;
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Code generated by github.com/geldata/gel-go/cmd/edgeql-go DO NOT EDIT.
2+
3+
package queries
4+
5+
import (
6+
"context"
7+
_ "embed"
8+
9+
"github.com/geldata/gel-go/geltypes"
10+
)
11+
12+
//go:embed aaxkcdlafformjbpqrlkttlulbysragb.edgeql
13+
var aaxkcdlafformjbpqrlkttlulbysragbCmd string
14+
15+
// aaxkcdlafformjbpqrlkttlulbysragb
16+
// runs the query found in
17+
// aaxkcdlafformjbpqrlkttlulbysragb.edgeql
18+
func aaxkcdlafformjbpqrlkttlulbysragb(
19+
ctx context.Context,
20+
client geltypes.Executor,
21+
) (int64, error) {
22+
var result int64
23+
24+
err := client.QuerySingle(
25+
ctx,
26+
aaxkcdlafformjbpqrlkttlulbysragbCmd,
27+
&result,
28+
)
29+
30+
return result, err
31+
}
32+
33+
// aaxkcdlafformjbpqrlkttlulbysragbJSON
34+
// runs the query found in
35+
// aaxkcdlafformjbpqrlkttlulbysragb.edgeql
36+
// returning the results as json encoded bytes
37+
func aaxkcdlafformjbpqrlkttlulbysragbJSON(
38+
ctx context.Context,
39+
client geltypes.Executor,
40+
) ([]byte, error) {
41+
var result []byte
42+
43+
err := client.QuerySingleJSON(
44+
ctx,
45+
aaxkcdlafformjbpqrlkttlulbysragbCmd,
46+
&result,
47+
)
48+
if err != nil {
49+
return nil, err
50+
}
51+
52+
return result, nil
53+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select 1;
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Code generated by github.com/geldata/gel-go/cmd/edgeql-go DO NOT EDIT.
2+
3+
package queries
4+
5+
import (
6+
"context"
7+
_ "embed"
8+
9+
"github.com/geldata/gel-go/geltypes"
10+
)
11+
12+
//go:embed abzdvfqqiwyzhmnetiukywybrcyaztoy.edgeql
13+
var abzdvfqqiwyzhmnetiukywybrcyaztoyCmd string
14+
15+
// abzdvfqqiwyzhmnetiukywybrcyaztoy
16+
// runs the query found in
17+
// abzdvfqqiwyzhmnetiukywybrcyaztoy.edgeql
18+
func abzdvfqqiwyzhmnetiukywybrcyaztoy(
19+
ctx context.Context,
20+
client geltypes.Executor,
21+
) (int64, error) {
22+
var result int64
23+
24+
err := client.QuerySingle(
25+
ctx,
26+
abzdvfqqiwyzhmnetiukywybrcyaztoyCmd,
27+
&result,
28+
)
29+
30+
return result, err
31+
}
32+
33+
// abzdvfqqiwyzhmnetiukywybrcyaztoyJSON
34+
// runs the query found in
35+
// abzdvfqqiwyzhmnetiukywybrcyaztoy.edgeql
36+
// returning the results as json encoded bytes
37+
func abzdvfqqiwyzhmnetiukywybrcyaztoyJSON(
38+
ctx context.Context,
39+
client geltypes.Executor,
40+
) ([]byte, error) {
41+
var result []byte
42+
43+
err := client.QuerySingleJSON(
44+
ctx,
45+
abzdvfqqiwyzhmnetiukywybrcyaztoyCmd,
46+
&result,
47+
)
48+
if err != nil {
49+
return nil, err
50+
}
51+
52+
return result, nil
53+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
select 1;

0 commit comments

Comments
 (0)