-
Notifications
You must be signed in to change notification settings - Fork 102
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
Error 4: Deadline for Transaction exceeded / Transaction outcome unknown #216
Comments
How large is this transaction? Is this a single row update? |
Yes it is a single row. |
Alright. I can't imagine a single row being so big that it would exceed deadlines. Just to check assumptions I may have made, the intent of your code is the following:
Could you measure how long |
When the original fix for this issue was released this issue morphed from what you see described in #202 to the current issue. It now appears I get this error as the error param of my Per some conversation I saw around the past ticket what I suspect is happening is the same as the previous issue, however now that it is retried internally this error occurs when retrying takes too long (I think I remember someone mentioned y'all will throw |
@walshie4 , your understanding about |
I'll add some more logging when I get a chance to see if I can gather some more detailed info on the insert in question causing the issue. |
@walshie4 , any luck at finding anything? |
Nothing of value, I have examples of the rows attempting to be inserted but there is nothing special about them. Here's an example (field names have been replaced with types)
The only weirdness I see is the int64 values are sometimes strings, sometimes JS ints. Not sure how this would cause an issue like we've been seeing though. |
Hi there, we also encounter the same error randomly. We got message Our current logging didn;t log it in detail, we will add better logging for this error. |
Is this issue also related the retry mechanism? We got the error quite frequently. It is impossible to use transaction feature with this error. |
@eric4545 , the logic for retrying a transaction requires the following be true
If any of those aren't true, the transaction will end. In the cases where it was a retryable error code but it exceed the allowable time, the returned error is modified to be a DEADLINE_EXCEEDED error. |
@Duncan00 the retry mechanism only retries on ABORTED and UNKNOWN because we consider those retry-able error codes. Some of the error codes likely wouldn't benefit from being retried. If you wanted to retry more aggressively you could always modify the transaction's |
@crwilcox the following code could easily reproduce the deadline transaction exceeded error, please help to check (it may need to take a long time to encounter the error, just keep it running for 1 hour): note that even the simplest That means doing any 'use strict';
const {Spanner} = require('@google-cloud/spanner');
const readline = require('readline');
const spanner = new Spanner({
projectId: '<your project>'
});
const database = spanner
.instance('<your instance>')
.database('<your db>', {
keepAlive: 5,
});
let total = 0;
let errors = [];
async function main() {
while (true) {
try {
await test();
} catch (e) {
e.time = new Date();
console.error(e)
errors.push(e);
} finally {
total += 1;
readline.clearLine(process.stdout, 0)
readline.cursorTo(process.stdout, 0, null);
process.stdout.write(`Total: ${total}, Errors: ${errors.length}, Error rate: ${((errors.length / total) * 100).toFixed(6) + '%'}`)
}
}
}
main().catch(console.error);
async function test() {
return new Promise((res, rej) => {
database.runTransaction(async (err, transaction) => {
if (err) return rej(err);
try {
await transaction.run({sql: 'select 1 as ok'})
await transaction.commit();
return res(true)
} catch (e) {
return rej(e);
}
});
})
} |
@crwilcox When this error throw there is no retry info key in the metadata, i tried the same flow using golang, so far no error occurs. https://gist.github.com/eric4545/c514128a625172cf5c6969ae74cd3f83 |
same script won't trigger any errors in ruby sdk as well. (correct me if me usage was wrong) require "google/cloud/spanner"
spanner = Google::Cloud::Spanner.new project_id: 'aftership-test'
db = spanner.client "aftership-test-1", "test_core_aftershipapi_com"
total = 0
errors = 0
while true do
begin
db.transaction do |tx|
results = tx.execute "SELECT 1 as OK"
total += results.rows.count
end
print "Total query: #{total}, errors: #{errors}\r"
$stdout.flush
rescue Interrupt => e
print_exception(e, true)
rescue Exception => e
errors += 1
print_exception(e, false)
end
end |
Environment details
@google-cloud/spanner
version: v1.4.3Steps to reproduce
Attempting an insert in the same way as described here: #202 (comment)
Code causing the issue for us:
I've added better logging to see if I can get a stack but so far this is all I have on the error.
The text was updated successfully, but these errors were encountered: