"change-packages" fails on PackageTask initialization

Bug #1994951 reported by Malte Kuhn
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Landscape Client
Fix Committed
Undecided
Unassigned

Bug Description

We have a standalone landscape server, that hands out a package "landscape-profile-standalone-company-tools".
On the server this activity is stuck in the "in progress" status.

On the client these logmessages can be found in syslog:

```
Oct 26 22:51:12 hostnamehere landscape-client[4159]: 2022-10-26 22:48:07,870 INFO [MainThread] Queueing message with updated reboot-required status.
Oct 26 22:51:12 hostnamehere landscape-client[4159]: 2022-10-26 22:48:07,871 INFO [MainThread] Queueing message with updated update-manager status.
Oct 26 22:51:12 hostnamehere landscape-client[4159]: 2022-10-26 22:48:07,871 ERROR [MainThread] Error running message handler for type 'change-packages': <bound method PackageManager.handle_change_packages of <landscape.client.manager.packagemanager.PackageManager object at 0x7f219d3d2500>>
Oct 26 22:51:12 hostnamehere landscape-client[4159]: Traceback (most recent call last):
Oct 26 22:51:12 hostnamehere landscape-client[4159]: File "/usr/lib/python3/dist-packages/landscape/client/broker/client.py", line 218, in dispatch_message
Oct 26 22:51:12 hostnamehere landscape-client[4159]: return handler(message)
Oct 26 22:51:12 hostnamehere landscape-client[4159]: File "/usr/lib/python3/dist-packages/landscape/client/manager/packagemanager.py", line 48, in handle_change_packages
Oct 26 22:51:12 hostnamehere landscape-client[4159]: return self._handle(PackageChanger, message)
Oct 26 22:51:12 hostnamehere landscape-client[4159]: File "/usr/lib/python3/dist-packages/landscape/client/manager/packagemanager.py", line 45, in _handle
Oct 26 22:51:12 hostnamehere landscape-client[4159]: self.spawn_handler(cls)
Oct 26 22:51:12 hostnamehere landscape-client[4159]: File "/usr/lib/python3/dist-packages/landscape/client/manager/packagemanager.py", line 71, in spawn_handler
Oct 26 22:51:12 hostnamehere landscape-client[4159]: if self._package_store.get_next_task(cls.queue_name):
Oct 26 22:51:12 hostnamehere landscape-client[4159]: File "/usr/lib/python3/dist-packages/landscape/lib/store.py", line 31, in inner
Oct 26 22:51:12 hostnamehere landscape-client[4159]: result = method(self, cursor, *args, **kwargs)
Oct 26 22:51:13 hostnamehere landscape-client[4159]: File "/usr/lib/python3/dist-packages/landscape/lib/apt/package/store.py", line 334, in get_next_task
Oct 26 22:51:13 hostnamehere landscape-client[4159]: return PackageTask(self._db, row[0])
Oct 26 22:51:13 hostnamehere landscape-client[4159]: File "/usr/lib/python3/dist-packages/landscape/lib/apt/package/store.py", line 435, in __init__
Oct 26 22:51:13 hostnamehere landscape-client[4159]: self.queue = row[0]
Oct 26 22:51:13 hostnamehere landscape-client[4159]: TypeError: 'NoneType' object is not subscriptable
Oct 26 22:51:13 hostnamehere landscape-client[4159]: 2022-10-26 22:48:37,859 INFO [MainThread] Ping indicates message available. Scheduling an urgent exchange.
```

Basically the PackageTask instance is unable to get the row that was found by get_next_task.

Additional information:
Landscape Client Version: 18.01-0ubuntu13
Operating System: Ubuntu 22.04.1 LTS
Kernel: Linux 5.15.0-52-generic
Architecture: x86-64
Hardware Vendor: Dell Inc.
Hardware Model: Latitude 5401
/ Filesystem is btrfs
I use suspend and hibernate via systemctl.

Workaround:
A restart of the landscape-client.service + cancel and redo on the activity resolves the matter as manual workaround.

Malte Kuhn (mc-mkuhn)
description: updated
Changed in landscape-client:
status: New → In Progress
status: In Progress → Fix Committed
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

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.