ckan / ckanext-pages

A simple builtin CMS for CKAN sites
GNU General Public License v3.0
51 stars 101 forks source link

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

Open jeancochrane opened 5 years ago

jeancochrane commented 5 years ago

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:

https://github.com/ckan/ckanext-pages/blob/06d8ef5f14087e5d9df14d982ec4d62f21ca25f6/ckanext/pages/actions.py#L78-L81

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:

https://github.com/ckan/ckanext-pages/blob/06d8ef5f14087e5d9df14d982ec4d62f21ca25f6/ckanext/pages/db.py#L97-L119

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: https://github.com/azavea/opendataphilly-ckan/issues/92#issuecomment-443790310