Skip to content

Commit 8463a6c

Browse files
authored
feat: use a single multiplexed session for all operations (#500)
The Spanner database/sql driver now uses a single multiplexed session for all operations. Setting a value for MinSessions and MaxSessions is therefore no longer necessary for workloads that have a significantly higher or lower usage than can normally be served by the default session pool. One multiplexed session can execute any number of both read-only and read/write transactions concurrently. See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more information on multiplexed sessions.
1 parent 6dba3cf commit 8463a6c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ tx.QueryContext(ctx, "SELECT SingerId, Name FROM Singers WHERE SingerId = ?", 12
103103

104104
## Transactions
105105

106-
- Read-write transactions always uses the strongest isolation level and ignore the user-specified level.
106+
- Read-write transactions support isolation levels `Serializable`, `Snapshot` and `RepeatableRead`.
107107
- Read-only transactions do strong-reads by default. Read-only transactions must be ended by calling
108108
either Commit or Rollback. Calling either of these methods will end the current read-only
109-
transaction and return the session that is used to the session pool.
109+
transaction.
110110

111111
```go
112112
tx, err := db.BeginTx(ctx, &sql.TxOptions{}) // Read-write transaction.
@@ -226,6 +226,11 @@ $ gcloud beta emulators spanner start
226226
$ export SPANNER_EMULATOR_HOST=localhost:9010
227227
```
228228

229+
### Automatically Create Instance and Database on the Emulator
230+
You can also add the `autoConfigEmulator=true` option to the connection string. This will instruct the driver
231+
to connect to the Spanner emulator, and to automatically create the Spanner instance and database on the
232+
emulator. See [examples/emulator](examples/emulator) for a working example.
233+
229234
## Spanner PostgreSQL Interface
230235

231236
This driver works with both Spanner GoogleSQL and PostgreSQL dialects.

driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ var noopLogger = slog.New(slog.NewTextHandler(io.Discard, &slog.HandlerOptions{L
8484
// The default is false
8585
// - enableEndToEndTracing: Boolean that indicates if end-to-end tracing is enabled
8686
// The default is false
87-
// - minSessions: The minimum number of sessions in the backing session pool. The default is 100.
88-
// - maxSessions: The maximum number of sessions in the backing session pool. The default is 400.
87+
// - minSessions (DEPRECATED): The minimum number of sessions in the backing session pool. The default is 100. This option is deprecated, as the driver by default uses a single multiplexed session for all operations.
88+
// - maxSessions (DEPRECATED): The maximum number of sessions in the backing session pool. The default is 400. This option is deprecated, as the driver by default uses a single multiplexed session for all operations.
8989
// - numChannels: The number of gRPC channels to use to communicate with Cloud Spanner. The default is 4.
9090
// - optimizerVersion: Sets the default query optimizer version to use for this connection.
9191
// - optimizerStatisticsPackage: Sets the default query optimizer statistic package to use for this connection.

0 commit comments

Comments
 (0)