diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-09-21 14:36:18 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-09-21 14:36:18 +0200 |
commit | 93a84d5e5aee9df869ac9e78a88c294d6311a9ef (patch) | |
tree | 060813cef751493abfa6c6417ed15031aec4842b /src/mintdb/plugin_mintdb_postgres.c | |
parent | 70c28e53d0615bc6694ea2339a739d387f8d8691 (diff) | |
download | exchange-93a84d5e5aee9df869ac9e78a88c294d6311a9ef.tar.xz |
retry transactions on serialization/dead-lock failures (#3990)
Diffstat (limited to 'src/mintdb/plugin_mintdb_postgres.c')
-rw-r--r-- | src/mintdb/plugin_mintdb_postgres.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/mintdb/plugin_mintdb_postgres.c b/src/mintdb/plugin_mintdb_postgres.c index 42aac19f1..621108026 100644 --- a/src/mintdb/plugin_mintdb_postgres.c +++ b/src/mintdb/plugin_mintdb_postgres.c @@ -1095,7 +1095,31 @@ postgres_commit (void *cls, if (PGRES_COMMAND_OK != PQresultStatus (result)) { - GNUNET_break (0); + const char *sqlstate; + + sqlstate = PQresultErrorField (result, + PG_DIAG_SQLSTATE); + if (NULL == sqlstate) + { + /* very unexpected... */ + GNUNET_break (0); + PQclear (result); + return GNUNET_SYSERR; + } + /* 40P01: deadlock, 40001: serialization failure */ + if ( (0 == strcmp (sqlstate, + "40P01")) || + (0 == strcmp (sqlstate, + "40001")) ) + { + /* These two can be retried and have a fair chance of working + the next time */ + PQclear (result); + return GNUNET_NO; + } + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Database commit failure: %s\n", + sqlstate); PQclear (result); return GNUNET_SYSERR; } |