-
Notifications
You must be signed in to change notification settings - Fork 108
chore: sample for snapshot isolation #2265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const snapshotIsolationOptionsForRequest = { | |
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably calls this isolationOptionsForClient
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
samples/snapshot-isolation.js
Outdated
defaultTransactionOptions: snapshotIsolationOptionsForClient, | ||
}); | ||
|
||
function spannerSnapshotIsolation() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this runTransactionWithIsolationLevel()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with naming, something like isolationOptionsForTransaction
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
c292e3c
to
2ee6b33
Compare
2ee6b33
to
82eb764
Compare
samples/snapshot-isolation.js
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this to repeatable-read.js.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
samples/README.md
Outdated
__Usage:__ | ||
|
||
|
||
`node snapshot-isolation.js <INSTANCE_ID> <DATABASE_ID> <PROJECT_ID>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with naming: repeatable-read.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
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}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with naming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
43c3f23
to
0da8b77
Compare
This PR contains sample for the Snapshot Isolation level support. Isolation level is being set to
SERIALIZABLE
at the client level which is getting overwritten by the isolation levelREPEATABLE_READ
set at the transaction level.