camptocamp / c2cgeoportal

c2cgeoportal application
http://geomapfish.org
Other
64 stars 46 forks source link

Failure with the layers_read_many service for empty data (editing) #699

Closed asaunier closed 6 years ago

asaunier commented 10 years ago

(for the records, I have not been able to reproduce the problem since I actually added items to the mentioned layers)

In a project, I have observed a strange behaviour in the editing interface while clicking on the map to select editable items: a layer had no item (empty DB table) and made the "layers_read_many" route crash (error 500).

The logs said:

[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] Error - <type 'exceptions.AttributeError'>: 'RelationshipProperty' ob
ject has no attribute 'strategy'
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] URL: http://geoportail-demo.epfl.ch/main/wsgi/layers/11?tolerance=10&
bbox=532826.52131084,152446.83694189,532827.2677662,152447.58339724
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/WebError-0.10.3-py2.7.egg/weberror/errormiddleware.py', line 162 in __call__
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   app_iter = self.application(environ, sr_checker)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/fanstatic-0.16-py2.7.egg/fanstatic/publisher.py', line 219 in __call__
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   return self.app(environ, start_response)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/fanstatic-0.16-py2.7.egg/fanstatic/injector.py', line 54 in __call__
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   response = request.get_response(self.app)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/WebOb-1.2.3-py2.7.egg/webob/request.py', line 1296 in send
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   application, catch_exc_info=False)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/WebOb-1.2.3-py2.7.egg/webob/request.py', line 1260 in call_application
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   app_iter = application(self.environ, start_response)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/pyramid-1.3.4-py2.7.egg/pyramid/router.py', line 187 in __call__
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   response = self.handle_request(request)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/pyramid-1.3.4-py2.7.egg/pyramid/tweens.py', line 20 in excview_tween
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   response = handler(request)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/pyramid_tm-0.7-py2.7.egg/pyramid_tm/__init__.py', line 82 in tm_tween
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   reraise(*exc_info)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/pyramid_tm-0.7-py2.7.egg/pyramid_tm/__init__.py', line 63 in tm_tween
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   response = handler(request)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/pyramid-1.3.4-py2.7.egg/pyramid/router.py', line 164 in handle_request
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   response = view_callable(context, request)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/pyramid-1.3.4-py2.7.egg/pyramid/config/views.py', line 333 in rendered_view
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   result = view(context, request)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/pyramid-1.3.4-py2.7.egg/pyramid/config/views.py', line 471 in _requestonly_view
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   response = view(request)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/
buildout/eggs/c2cgeoportal-1.4dev_20130617-py2.7.egg/c2cgeoportal/views/layers.py', line 143 in read_many
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   for f in _proto_read(layer, request).features:
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/c2cgeoportal-1.4dev_20130617-py2.7.egg/c2cgeoportal/views/layers.py', line 136 in _proto_read
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   return proto.read(request, filter=filter_)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/papyrus-0.10dev1-py2.7.egg/papyrus/protocol.py', line 290 in read
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   objs = self._query(request, filter)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/papyrus-0.10dev1-py2.7.egg/papyrus/protocol.py', line 270 in _query
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   return query.all()
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/SQLAlchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py', line 2115 in all
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   return list(self)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/SQLAlchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py', line 2223 in __iter__
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   context = self._compile_context()
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/SQLAlchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py', line 2873 in _compile_context
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   entity.setup_context(self, context)
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/SQLAlchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/orm/query.py', line 3211 in setup_context
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   column_collection=context.primary_columns
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/SQLAlchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/orm/interfaces.py', line 339 in setup
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   self._get_context_strategy(context, reduced_path + (self.key,)).\\
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] File '/var/www/vhosts/epfl-c2cgeoportail/private/epfl_authgeoportail/buildout/eggs/SQLAlchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/orm/interfaces.py', line 326 in _get_context_strategy
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4]   return self.strategy
[Wed Oct 09 15:52:21 2013] [error] [client 128.179.66.4] AttributeError: 'RelationshipProperty' object has no attribute 'strategy'

Eveything works fine since I added an item in the layer. Even if I delete all items from this layer and try again to make a new "layers_read_many" request including the mentioned layer...

@elemoine Do you think it could be a problem in the editing interface with "not initialized" layers?

sbrunner commented 10 years ago

