OSProfiler does not catch DB error events
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
osprofiler |
Fix Released
|
Undecided
|
Ilya Shakhat |
Bug Description
Consider the following scenario: user traces OpenStack command and an error occurs in database layer (e.g. connection is closed). This leads to 2 issues:
1. OSProfiler does not catch 'db-stop' event, nor any other errors from DB
2. All further events are mis-aligned, causing wrong interpretation of the trace.
Example
-------
Keystone trace usually have the following events:
wsgi-start -> POST/identity/
db-start -> SELECT 1
db-stop
db-start -> SELECT user...
db-stop
....
wsgi-stop
If DB error occurs during execution of 'SELECT user...' then the trace looks as following:
wsgi-start -> POST/identity/
db-start -> SELECT 1
db-stop
db-start -> SELECT user...
db-stop
The last 'db-stop' event is actually emitted from WSGI interceptor, but it has wrong name because the name is calculated based on stack status (https:/
Possible solutions
------------------
a) Subscribe to SQLAlchemy events
There are 2 types of events related to errors:
* 'dbapi_error' intercepts a raw DB error, but it is deprecated for a long time
* 'handle_error' intercepts exceptions processed by SQLAlchemy connection. Oslo.db is already subscribed to this event, the handler maps low-level exceptions and raises custom instead (https:/
b) Force WSGIMiddleware to ignore Profiler's stack.
Middleware works like interceptor and OSProfiler can control when the trace starts and when it stops, there is no need to rely on stack state. However this solution just fixes the alignment, but DB error will still be missing.
Changed in osprofiler: | |
status: | New → Confirmed |
Changed in osprofiler: | |
assignee: | nobody → Ilya Shakhat (shakhat) |
Changed in osprofiler: | |
status: | Confirmed → In Progress |
Related change into oslo.db: https:/ /review. openstack. org/#/c/ 486980/