Skip to content

Commit 4dfb59d

Browse files
authored
Merge pull request #68 from ydb-platform/race-result
draft v3.5.2
2 parents 9f931ca + 32e9827 commit 4dfb59d

Some content is hidden

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

79 files changed

+2068
-1287
lines changed

.github/workflows/gosec.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.golangci.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,69 @@ linters-settings:
126126
linters:
127127
disable-all: true
128128
enable:
129+
# - cyclop
129130
- deadcode
130131
- depguard
132+
- dogsled
133+
# - dupl
131134
- errcheck
135+
- errorlint
136+
# - exhaustive
137+
# - exhaustivestruct
138+
# - forbidigo
139+
# - funlen
140+
# - gci
141+
# - gocognit
132142
- goconst
143+
- gocritic
144+
- gocyclo
145+
# - godot
146+
- godox
133147
- gofmt # On why gofmt when goimports is enabled - https://github.com/golang/go/issues/21476
148+
- gofumpt
149+
- goheader
134150
- goimports
151+
# - gomnd
152+
# - gomoddirectives
153+
# - gomodguard
154+
- gosec
135155
- revive
136156
- gosimple
137157
- govet
158+
- depguard
159+
# - ifshort
160+
# - ireturn
161+
- lll
162+
- makezero
163+
- maligned
164+
- misspell
138165
- ineffassign
139166
- misspell
167+
- nakedret
168+
- nestif
169+
# - nilnil
170+
# - nlreturn
171+
- nolintlint
172+
- prealloc
173+
- predeclared
174+
- rowserrcheck
175+
- revive
140176
- staticcheck
177+
- stylecheck
141178
- structcheck
179+
# - tagliatelle
180+
# - testpackage
181+
# - thelper
182+
# - tenv
142183
- typecheck
143184
- unconvert
144185
- unparam
145186
- unused
187+
# - varnamelen
146188
- varcheck
189+
- whitespace
190+
# - wrapcheck
191+
# - wsl
147192