Probably related: https://groups.google.com/forum/#!topic/sqlalchemy/-_gYIH7uMJ0

kalbermattenm commented 8 years ago

I just bumped into this problem... Does anyone have a hint what is going on and on how to solve it ?

kalbermattenm commented 8 years ago

I still have this issue...

It is really weird, because it only happens when using the edit app through Apache...

I have to restart Apache, reload the edit interface first, then this issue disappears...

I really do not get what is going wrong. Moreover, this now happens on editing layers which contain elements.

If I activate only one layer, then it works... But if I activate all layers (which are all editable) then I get the famous error. As example, here is a snapshot of the "editing" layer tree:

presse-papiers-2

sbrunner commented 8 years ago

Do you have a new trace?

kalbermattenm commented 8 years ago

It is not super explicit... But here it is:

[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6] mod_wsgi (pid=8048): Exception occurred processing WSGI script 'D:/Applications/Mapfish/production/apache/application.wsgi'., referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6] Traceback (most recent call last):, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\fanstatic\\publisher.py", line 219, in __call__, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     return self.app(environ, start_response), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\fanstatic\\injector.py", line 54, in __call__, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     response = request.get_response(self.app), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\webob\\request.py", line 1320, in send, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     application, catch_exc_info=False), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\webob\\request.py", line 1284, in call_application, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     app_iter = application(self.environ, start_response), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\pyramid\\router.py", line 243, in __call__, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     response = self.invoke_subrequest(request, use_tweens=True), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\pyramid\\router.py", line 218, in invoke_subrequest, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     response = handle_request(request), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\pyramid\\tweens.py", line 21, in excview_tween, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     response = handler(request), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\pyramid_tm\\__init__.py", line 94, in tm_tween, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     reraise(*exc_info), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\pyramid_tm\\__init__.py", line 75, in tm_tween, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     response = handler(request), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\pyramid\\router.py", line 164, in handle_request, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     response = view_callable(context, request), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\pyramid\\config\\views.py", line 353, in rendered_view, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     result = view(context, request), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\pyramid\\config\\views.py", line 481, in _class_requestonly_view, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     response = getattr(inst, attr)(), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\c2cgeoportal\\views\\layers.py", line 178, in read_many, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     for f in self._proto_read(layer).features:, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\c2cgeoportal\\views\\layers.py", line 170, in _proto_read, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     return proto.read(self.request, filter=filter_), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\papyrus\\protocol.py", line 298, in read, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     objs = self._query(request, filter), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\papyrus\\protocol.py", line 275, in _query, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     return query.all(), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\sqlalchemy\\orm\\query.py", line 2320, in all, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     return list(self), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\sqlalchemy\\orm\\query.py", line 2434, in __iter__, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     context = self._compile_context(), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\sqlalchemy\\orm\\query.py", line 2810, in _compile_context, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     entity.setup_context(self, context), referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\sqlalchemy\\orm\\query.py", line 3194, in setup_context, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     column_collection=context.primary_columns, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]   File "d:\\applications\\mapfish\\production\\.build\\venv\\Lib\\site-packages\\sqlalchemy\\orm\\interfaces.py", line 465, in setup, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6]     strat = self.strategy, referer: https://sitnintra.ne.ch/edit
[Wed Apr 06 08:41:30 2016] [error] [client 148.196.28.6] AttributeError: 'RelationshipProperty' object has no attribute 'strategy', referer: https://sitnintra.ne.ch/edit
sbrunner commented 8 years ago

But if I activate all layers

About how many layers?

kalbermattenm commented 8 years ago

11, like in the image...

Using (or activating) only one layer resolves the problem... I am wondering if this is not a problem because some of these layers use relationships to tables containing lists. Furthermore, we have tables containing for example a list of colors that we link (foreign key) to editable layers. These list tables may be related more then once to editable layers. (hmmm.... wondering if my explanation is really clear...)

kalbermattenm commented 7 years ago

I still have this issue.... It appears from time to time and restarting Apache resolves the problem, but I do not really know what triggers it...

kalbermattenm commented 7 years ago

Maybe this has to do with concurrent requests, see http://stackoverflow.com/questions/13371754/making-sql-alchemy-play-nice-with-google-app-engine

But I am really not sure about it (and I do not understand what is really happening here...)

sbrunner commented 6 years ago

Moved to Jira