Comment 2 for bug 1994951

Revision history for this message
Juanmi Taboada (juanmitaboada) wrote :

The problem seems to be produced by a double SELECT:
- get_next_task() execute a SELECT which is valid and returns a valid ROW
- Then get_next_task() creates an instance from PackageTask, which executes a second SELECT to bring some fields from the database.

I must mention that get_next_task() is inside a transaction by the @with_cursor decorator, which shouldn't fail.

This solution optimizes the number of queries sent to the database and prevents this exception from happening.

A PR that removed the unnecessary SELECT has been proposed:
https://github.com/CanonicalLtd/landscape-client/pull/146