nprapps / elections18-general

2018 midterm election back-end: Associated Press data ETL, database, admin panel, and JSON output; iteration upon 2016 GE work
MIT License
3 stars 1 forks source link

Occasionally, production admin-panel server will not see any `Result`s #24

Open mileswwatkins opened 6 years ago

mileswwatkins commented 6 years ago

Occasionally (every ~7 requests?) database query will report that there are 0 Results.

Exception on /elections18/calls/senate/ [GET]
Traceback (most recent call last):
  File "/home/ubuntu/apps/elections18_general/virtualenv/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/ubuntu/apps/elections18_general/virtualenv/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/ubuntu/apps/elections18_general/virtualenv/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/ubuntu/apps/elections18_general/virtualenv/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/home/ubuntu/apps/elections18_general/virtualenv/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/ubuntu/apps/elections18_general/virtualenv/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "app.py", line 55, in calls_admin
    chamber_call_override = results.first().meta.first().chamber_call_override
AttributeError: 'NoneType' object has no attribute 'meta'

Handling this now with an escape clause. Will need to investigate further. It could be because the new-data loading procedure by the daemon is not a single transaction (yuck).

mileswwatkins commented 6 years ago

Yeah, it's not a single transaction, and can't easily be made such given the antipattern "delete and reload in-place" strategy that's employed in fabfile/data.py's load_results().