-
Notifications
You must be signed in to change notification settings - Fork 104
Description
I'm trying to determine whether ckanext-pages
is responsible for a race condition that brought down our application last night. I'm wondering if you can help me figure out how to interpret the context['model']
object to see if it's possible that it could have been shared between two threads. Specifically, I'm interested in this code block:
ckanext-pages/ckanext/pages/actions.py
Lines 78 to 81 in 06d8ef5
def _pages_list(context, data_dict): | |
search = {} | |
if db.pages_table is None: | |
db.init_db(context['model']) |
What would you expect context['model']
to represent in this case? It looks like db.py
modifies in a number of different ways, including setting table mappings:
ckanext-pages/ckanext/pages/db.py
Lines 97 to 119 in 06d8ef5
global pages_table | |
pages_table = sa.Table('ckanext_pages', model.meta.metadata, | |
sa.Column('id', types.UnicodeText, primary_key=True, default=make_uuid), | |
sa.Column('title', types.UnicodeText, default=u''), | |
sa.Column('name', types.UnicodeText, default=u''), | |
sa.Column('content', types.UnicodeText, default=u''), | |
sa.Column('lang', types.UnicodeText, default=u''), | |
sa.Column('order', types.UnicodeText, default=u''), | |
sa.Column('private',types.Boolean,default=True), | |
sa.Column('group_id', types.UnicodeText, default=None), | |
sa.Column('user_id', types.UnicodeText, default=u''), | |
sa.Column('publish_date', types.DateTime), | |
sa.Column('page_type', types.DateTime), | |
sa.Column('created', types.DateTime, default=datetime.datetime.utcnow), | |
sa.Column('modified', types.DateTime, default=datetime.datetime.utcnow), | |
sa.Column('extras', types.UnicodeText, default=u'{}'), | |
extend_existing=True | |
) | |
model.meta.mapper( | |
Page, | |
pages_table, | |
) |
This was the block of code that caused my errors in question, so any guidance you might have to shed light on what's supposed to happen with the model
object would be helpful. If you're interested in deeper context, you can see a more detailed investigation into our outage here: opendataphilly/opendataphilly-ckan#92 (comment)