-
Notifications
You must be signed in to change notification settings - Fork 101
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
docs: sample on setting per-request gaxOptions #1210
docs: sample on setting per-request gaxOptions #1210
Conversation
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.
LGTM, 👍 . Only need a small change.
samples/dml.js
Outdated
@@ -630,6 +630,74 @@ async function updateUsingBatchDml(instanceId, databaseId, projectId) { | |||
// [END spanner_dml_batch_update] | |||
} | |||
|
|||
async function executeSqlWithCustomTimeoutAndRetrySettings( |
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.
Does the Samples Test fail due to the async
prefix here? I don't see what the difference is, comparing to
Lines 20 to 69 in 0a50621
function insertUsingDml(instanceId, databaseId, projectId) { | |
// [START spanner_dml_standard_insert] | |
// Imports the Google Cloud client library | |
const {Spanner} = require('@google-cloud/spanner'); | |
/** | |
* TODO(developer): Uncomment the following lines before running the sample. | |
*/ | |
// const projectId = 'my-project-id'; | |
// const instanceId = 'my-instance'; | |
// const databaseId = 'my-database'; | |
// Creates a client | |
const spanner = new Spanner({ | |
projectId: projectId, | |
}); | |
// Gets a reference to a Cloud Spanner instance and database | |
const instance = spanner.instance(instanceId); | |
const database = instance.database(databaseId); | |
database.runTransaction(async (err, transaction) => { | |
if (err) { | |
console.error(err); | |
return; | |
} | |
try { | |
const [rowCount] = await transaction.runUpdate({ | |
sql: | |
'INSERT Singers (SingerId, FirstName, LastName) VALUES (10, @firstName, @lastName)', | |
params: { | |
firstName: 'Virginia', | |
lastName: 'Watson', | |
}, | |
}); | |
console.log( | |
`Successfully inserted ${rowCount} record into the Singers table.` | |
); | |
await transaction.commit(); | |
} catch (err) { | |
console.error('ERROR:', err); | |
} finally { | |
// Close the database when finished. | |
database.close(); | |
} | |
}); | |
// [END spanner_dml_standard_insert] | |
} |
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.
It's not about async
, currently I am investigating on it.
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.
This issue turns up purely when you set the gaxOptions. If you don't, the sample runs fine.
Also, you can't set a subset of the fields. You have to set all of them.
- first I set only the retry codes then it said
ERROR: TypeError: Cannot read property 'retryDelayMultiplier' of undefined
. - then I set
retryDelayMultiplier
then it saidError: 2 UNKNOWN: Getting metadata from plugin failed with error: Deadline is too far in the future
- until you set each field, it keeps producing the same error.
- once you set all of them, it errors with
ERROR: TypeError: stream.on is not a function
.
So it has something to do with the fact that this is a streaming RPC. We set gaxOptions in the admin RPC calls in the system tests and this doesn't happen.
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.
@skuruppu @hengfengli something with streaming in google-gax
, I did check this in bigtable
and found same error with stream.
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 see, we do not support retry in stream, Here is the issue in google-gax
.
I will change the sample accordingly.
Hi @laljikanjareeya, is there any news for this? |
Codecov Report
@@ Coverage Diff @@
## master #1210 +/- ##
=======================================
Coverage 98.24% 98.24%
=======================================
Files 23 23
Lines 21140 21140
Branches 1181 1181
=======================================
Hits 20769 20769
Misses 368 368
Partials 3 3 Continue to review full report at Codecov.
|
Please also wait for approval by @hengfengli since the sample now looks different to the one in Go. |
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.
LGTM. 👍 Thanks for doing this.
Fixes #1203