You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
5.[Changing the transaction control mode](#tx-control)
18
+
6.[Retry helpers for `YDB``database/sql` driver](#retry)
18
19
*[Retries over `sql.Conn` object](#retry-conn)
19
20
*[Retries over `sql.Tx`](#retry-tx)
20
-
6.[Specifying query parameters](#arg-types)
21
-
7.[Accessing the native driver from `*sql.DB`](#unwrap)
21
+
7.[Specifying query parameters](#arg-types)
22
+
8.[Accessing the native driver from `*sql.DB`](#unwrap)
22
23
23
24
## Initialization of `database/sql` driver <aname="init"></a>
24
25
@@ -61,6 +62,18 @@ Data source name parameters:
61
62
* static credentials with authority part of URI, like `grpcs://root:password@localhost:2135/local`
62
63
*`query_mode=scripting` - you can redefine default [DML](https://en.wikipedia.org/wiki/Data_manipulation_language) query mode
63
64
65
+
## Session pooling <aname="session-pool"></a>
66
+
67
+
Native driver `ydb-go-sdk/v3` implements the internal session pool, which uses with `db.Table().Do()` or `db.Table().DoTx()` methods.
68
+
Internal session pool is configured with options like `ydb.WithSessionPoolSizeLimit()` and other.
69
+
Unlike the session pool in the native driver, `database/sql` contains a different implementation of the session pool, which is configured with `*sql.DB.SetMaxOpenConns` and `*sql.DB.SetMaxIdleConns`.
70
+
Lifetime of a `YDB` session depends on driver configuration and error occurance, such as `sql.driver.ErrBadConn`.
71
+
`YDB` driver for `database/sql` includes the logic to transform the internal `YDB` error codes into `sql.driver.ErrBadConn` and other retryable and non-retryable error types.
72
+
73
+
In most cases the implementation of `database/sql` driver for YDB allows to complete queries without user-visible errors.
74
+
But some errors need to be handled on the client side, by re-running not a single operation, but a complete transaction.
75
+
Therefore the transaction logic needs to be wrapped with retry helpers, such as `retry.Do` or `retry.DoTx` (see more about retry helpers in the [retry section](#retry)).
76
+
64
77
## Query execution <aname="queries"></a>
65
78
66
79
### Queries on database object <aname="queries-db"></a>
0 commit comments