chore: sample for snapshot isolation#2265
Conversation
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
samples/snapshot-isolation.js
Outdated
| // Gets a reference to a Cloud Spanner instance and database | ||
| const instance = spanner.instance(instanceId); | ||
| const database = instance.database(databaseId); | ||
| const snapshotIsolationOptionsForRequest = { |
There was a problem hiding this comment.
| const snapshotIsolationOptionsForRequest = { | |
| // The isolation level specified at the request level takes precedence over the isolation level configured at the client level. | |
| const snapshotIsolationOptionsForRequest = { |
|
Warning: This pull request is touching the following templated files:
|
samples/snapshot-isolation.js
Outdated
| // [START spanner_isolation_level] | ||
| // Imports the Google Cloud Spanner client library | ||
| const {Spanner, protos} = require('@google-cloud/spanner'); | ||
| const snapshotIsolationOptionsForClient = { |
There was a problem hiding this comment.
probably calls this isolationOptionsForClient.
samples/snapshot-isolation.js
Outdated
| defaultTransactionOptions: snapshotIsolationOptionsForClient, | ||
| }); | ||
|
|
||
| function spannerSnapshotIsolation() { |
There was a problem hiding this comment.
I would call this runTransactionWithIsolationLevel().
samples/snapshot-isolation.js
Outdated
| const instance = spanner.instance(instanceId); | ||
| const database = instance.database(databaseId); | ||
| // The isolation level specified at the request level takes precedence over the isolation level configured at the client level. | ||
| const snapshotIsolationOptionsForRequest = { |
There was a problem hiding this comment.
Same here with naming, something like isolationOptionsForTransaction.
c292e3c to
2ee6b33
Compare
2ee6b33 to
82eb764
Compare
There was a problem hiding this comment.
Let's rename this to repeatable-read.js.
samples/README.md
Outdated
| __Usage:__ | ||
|
|
||
|
|
||
| `node snapshot-isolation.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>` |
There was a problem hiding this comment.
Same here with naming: repeatable-read.js
samples/system-test/spanner.test.js
Outdated
| // isolation_level_option | ||
| it('should run read-write transaction with isolation level option set', () => { | ||
| const output = execSync( | ||
| `node snapshot-isolation.js ${INSTANCE_ID} ${DATABASE_ID} ${PROJECT_ID}` |
166130e to
36566d0
Compare
ecc0c81 to
e107491
Compare
This PR contains sample for the Snapshot Isolation level support. Isolation level is being set to
SERIALIZABLEat the client level which is getting overwritten by the isolation levelREPEATABLE_READset at the transaction level.