Hi,
If you follow the steps I listed below, I think you will get a very slow data update operation which will consume larger than 10 seconds(table().update()).
I found that if I add the option {strong: true} to call runTransaction, the update function will run at a reasonable speed.
According to the docs, the default timestamp bound types of the read-only transaction is Strong.
But I think the Spanner SDK ignore the default option in database.runTransaction.
Environment details
- OS: macOS 10.11.6
- Node.js version: 8.1.3
- npm version: 5.0.3
- google-cloud-node version: 0.7.1
Steps to reproduce
- require
require('@google-cloud/spanner')
- Connect to Spanner
- Select an instance and a database without any workload
- create a table with this schema:
`CREATE TABLE bar (
user_id STRING(64) NOT NULL,
role STRING(64),
level INT64
) PRIMARY KEY (user_id)`
- insert sample data:
let sampleData = [
{'user_id': '1', 'role': 'coder','level': 1},
{'user_id': '2', 'role': 'coder', 'level': 1}
];
- create a read-only transaction
- use this transaction to run the following sql
- and then update the record
let options = {
readOnly: true
};
console.time('Step 1 read-only-transaction consume:');
database.runTransaction(options, function (err, transaction) {
if (err) {
throw (err);
}
let query1 = {
sql: 'SELECT * FROM bar as t WHERE t.role = @role',
params: {
role: 'coder'
}
};
transaction.run(query1, function (err1, dataset) {
if (err1) {
throw err1;
}
console.timeEnd('Step 1 read-only-transaction consume:');
transaction.end();
console.time('Step 2 DB update consume:');
let dbOperation = [
{user_id: '1', level: 2},
{user_id: '2', level: 2}
];
database.table('bar').update(dbOperation, function (err2, apiResponse) {
if (err2) {
throw err2;
}
console.timeEnd('Step 2 DB update consume:');
});
});
});
- Get the following result(the step 2 consume large than 10 seconds)
Step 1 read-only-transaction consume:: 1562.155ms
Step 2 DB update consume:: 15148.733ms
Thanks!
Hi,
If you follow the steps I listed below, I think you will get a very slow data update operation which will consume larger than 10 seconds(
table().update()).I found that if I add the option
{strong: true}to callrunTransaction, the update function will run at a reasonable speed.According to the docs, the default timestamp bound types of the read-only transaction is
Strong.But I think the Spanner SDK ignore the default option in database.runTransaction.
Environment details
Steps to reproduce
require('@google-cloud/spanner')Thanks!