Handling the bad/lost connection of a database server.

Made backend changes for:
* Taking care of the connection status in the psycopg2 driver. And, when
  the connection is lost, it throws a exception with 503 http status
  message, and connection lost information in it.
* Allowing the flask application to propagate the exceptions even in the
  release mode.
* Utilising the existing password (while reconnection, if not
  disconnected explicitly).
* Introduced a new ajax response message 'service_unavailable' (http
  status code: 503), which suggests temporary service unavailable.

Client (front-end) changes:
* To handle the connection lost of a database server for different
  operations by generating proper events, and handle them properly.

Removed the connection status check code from different nodes, so that
- it generates the proper exception, when accessing the non-alive
  connection.

Fixes #1387
This commit is contained in:
Ashesh Vashi
2016-08-29 11:52:50 +05:30
parent 1b05464a04
commit f12d981a9d
51 changed files with 1235 additions and 970 deletions

View File

@@ -1,6 +1,7 @@
define(
['underscore', 'jquery', 'pgadmin.browser', 'backgrid', 'wcdocker', 'pgadmin.backgrid'],
function(_, $, pgBrowser, Backgrid) {
define([
'underscore', 'underscore.string', 'jquery', 'pgadmin.browser', 'backgrid',
'alertify', 'wcdocker', 'pgadmin.backgrid', 'pgadmin.alertifyjs'
], function(_, S, $, pgBrowser, Backgrid, Alertify) {
if (pgBrowser.NodeStatistics)
return pgBrowser.NodeStatistics;
@@ -210,8 +211,26 @@ function(_, $, pgBrowser, Backgrid) {
$msgContainer.removeClass('hidden');
}
},
error: function() {
// TODO:: Report this error.
error: function(xhr, error, message) {
var _label = treeHierarchy[n_type].label;
pgBrowser.Events.trigger(
'pgadmin:node:retrieval:error', 'statistics', xhr, status, error, item
);
if (
!Alertify.pgHandleItemError(xhr, error, message, {
item: item, info: treeHierarchy
})
) {
Alertify.pgNotifier(
status, xhr,
S(
pgBrowser.messages['ERR_RETRIEVAL_INFO']
).sprintf(message || _label).value(),
function() {
console.log(arguments);
}
);
}
}
});
}