aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-10-04 12:10:55 +0200
committerKim Alvefur <zash@zash.se>2017-10-04 12:10:55 +0200
commit5970fb161e2c811c59d0b0a512c8f8a756a7814a (patch)
tree31071c1b069ed0de0094100b6522683ff05d0e54
parent753dbfaf91c8855555370310ecd1ac228b2ad6c8 (diff)
parent03d6a88e608e2027894172728921701f8987d9a8 (diff)
downloadprosody-5970fb161e2c811c59d0b0a512c8f8a756a7814a.tar.gz
prosody-5970fb161e2c811c59d0b0a512c8f8a756a7814a.zip
Merge 0.10->trunk
-rw-r--r--CHANGES4
-rw-r--r--util/sql.lua17
2 files changed, 15 insertions, 6 deletions
diff --git a/CHANGES b/CHANGES
index 102415b7..8b9baa8e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -12,10 +12,10 @@ New features
- mod\_pep\_plus
- Asynchronous operations
-0.10.not-released-yet
+0.10.0
=====================
-**YYYY-MM-DD**
+**2017-10-02**
New features
------------
diff --git a/util/sql.lua b/util/sql.lua
index 61d6af41..71158d4c 100644
--- a/util/sql.lua
+++ b/util/sql.lua
@@ -217,8 +217,9 @@ function engine:debug(enable)
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 @@ function engine:_transaction(func, ...)
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 @@ function engine:transaction(...)
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;