From 2dc98bea8dc66ba9dfd0288d5faa3a2cc00916b7 Mon Sep 17 00:00:00 2001 From: Tobias Henkel Date: Fri, 11 Sep 2020 09:08:49 +0200 Subject: Clear traceback before attaching exception to event When we hit an exception in a management event we attach it to the event so the sender of the event can get the stack trace back. However the traceback also contains the local variables of all frames part of the traceback. Those also can contain references to Tenant objects which will be blocked for the gc until the event is (hopefully) collected as well. Since we're only interested in the stack traces and don't need the local variables clear the frames before attaching the traceback to the event. Change-Id: I57854ac4b9d1405d2b7b86f27149f87af968e77a --- zuul/scheduler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'zuul/scheduler.py') diff --git a/zuul/scheduler.py b/zuul/scheduler.py index 8e0738236..83f620fec 100644 --- a/zuul/scheduler.py +++ b/zuul/scheduler.py @@ -25,6 +25,7 @@ import socket import sys import threading import time +import traceback import urllib from zuul import configloader @@ -1385,7 +1386,11 @@ class Scheduler(threading.Thread): event.done() except Exception: self.log.exception("Exception in management event:") - event.exception(sys.exc_info()) + type, val, tb = sys.exc_info() + # Remove local variables from the traceback to prevent leaking + # large objects. + traceback.clear_frames(tb) + event.exception((type, val, tb)) self.management_event_queue.task_done() def process_result_queue(self): -- cgit v1.2.1