that error looks like a collision in a very short section which only  
occurs during mapper creation (i.e. weakref.iterkeys()) and should be  
exceedingly difficult to reproduce, unless you are creating new  
SqlSoup objects on each request.    Make sure you're using just one  
SqlSoup object declared when your program first runs, so that it  
creates a single set of mappers for the whole process, instead of new  
mappers for every request.

OTOH if you are truly getting this collision with just a handful of  
mappers in use throughout the app, we can place an additional lock  
around the two unsynchronized references to _mapper_registry in  
mapper.py.


On Jun 7, 2009, at 6:41 AM, tsangpo wrote:

>
> I use the SqlSoup to make it easy to access the database. It's all
> right
> when I make the http request one by one.
> But it run into errors when serveral requests were sent at the same
> time,
> and fail to proccess requests anymore.
> I log the Session, and found that each request exact has different
> session.
> The most strange thing is that each time the sqlsoup go down, it
> produce
> different error message:
>
> When everything is OK, the log is:
> -------------------------------------------------------------------------------------
> 2009-06-07 17:18:33,082 INFO sqlalchemy.engine.base.Engine.0x...a530
> BEGIN
> 2009-06-07 17:18:33,082 INFO sqlalchemy.engine.base.Engine.0x...a530
> SELECT
> user.id AS user_id, user.name AS user_name, user.full_name AS
> user_full_name, user.password AS user_password, user.active AS
> user_active
> FROM user
> WHERE user.password = %s AND user.name = %s
> LIMIT 0, 1
> 2009-06-07 17:18:33,082 INFO sqlalchemy.engine.base.Engine.0x...a530
> ['123456', 'eric']
> 2009-06-07 17:18:33,098 INFO sqlalchemy.engine.base.Engine.0x...a530
> SELECT
> role.id AS role_id, role.name AS role_name, role.description AS
> role_description, rl_user_role.user_id AS rl_user_role_user_id,
> rl_user_role.role_id AS rl_user_role_role_id, rl_role_action.role_id
> AS
> rl_role_action_role_id, rl_role_action.action_id AS
> rl_role_action_action_id
> FROM role INNER JOIN rl_user_role ON role.id = rl_user_role.role_id
> INNER
> JOIN rl_role_action ON role.id = rl_role_action.role_id
> WHERE rl_role_action.action_id = %s AND rl_user_role.user_id = %s
> 2009-06-07 17:18:33,098 INFO sqlalchemy.engine.base.Engine.0x...a530
> [1L,
> 1L]
> 2009-06-07 17:18:33,098 INFO sqlalchemy.engine.base.Engine.0x...a530
> SELECT
> user.id AS user_id, user.name AS user_name, user.full_name AS
> user_full_name, user.password AS user_password, user.active AS
> user_active
> FROM user
> 2009-06-07 17:18:33,098 INFO sqlalchemy.engine.base.Engine.0x...a530
> []
> 2009-06-07 17:18:33,115 INFO sqlalchemy.engine.base.Engine.0x...a530
> COMMIT
> --------------------------------------------------------------------------------------
>
> And error edition 1:
> -------------------------------------------------------------------------------------
> Traceback (most recent call last):
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\google_appengine\google
> \appengine\ext\webapp\__init__
> .py", line 499, in __call__
>    handler.get(*groups)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\database.py",
> line
> 44, in _func
>    return func(*args, **kwargs)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 23, in action_metho
> d
>    if roles == 'everyone' or check_privilege(action_id,
> users.get_current_user().id):
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 67, in check_privil
> ege
>    db.role.id==db.rl_user_role.role_id)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 541, in join
>    return self.map(j)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 531, in map
>    t = class_for_table(selectable, **kwargs)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 483, in class_for_table
>    for k in mappr.iterate_properties:
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\mapper.py",
> line
> 777, in iterate_properties
>    self.compile()
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\mapper.py",
> line
> 651, in compile
>    for mapper in list(_mapper_registry):
>  File "D:\CodingLife\win32\native\Python25\lib\weakref.py", line 303,
> in
> iterkeys
>    for wr in self.data.iterkeys():
> RuntimeError: dictionary changed size during iteration
>
> the request followed produce this:
>
> INFO:sqlalchemy.engine.base.Engine.0x...a530:ROLLBACK
> ERROR:root:Traceback (most recent call last):
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\google_appengine\google
> \appengine\ext\webapp\__init__.py",
> line 499, in __call__
>    handler.get(*groups)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\database.py",
> line
> 44, in _func
>    return func(*args, **kwargs)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 23, in action_method
>    if roles == 'everyone' or check_privilege(action_id,
> users.get_current_user().id):
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 67, in check_privilege
>    db.role.id==db.rl_user_role.role_id)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 541, in join
>    return self.map(j)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 531, in map
>    t = class_for_table(selectable, **kwargs)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 483, in class_for_table
>    for k in mappr.iterate_properties:
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\mapper.py",
> line 777, in iterate_properties
>    self.compile()
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\mapper.py",
> line 655, in compile
>    "Message was: %s" % mapper._compile_failed)
> InvalidRequestError: One or more mappers failed to compile.  Exception
> was
> probably suppressed within a hasattr() call. Message was: dictionary
> changed
> size during iteration
> -------------------------------------------------------------------------------------
>
> And error edition 2:
> -------------------------------------------------------------------------------------
> ERROR:root:Traceback (most recent call last):
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\google_appengine\google
> \appengine\ext\webapp\__init__.py",
> line 499, in __call__
>    handler.get(*groups)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\database.py",
> line
> 44, in _func
>    return func(*args, **kwargs)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 23, in action_method
>    if roles == 'everyone' or check_privilege(action_id,
> users.get_current_user().id):
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 69, in check_privilege
>    db.role.id==db.rl_role_action.role_id)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 541, in join
>    return self.map(j)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 531, in map
>    t = class_for_table(selectable, **kwargs)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 483, in class_for_table
>    for k in mappr.iterate_properties:
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\mapper.py",
> line 777, in iterate_properties
>    self.compile()
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\mapper.py",
> line 655, in compile
>    "Message was: %s" % mapper._compile_failed)
> InvalidRequestError: One or more mappers failed to compile.  Exception
> was
> probably suppressed within a hasattr() call. Message was: 'Mapper'
> object
> has no attribute 'primary_key'
>
> the request followed produce this:
>
> ERROR:root:Traceback (most recent call last):
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\google_appengine\google
> \appengine\ext\webapp\__init__.py",
> line 499, in __call__
>    handler.get(*groups)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\database.py",
> line
> 44, in _func
>    return func(*args, **kwargs)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 22, in action_method
>    if ensure_login(handler):
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 33, in ensure_login
>    user = check_user(username, password)
>  File "D:\CodingLife\win32\home\workspace\eric\src\eric\auth
> \__init__.py",
> line 76, in check_user
>    user = db.user.filter_by(name=username, password=password).first()
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\ext\sqlsoup.py",
> line 410, in __getattr__
>    return getattr(cls._query, attr)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\scoping.py",
> line 107, in __get__
>    mapper = class_mapper(owner)
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\util.py",
> line 567, in class_mapper
>    mapper = mapper.compile()
>  File
> "D:\CodingLife\win32\home\workspace\eric\lib\SQLAlchemy-0.5.3\lib
> \sqlalchemy\orm\mapper.py",
> line 655, in compile
>    "Message was: %s" % mapper._compile_failed)
> InvalidRequestError: One or more mappers failed to compile.  Exception
> was
> probably suppressed within a hasattr() call. Message was: One or more
> mappers failed to compile.  Exception was probably suppressed within
> a
> hasattr() call. Message was: 'Mapper' object has no attribute
> 'primary_key'
> -------------------------------------------------------------------------------------
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to