148193
issues:
149194
# List of regexps of issue texts to exclude, empty list by default.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 3.5.2
2+
* Fixed data race on closing table result
3+
* Added custom dns-resolver to grpc options for use dns-balancing with round_robin balancing policy
4+
* Wrapped with `recover()` system panic on getting system certificates pool
5+
* Added linters and fixed issues from them
6+
* Changed API of `sugar` package
7+
18
## 3.5.1
29
* Added system certificates for `darwin` system
310
* Fixed `table.StreamResult` finishing

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ The straightforward example of querying data may look similar to this:
6060
```go
6161
ctx := context.Background()
6262

63-
// connect package helps to connect to database, returns connection object which
64-
// provide necessary clients such as table.Client, scheme.Client, etc.
63+
// ydb.New() returns connection object which provide necessary clients for different ydb services
64+
// such as table.Client, scheme.Client, coordination.Client, etc.
6565
db, err := ydb.New(
6666
ctx,
6767
ydb.WithConnectionString(os.Getenv("YDB_CONNECTION_STRING")),

config/balancer.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,4 @@ type BalancerConfig struct {
3232
PreferLocal bool
3333
}
3434

35-
var (
36-
DefaultBalancer = BalancerConfig{Algorithm: DefaultBalancingAlgorithm, PreferLocal: true}
37-
)
35+
var DefaultBalancer = BalancerConfig{Algorithm: DefaultBalancingAlgorithm, PreferLocal: true}

config/config.go

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,22 @@ type Config interface {
9191

9292
// Config contains driver configuration options.
9393
type config struct {
94-
endpoint string
95-
database string
96-
secure bool
97-
credentials credentials.Credentials
9894
trace trace.Driver
9995
requestTimeout time.Duration
10096
streamTimeout time.Duration
10197
operationTimeout time.Duration
10298
operationCancelAfter time.Duration
10399
discoveryInterval time.Duration
100+
dialTimeout time.Duration
104101
balancingConfig BalancerConfig
105-
requestsType string
102+
secure bool
106103
fastDial bool
107-
dialTimeout time.Duration
108-
tlsConfig *tls.Config
104+
endpoint string
105+
database string
106+
requestsType string
109107
grpcOptions []grpc.DialOption
108+
credentials credentials.Credentials
109+
tlsConfig *tls.Config
110110
}
111111

112112
func (c *config) GrpcDialOptions() []grpc.DialOption {
@@ -282,21 +282,28 @@ func New(opts ...Option) Config {
282282
return c
283283
}
284284

285-
func defaults() (c *config) {
286-
var (
287-
certPool *x509.CertPool
288-
err error
289-
)
285+
func certPool() (certPool *x509.CertPool) {
286+
defer func() {
287+
// on darwin system panic raced on getting system security checks
288+
if e := recover(); e != nil {
289+
certPool = x509.NewCertPool()
290+
}
291+
}()
292+
var err error
290293
certPool, err = x509.SystemCertPool()
291294
if err != nil {
292295
certPool = x509.NewCertPool()
293296
}
297+
return
298+
}
299+
300+
func defaults() (c *config) {
294301
return &config{
295302
discoveryInterval: DefaultDiscoveryInterval,
296303
balancingConfig: DefaultBalancer,
297304
tlsConfig: &tls.Config{
298305
MinVersion: tls.VersionTLS12,
299-
RootCAs: certPool,
306+
RootCAs: certPool(),
300307
},
301308
}
302309
}

connect_params_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,35 @@ func TestParseConnectionString(t *testing.T) {
1818
error error
1919
}{
2020
{
21-
"grpc://ydb-ru.yandex.net:2135/?database=/ru/home/gvit/mydb&token=123",
21+
"grpc://ydb-ru.yandex.net:2135/?" +
22+
"database=/ru/home/gvit/mydb&token=123",
2223
"grpc",
2324
"ydb-ru.yandex.net:2135",
2425
"/ru/home/gvit/mydb",
2526
"123",
2627
nil,
2728
},
2829
{
29-
"grpcs://ydb.serverless.yandexcloud.net:2135/?database=/ru-central1/b1g8skpblkos03malf3s/etn02qso4v3isjb00te1&token=123",
30+
"grpcs://ydb.serverless.yandexcloud.net:2135/?" +
31+
"database=/ru-central1/b1g8skpblkos03malf3s/etn02qso4v3isjb00te1&token=123",
3032
"grpcs",
3133
"ydb.serverless.yandexcloud.net:2135",
3234
"/ru-central1/b1g8skpblkos03malf3s/etn02qso4v3isjb00te1",
3335
"123",
3436
nil,
3537
},
3638
{
37-
"grpcs://lb.etn03r9df42nb631unbv.ydb.mdb.yandexcloud.net:2135/?database=/ru-central1/b1g8skpblkos03malf3s/etn03r9df42nb631unbv&token=123",
39+
"grpcs://lb.etn03r9df42nb631unbv.ydb.mdb.yandexcloud.net:2135/?" +
40+
"database=/ru-central1/b1g8skpblkos03malf3s/etn03r9df42nb631unbv&token=123",
3841
"grpcs",
3942
"lb.etn03r9df42nb631unbv.ydb.mdb.yandexcloud.net:2135",
4043
"/ru-central1/b1g8skpblkos03malf3s/etn03r9df42nb631unbv",
4144
"123",
4245
nil,
4346
},
4447
{
45-
"abcd://ydb-ru.yandex.net:2135/?database=/ru/home/gvit/mydb",
48+
"abcd://ydb-ru.yandex.net:2135/?" +
49+
"database=/ru/home/gvit/mydb",
4650
"",
4751
"",
4852
"",

connection.go

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/ydb-platform/ydb-go-sdk/v3/internal/coordination"
1212
"github.com/ydb-platform/ydb-go-sdk/v3/internal/dial"
1313
"github.com/ydb-platform/ydb-go-sdk/v3/internal/discovery"
14+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/errors"
1415
"github.com/ydb-platform/ydb-go-sdk/v3/internal/logger"
1516
"github.com/ydb-platform/ydb-go-sdk/v3/internal/ratelimiter"
1617
"github.com/ydb-platform/ydb-go-sdk/v3/log"
@@ -93,19 +94,43 @@ func (db *db) Secure() bool {
9394
return db.config.Secure()
9495
}
9596

96-
func (db *db) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error {
97+
func (db *db) Invoke(
98+
ctx context.Context,
99+
method string,
100+
args interface{},
101+
reply interface{},
102+
opts ...grpc.CallOption,
103+
) error {
97104
return db.cluster.Invoke(ctx, method, args, reply, opts...)
98105
}
99106

100-
func (db *db) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error) {
107+
func (db *db) NewStream(
108+
ctx context.Context,
109+
desc *grpc.StreamDesc,
110+
method string,
111+
opts ...grpc.CallOption,
112+
) (grpc.ClientStream, error) {
101113
return db.cluster.NewStream(ctx, desc, method, opts...)
102114
}
103115

104116
func (db *db) Close(ctx context.Context) error {
105-
_ = db.Table().Close(ctx)
106-
_ = db.Scheme().Close(ctx)
107-
_ = db.Coordination().Close(ctx)
108-
return db.cluster.Close(ctx)
117+
issues := make([]error, 0, 4)
118+
if err := db.cluster.Close(ctx); err != nil {
119+
issues = append(issues, err)
120+
}
121+
if err := db.Table().Close(ctx); err != nil {
122+
issues = append(issues, err)
123+
}
124+
if err := db.Scheme().Close(ctx); err != nil {
125+
issues = append(issues, err)
126+
}
127+
if err := db.Coordination().Close(ctx); err != nil {
128+
issues = append(issues, err)
129+
}
130+
if len(issues) > 0 {
131+
return errors.NewWithIssues("close failed", issues...)
132+
}
133+
return nil
109134
}
110135

111136
func (db *db) Table(opts ...Option) table.Client {

coordiantion.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ func (c *lazyCoordination) DropNode(ctx context.Context, path string) (err error
3030
return c.client.DropNode(ctx, path)
3131
}
3232

33-
func (c *lazyCoordination) DescribeNode(ctx context.Context, path string) (_ *scheme.Entry, _ *coordination.Config, err error) {
33+
func (c *lazyCoordination) DescribeNode(
34+
ctx context.Context,
35+
path string,
36+
) (
37+
_ *scheme.Entry,
38+
_ *coordination.Config,
39+
err error,
40+
) {
3441
c.init()
3542
return c.client.DescribeNode(ctx, path)
3643
}

go.mod

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,3 @@ require (
77
google.golang.org/grpc v1.38.0
88
google.golang.org/protobuf v1.26.0
99
)
10-
11-
retract v3.0.0
12-
13-
retract v3.0.1
14-
15-
retract v3.0.2
16-
17-
retract v3.0.3
18-
19-
retract v3.2.3
20-
21-
retract v3.3.1

0 commit comments

Comments
 (0)