Univention Bugzilla – Bug 34723
Traceback in pkgdb when postgres not running
Last modified: 2014-09-11 14:50:32 CEST
Reported by traceback feedback: Traceback: The init function of the module has failed: InternalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/univention/management/console/protocol/modserver.py", line 228, in handle self.__handler.init() File "/usr/lib/pymodules/python2.6/univention/management/console/modules/pkgdb/__init__.py", line 210, in init self.connection = updb.open_database_connection(self.ucr, pkgdbu=True) File "/usr/lib/pymodules/python2.6/univention/pkgdb.py", line 521, in open_database_connection connection = pgdb.connect(database=connectstring) File "/usr/lib/python2.6/dist-packages/pgdb.py", line 482, in connect dbtty, dbuser, dbpasswd) InternalError: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Happened at least 3 more times
The UMC did not yet offer a way to provide user friendly error messages on failed module init() calls. A specific exception class (UMC_ModuleInitError) has been added which can be thrown by UMC modules with a proper error message. UMC won't display the traceback, but only the error message passed to this exception when catchting it. svn 51145: univention-management-console (6.0.26-6) The pkgdb UMC module will throw an UMC_MOduleInitError, informing the user about the fact that the database server could not be contacted. svn 51146: univention-pkgdb (7.0.11-2) univention-pkgdb: yet to be build, YAML needs to be commited.
FYI: It doesn't make sense to translate the error message in the init() function because we don't have the information which language the user wants yet. Your commit message contained bug number #33673 which is already CLOSED.
> univention-pkgdb: yet to be build, YAML needs to be commited. Build, YAML added (svn 51187) Changes made for univention-pkgdb depend on changes made for univention-management-console. Therefore, the errata update for univention-pkgdb may not me published before.
I am now getting errors when using the command line. This can probably be worked around by importing some modules in the correct order (at least I hope that this gives not always a traceback...). But there are scripts out there that were written before this was necessary. >>> from univention.management.console.modules.appcenter.app_center import * Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/pymodules/python2.6/univention/management/console/modules/__init__.py", line 133, in <module> from ..protocol import Response, MIMETYPE_JSON File "/usr/lib/pymodules/python2.6/univention/management/console/protocol/__init__.py", line 192, in <module> from modserver import * File "/usr/lib/pymodules/python2.6/univention/management/console/protocol/modserver.py", line 46, in <module> from ..modules import UMC_ModuleInitError ImportError: cannot import name UMC_ModuleInitError
With a prepending from univention.management.console.protocol import * it seems to work... But this is not a good solution Also: I do not see why one needs a special UMC_ModuleInitError for that. UMC_Error would suffice (as these are raised manually AFAICS). From the changeset I would say that now we are losing information in case e != UMC_ModuleInitError. Why not revert and just: ) + if isinstance(e, UMC_Error): + error = str(e) self.__init_error_message = error (Haven't tested it) Just thinking: If locale is not ready when raising in init() of the module, one may translate the error message _again_ in protocol/modserver.py with the correct translation object (as the modserver should now which locale it was about to set).
> Also: I do not see why one needs a special UMC_ModuleInitError for that. > UMC_Error would suffice (as these are raised manually AFAICS). We're over using UMC_Error around the modules, as (considering the name) it should be raised in case of a problem with the UMC itself but not with the modules. We're over using UMC_Error around the modules, as (considering the name) it should be raised in case of a problem with the UMC itself but not with the modules. > From the > changeset I would say that now we are losing information in case e != > UMC_ModuleInitError. No information is lost. The full traceback is shown in a feedback dialog when the caught exception is no instance of UMC_ModuleInitError. If the exception IS an instance of UMC_ModuleInitError, only the exception message is shown (without a full feedback dialog). In any case, the traceback gets logged. That is to say: the modules have won a way to react to known errors in a user suitable way, while they can still force a feed back dialog by raising another exception type (e.g. "Exception", "ValueError", "TypeError"). Arbitrament?
> We're over using UMC_Error around the modules, as (considering the name) it > should be raised in case of a problem with the UMC itself but not with the > modules. Copy&Paste error.
(In reply to Dirk Wiesenthal from comment #5) > I am now getting errors when using the command line. This can probably be > worked around by importing some modules in the correct order (at least I > hope that this gives not always a traceback...). But there are scripts out > there that were written before this was necessary. > > >>> from univention.management.console.modules.appcenter.app_center import * > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File > "/usr/lib/pymodules/python2.6/univention/management/console/modules/__init__. > py", line 133, in <module> > from ..protocol import Response, MIMETYPE_JSON > File > "/usr/lib/pymodules/python2.6/univention/management/console/protocol/ > __init__.py", line 192, in <module> > from modserver import * > File > "/usr/lib/pymodules/python2.6/univention/management/console/protocol/ > modserver.py", line 46, in <module> > from ..modules import UMC_ModuleInitError > ImportError: cannot import name UMC_ModuleInitError Circular import. Fixed by defering the import. svn 51213: univention-management-console (6.0.24-13)
If the server is stopped while the module is active the module process remains running and the user is given the wrong feedback. (Empty results instead of error message)
(In reply to Janek Walkenhorst from comment #10) > If the server is stopped while the module is active the module process > remains running and the user is given the wrong feedback. (Empty results > instead of error message) Right now, the API offered by univention-pkgdb, which is used in the univention-pkgdb UMC module, does not provide a way for higher code levels to evaluate whether an error occured or not - exceptions are logged and swallowed, empty results given back. Therefore, the only clean way to fix this issue is by changing this API in a way that, for examples, passes exceptions along. Alternatively, we could perform a simple request to the database for each query the module gets, bypassing the API, just to ensure that the server is still running.
(In reply to Dirk Wiesenthal from comment #6) > Also: I do not see why one needs a special UMC_ModuleInitError for that. > UMC_Error would suffice (as these are raised manually AFAICS) UMC_Error/UMC_CommandError will be used. (In reply to Lukas Walter from comment #11) > Alternatively, we could perform a simple request to the database for each > query the module gets, bypassing the API, just to ensure that the server is > still running. Implemented.
Typo: Connection to the dabase lost Also: self.dbConnection is camelcase, one should use db_connection. But in this case it should actually be connection: self.connection was there before the patch. Now this (kind of) public member is gone.
(In reply to Dirk Wiesenthal from comment #13) > Typo: Connection to the dabase lost > > Also: self.dbConnection is camelcase, one should use db_connection. But in > this case it should actually be connection: self.connection was there before > the patch. Now this (kind of) public member is gone. I've fixed the typo and renamed the attributes. svn 51475: univention-pkgdb (7.0.11-6)
Missing XS-Python-Version: Trigger für python-support werden verarbeitet ... /usr/lib/pymodules/python2.5/univention/management/console/modules/pkgdb/__init__.py:229: Warning: 'as' will become a reserved keyword in Python 2.6 Compiling /usr/lib/pymodules/python2.5/univention/management/console/modules/pkgdb/__init__.py ... File "/usr/lib/pymodules/python2.5/univention/management/console/modules/pkgdb/__init__.py", line 229 except pgdb.InternalError as ex: ^ SyntaxError: invalid syntax
(In reply to Janek Walkenhorst from comment #10) > If the server is stopped while the module is active the module process > remains running and the user is given the wrong feedback. (Empty results > instead of error message) This works now. Also if the server is already not running when starting the module; A helpful message is shown. Advisory: OK
http://errata.univention.de/ucs/3.2/159.html
http://errata.univention.de/ucs/3.2/171.html
This fix introduced Bug #35700.