Power parameters access attempt from non-db thread

Bug #1997190 reported by Alexsander de Souza
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
Critical
Alexsander de Souza

Bug Description

```
2022-11-20 15:50:47 twisted.internet.defer: [critical] Unhandled error in Deferred:
2022-11-20 15:50:47 twisted.internet.defer: [critical]
    Traceback (most recent call last):
      File "/snap/maas/24982/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 661, in callback
        self._startRunCallbacks(result)
      File "/snap/maas/24982/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 763, in _startRunCallbacks
        self._runCallbacks()
      File "/snap/maas/24982/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 857, in _runCallbacks
        current.result = callback( # type: ignore[misc]
      File "/snap/maas/24982/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1750, in gotResult
        current_context.run(_inlineCallbacks, r, gen, status)
    --- <exception caught here> ---
      File "/snap/maas/24982/usr/lib/python3/dist-packages/twisted/internet/defer.py", line 1660, in _inlineCallbacks
        result = current_context.run(gen.send, result)
      File "/snap/maas/24982/lib/python3.10/site-packages/maasserver/vmhost.py", line 56, in request_commissioning_results
        pod.get_power_parameters(),
      File "/snap/maas/24982/lib/python3.10/site-packages/maasserver/models/bmc.py", line 412, in get_power_parameters
        **SecretManager().get_composite_secret(
      File "/snap/maas/24982/lib/python3.10/site-packages/maasserver/secrets.py", line 139, in get_composite_secret
        return self._get_secret_from_db(path)
      File "/snap/maas/24982/lib/python3.10/site-packages/maasserver/secrets.py", line 179, in _get_secret_from_db
        return Secret.objects.get(path=path).value
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/manager.py", line 85, in manager_method
        return getattr(self.get_queryset(), name)(*args, **kwargs)
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/query.py", line 424, in get
        clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/query.py", line 941, in filter
        return self._filter_or_exclude(False, args, kwargs)
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/query.py", line 961, in _filter_or_exclude
        clone._filter_or_exclude_inplace(negate, args, kwargs)
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/query.py", line 968, in _filter_or_exclude_inplace
        self._query.add_q(Q(*args, **kwargs))
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/sql/query.py", line 1423, in add_q
        clause, _ = self._add_q(q_object, self.used_aliases)
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/sql/query.py", line 1442, in _add_q
        child_clause, needed_inner = self.build_filter(
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/sql/query.py", line 1377, in build_filter
        condition = self.build_lookup(lookups, col, value)
      File "/snap/maas/24982/usr/lib/python3/dist-packages/django/db/models/sql/query.py", line 1235, in build_lookup
        if (connections[DEFAULT_DB_ALIAS].features.interprets_empty_strings_as_nulls and
      File "/snap/maas/24982/lib/python3.10/site-packages/maasserver/utils/orm.py", line 855, in __getattr__
        self._raise_error()
      File "/snap/maas/24982/lib/python3.10/site-packages/maasserver/utils/orm.py", line 864, in _raise_error
        raise RuntimeError(
    builtins.RuntimeError: Database connections in this thread (MainThread) are disabled.
```

Related branches

Changed in maas:
assignee: nobody → Alexsander de Souza (alexsander-souza)
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
Changed in maas:
milestone: 3.3.0 → 3.3.0-beta3
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.