The thread local which stores the request context is not green

Bug #1784666 reported by Radoslav Gerganov
This bug report is a duplicate of:  Bug #1773102: Abnormal request id in logs. Edit Remove
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Triaged
Medium
Unassigned
Pike
Confirmed
Medium
Unassigned
Queens
Confirmed
Medium
Unassigned

Bug Description

nova-compute imports oslo.context before calling monkey_patch():

(Pdb) bt
  /usr/local/bin/nova-compute(6)<module>()
-> from nova.cmd.compute import main
  /opt/stack/nova/nova/__init__.py(33)<module>()
-> import oslo_service # noqa
  /usr/local/lib/python2.7/dist-packages/oslo_service/__init__.py(17)<module>()
-> from oslo_log import log as logging
  /usr/local/lib/python2.7/dist-packages/oslo_log/log.py(48)<module>()
-> from oslo_log import formatters
  /usr/local/lib/python2.7/dist-packages/oslo_log/formatters.py(28)<module>()
-> from oslo_context import context as context_utils
> /usr/local/lib/python2.7/dist-packages/oslo_context/context.py(40)<module>()
-> _request_store = threading.local()

which makes the global thread-local variable (_request_store) not green. So instead of having request context per green thread, we have one context for all green threads which is overwritten every time a new context is created.

This is regression from this patch:

https://review.openstack.org/#/c/434327/

which imports oslo.service before eventlet

Changed in nova:
importance: Undecided → Medium
Revision history for this message
Matt Riedemann (mriedem) wrote :

Someone said the same in this change:

https://review.openstack.org/#/c/582332/

"""
Hello melanie, I meet the same problem about request-id in log.
I think this bug is similar to cinder bug https://bugs.launchpad.net/cinder/+bug/1743461 as Rikimaru Honjo says.
In his patch, eventlet.monkey_patch() must before import oslo_log (actually before import oslo_context).

In nova, we do eventlet.monkey_patch() in nova/cmd/__init__.py but import oslo_service in nova/__init__.py,
and in oslo_service will import oslo log.

In my environment, I delete the monkey_patch() in nova/cmd/__init__.py and put it to nova/__init__.py before oslo_service.
In this way, the request-id (including the periodic task) will not be replaced by other processes.

I think this maybe more suitable to close bug#1773102.
Tanks.
"""

Changed in nova:
status: New → Triaged
no longer affects: nova/ocata
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.