Future < dynamic > sqlInsert(Map body) async {
bool isDataWasInserted = false;
try {
await connection.transaction((ctx) async {
for (var s in jsonDecode(body['sql'])) {
await ctx.query(s);
}
isDataWasInserted = true;
}).timeout(Duration(seconds: 96));
}
on PostgreSQLException
catch (e) {
await connection.cancelTransaction();
try {
await connection.transaction((ctx) async {
for (var s in jsonDecode(body['sql-remove'])) {
await ctx.query(s);
}
});
try {
await connection.transaction((ctx) async {
for (var s in jsonDecode(body['sql'])) {
await ctx.query(s);
}
isDataWasInserted = true;
});
}
on PostgreSQLException
catch (e) {
print("SECOND INSERT WAS FAILED ${e.message}");
await connection.cancelTransaction();
writeLog("SECOND INSERT WAS FAILED ", e.message);
}
}
on PostgreSQLException
catch (e) {
print("Removing duplicates was FAILED: ${e.message}");
}
}
if (isDataWasInserted) {
return dbEnums.success;
} else {
writeLog("Can't insert data. Something wrong", "");
return dbEnums.insertFailed;
}
}
Periodically I am getting exception:
sql-insert exception: TimeoutException after 0:00:30.000000: Future not completed
sql-insert exception: TimeoutException after 0:00:30.000000: Future not completed
But I can't understand why the code and exception have different timeouts.
I can't find bug for a week. So possible it could be a bug in driver.
method:
Periodically I am getting exception:
But I can't understand why the code and exception have different timeouts.