lava-dashboard fails with can't adapt type 'Decimal' deserialization error

Bug #850770 reported by Deepti B. Kalakeri
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
LAVA Dashboard (deprecated)
Fix Released
Critical
Zygmunt Krynicki

Bug Description

lava-dashboard fails with can't adapt type 'Decimal' deserialization error
Here is the error traceback:

Cause

can't adapt type 'Decimal'
Deserialization failure traceback

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.6/dashboard_app/models.py", line 399, in deserialize
    self._do_deserialize(prefer_evolution)
  File "/usr/lib/pymodules/python2.6/dashboard_app/models.py", line 417, in _do_deserialize
    helper.deserialize(self, prefer_evolution)
  File "/usr/lib/pymodules/python2.6/dashboard_app/helpers.py", line 737, in deserialize
    importer().import_document(s_bundle, doc)
  File "/usr/lib/pymodules/python2.6/dashboard_app/helpers.py", line 64, in import_document
    self._import_document_with_transaction(s_bundle, doc)
  File "/usr/lib/pymodules/python2.6/django/db/transaction.py", line 299, in _commit_on_success
    res = func(*args, **kw)
  File "/usr/lib/pymodules/python2.6/dashboard_app/helpers.py", line 106, in _import_document_with_transaction
    self._import_document(s_bundle, doc)
  File "/usr/lib/pymodules/python2.6/dashboard_app/helpers.py", line 110, in _import_document
    self._import_test_run(c_test_run, s_bundle)
  File "/usr/lib/pymodules/python2.6/dashboard_app/helpers.py", line 152, in _import_test_run
    self._import_test_results(c_test_run, s_test_run)
  File "/usr/lib/pymodules/python2.6/dashboard_app/helpers.py", line 390, in _import_test_results
    self._import_test_results_pgsql(c_test_results, s_test_run)
  File "/usr/lib/pymodules/python2.6/dashboard_app/helpers.py", line 334, in _import_test_results_pgsql
    ) VALUES """ + sequel, data)
  File "/usr/lib/pymodules/python2.6/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute
    return self.cursor.execute(query, args)
DatabaseError: can't adapt type 'Decimal'

The above error occurred for the job: http://validation.linaro.org/lava-server/scheduler/job/1608

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

I cannot reproduce this locally on natty (although I may have made a mistake so I'm checking again). From my reading of the code the only suspect is a bit of magic Django _may_ (I'm not certain this is true) be putting between us and postgresql in the adapter classes. From my naive checking postgresql adapter supports decimals just fine so something else must be at play.

Changed in lava-dashboard:
importance: Undecided → Medium
milestone: none → 2011.09
status: New → In Progress
assignee: nobody → Zygmunt Krynicki (zkrynicki)
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

The bundle that caused this is https://bugs.launchpad.net/lava-dashboard/+bug/850770. One can download it with the following command:

$ lava-dashboard-tool get --dashboard-url=http://validation.linaro.org/lava-server/RPC2/ 492c3fd101d748816d949b85cd458dc99becbf2d --output bug-850770.json

Revision history for this message
Paul Larson (pwlars) wrote :

Bumped up the priority as this is causing lots of deserialization errors on the daily runs

Changed in lava-dashboard:
importance: Medium → Critical
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Still trying to nail this one. It seems to work all the time. I did manage to reproduce it only once, the very first time I tried, then it succeeded.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Well, I think I have _some_ idea what's going on, although not much. Basically, the problem is that the _psycopg module has a process global dictionary of adapters, including the adapter for Decimal types. mod_wsgi runs all the various WSGI apps it is hosting in one process (or at least only a small number of processes) and so if one WSGI app messes with this adapter registry somehow, all the other hosted WSGI apps will break. I don't know which app we're hosting could do this, but _possibly_ it's the edge site. I notice that the edge .wsgi file uses the "activate_this" script from the virtualenv, but this is a bad idea with mod_wsgi:

http://code.google.com/p/modwsgi/wiki/VirtualEnvironments

It's possible that some of the manipulations activate_this does mean that importing the decimal module will fail, and if another app is unlucky enough to import psycopg2 module at this moment psycopg2 for that process forever more will not support decimals. This seems moderately unlikely, but it's the best guess I have.

Fixes that suggest themselves, in increasing order of invasiveness but also perhaps desirability:

1) Change the edge .wsgi script to not use activate_this.py
2) Switch to using mod_wsgi in daemon mode
3) Stop using mod_wsgi at all and ProxyPass to gunicorn or something.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Oh, this also suggests a workaround: if this starts happening a lot, restart apache, and the race probably won't happen on next startup. Any bundles that failed to deserialize should deserialize fine if you just try again after a restart.

Revision history for this message
Deepti B. Kalakeri (deeptik) wrote :

Ah! the error does not seem to appear any more. The lava test execution for beagle board now completes.
This can be closed.

Thanks!!!
Deepti.

Fathi Boudra (fboudra)
Changed in lava-dashboard:
status: In Progress → Fix Committed
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

For the record: I removed our edge site so that currently apache runs only one python interpreter

Fathi Boudra (fboudra)
Changed in lava-dashboard:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.