diff options
author | 2014-01-05 20:20:09 -0500 | |
---|---|---|
committer | 2014-01-05 20:20:09 -0500 | |
commit | f00f54541df6722f06057da89da38ba906252058 (patch) | |
tree | b4fcc7c72f2d39435bc102fe548b05d2537be4a8 | |
parent | 771723435b7949b0a0ccb1e55ce919994a97613f (diff) |
MySQL: catch deadlocks during queries
-rw-r--r-- | src/mysql.sml | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mysql.sml b/src/mysql.sml index a119321c..3b59d1c1 100644 --- a/src/mysql.sml +++ b/src/mysql.sml @@ -854,11 +854,20 @@ fun queryCommon {loc, query, cols, doCols} = newline, newline, - string "if (mysql_stmt_execute(stmt)) uw_error(ctx, FATAL, \"", - string (ErrorMsg.spanToString loc), - string ": Error executing query: %s\\n%s\", ", - query, - string ", mysql_error(conn->conn));", + string "if (mysql_stmt_execute(stmt)) {", + newline, + box [string "if (mysql_errno(conn->conn) == 1213)", + newline, + box [string "uw_error(ctx, UNLIMITED_RETRY, \"Deadlock detected\");", + newline], + newline, + string "uw_error(ctx, FATAL, \"", + string (ErrorMsg.spanToString loc), + string ": Error executing query: %s\\n%s\", ", + query, + string ", mysql_error(conn->conn));", + newline], + string "}", newline, newline, |