Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can context['model'] be shared between threads? #81

Open
jeancochrane opened this issue Dec 3, 2018 · 0 comments
Open

Can context['model'] be shared between threads? #81

jeancochrane opened this issue Dec 3, 2018 · 0 comments

Comments

@jeancochrane
Copy link

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:

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:

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant