mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-08-13 14:34:51 -05:00
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:
@@ -16,9 +16,8 @@ from flask import render_template, make_response, request, jsonify
|
||||
from flask_babel import gettext
|
||||
from pgadmin.browser.collection import CollectionNodeModule
|
||||
from pgadmin.browser.utils import PGChildNodeView
|
||||
from pgadmin.utils.ajax import make_json_response, \
|
||||
make_response as ajax_response, internal_server_error
|
||||
from pgadmin.utils.ajax import precondition_required
|
||||
from pgadmin.utils.ajax import make_json_response, internal_server_error, \
|
||||
make_response as ajax_response
|
||||
from pgadmin.utils.driver import get_driver
|
||||
|
||||
from config import PG_DEFAULT_DRIVER
|
||||
@@ -188,22 +187,12 @@ class EventTriggerView(PGChildNodeView):
|
||||
|
||||
@wraps(f)
|
||||
def wrap(*args, **kwargs):
|
||||
# Here args[0] will hold self & kwargs will hold gid,sid,did
|
||||
|
||||
# Here - args[0] will always hold self & kwargs will hold gid, sid, did
|
||||
self = args[0]
|
||||
self.manager = get_driver(PG_DEFAULT_DRIVER).connection_manager(kwargs['sid'])
|
||||
self.conn = self.manager.connection(did=kwargs['did'])
|
||||
|
||||
# If DB not connected then return error to browser
|
||||
if not self.conn.connected():
|
||||
return precondition_required(
|
||||
gettext(
|
||||
"Connection to the server has been lost!"
|
||||
)
|
||||
)
|
||||
|
||||
ver = self.manager.version
|
||||
if ver >= 90300:
|
||||
self.template_path = 'event_triggers/sql/9.3_plus'
|
||||
self.template_path = 'event_triggers/sql/9.3_plus'
|
||||
|
||||
return f(*args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user