--- a/.hgtags Fri Sep 29 13:45:03 2017 +0200
+++ b/.hgtags Wed Oct 04 12:10:55 2017 +0200
@@ -60,3 +60,4 @@
352270bc04393910a567b569ede03358dbb728b5 0.9.10
8613086779fa9276615c2af066d2a10c38d0c86e 0.9.11
2a7b52437167a5c7b6c8a5bc79f4463afe092fd5 0.9.12
+39966cbc29f46d7ae9660edca8683d5121c82edf 0.10.0
--- a/CHANGES Fri Sep 29 13:45:03 2017 +0200
+++ b/CHANGES Wed Oct 04 12:10:55 2017 +0200
@@ -12,10 +12,10 @@
- mod\_pep\_plus
- Asynchronous operations
-0.10.not-released-yet
+0.10.0
=====================
-**YYYY-MM-DD**
+**2017-10-02**
New features
------------
--- a/util/sql.lua Fri Sep 29 13:45:03 2017 +0200
+++ b/util/sql.lua Wed Oct 04 12:10:55 2017 +0200
@@ -217,8 +217,9 @@
end
end
local function handleerr(err)
- log("error", "Error in SQL transaction: %s", debug_traceback(err, 3));
- return err;
+ local trace = debug_traceback(err, 3);
+ log("debug", "Error in SQL transaction: %s", trace);
+ return { err = err, traceback = trace };
end
function engine:_transaction(func, ...)
if not self.conn then
@@ -238,9 +239,9 @@
if not ok then return ok, err; end -- commit failed
return success, a, b, c;
else
- log("debug", "SQL transaction failure [%s]: %s", tostring(func), a);
+ log("debug", "SQL transaction failure [%s]: %s", tostring(func), a.err);
if self.conn then self.conn:rollback(); end
- return success, a;
+ return success, a.err;
end
end
function engine:transaction(...)
@@ -248,8 +249,16 @@
if not ok then
local conn = self.conn;
if not conn or not conn:ping() then
+ log("debug", "Database connection was closed. Will reconnect and retry.");
self.conn = nil;
+ log("debug", "Retrying SQL transaction [%s]", tostring((...)));
ok, ret = self:_transaction(...);
+ log("debug", "SQL transaction retry %s", ok and "succeeded" or "failed");
+ else
+ log("debug", "SQL connection is up, so not retrying");
+ end
+ if not ok then
+ log("error", "Error in SQL transaction: %s", ret);
end
end
return ok, ret;