From ac3a1155113af8896ecf3f9fcfdf5cfe23b3e90c Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Wed, 25 Feb 2026 09:47:13 -0600 Subject: [PATCH] Log if we ever `gc.freeze()` (#19440) Spawning from https://github.com/element-hq/synapse-small-hosts/issues/348 where some test appears to be flaky because some homeserver objects are frozen in the garbage collector. We set [`freeze=False`](https://github.com/element-hq/synapse-small-hosts/blob/a9a6869aa9a67176bdddc3b8ae2d0de0996d8cf4/multi_synapse/app/shard.py#L319-L321) in the [Synapse Pro for small hosts](https://docs.element.io/latest/element-server-suite-pro/synapse-pro-for-small-hosts/overview/) code but I just want to use this log to make extra sure this isn't being run somehow. The follow-up here would be to see what else would cause something to be frozen in the garbage collector. --- changelog.d/19440.misc | 1 + synapse/app/_base.py | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 changelog.d/19440.misc diff --git a/changelog.d/19440.misc b/changelog.d/19440.misc new file mode 100644 index 0000000000..7777601114 --- /dev/null +++ b/changelog.d/19440.misc @@ -0,0 +1 @@ +Add log to explain when and why we freeze objects in the garbage collector. diff --git a/synapse/app/_base.py b/synapse/app/_base.py index c64c41e9d2..7f4855f36b 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -776,6 +776,11 @@ async def start(hs: "HomeServer", *, freeze: bool = True) -> None: # # PyPy does not (yet?) implement gc.freeze() if hasattr(gc, "freeze"): + logger.info( + "garbage collector: Freezing all allocated objects in the hopes that (almost) " + "everything currently allocated are things that will be used by the homeserver " + "for the rest of time. Doing so means less work each GC (hopefully)." + ) gc.collect() gc.freeze()