Skip to content

Commit 22e1643

Browse files
Add warning about known problems when configuring use_frozen_dicts (#19711)
Known problems: #18117 As a follow-up, we should consider removing this config option altogether. It's "expensive" and claims to "prevent bugs" but actually introduces a whole new class of bugs. It could be re-introduced with a more holistic solution to the typing. Or a completely new approach (safe mode that blows up when someone mutates the event content, always make deep clones when handing out references, etc) The `use_frozen_dict` config option was there [since inception](a7b65bd) but was only recently [documented](#18122) for completeness sake.
1 parent ae242fd commit 22e1643

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

changelog.d/19711.doc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add warning about known problems when configuring `use_frozen_dicts`.

docs/usage/configuration/config_documentation.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ user_agent_suffix: ' (I''m a teapot; Linux x86_64)'
194194
---
195195
### `use_frozen_dicts`
196196

197-
*(boolean)* Determines whether we should freeze the internal dict object in `FrozenEvent`. Freezing prevents bugs where we accidentally share e.g. signature dicts. However, freezing a dict is expensive. Defaults to `false`.
197+
*(boolean)* Determines whether we should freeze the internal dict object in `FrozenEvent`. Freezing prevents bugs where we accidentally share e.g. signature dicts. However, freezing a dict is expensive.
198+
199+
> ⚠️ **Warning** – This option is known to introduce a new class of [comparison bugs](https://github.com/element-hq/synapse/issues/18117) in Synapse.
200+
201+
Defaults to `false`.
198202

199203
Example configuration:
200204
```yaml

schema/synapse-config.schema.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ properties:
9494
Determines whether we should freeze the internal dict object in
9595
`FrozenEvent`. Freezing prevents bugs where we accidentally share e.g.
9696
signature dicts. However, freezing a dict is expensive.
97+
98+
99+
> ⚠️ **Warning** – This option is known to introduce a new class of [comparison
100+
bugs](https://github.com/element-hq/synapse/issues/18117) in Synapse.
97101
default: false
98102
examples:
99103
- true

synapse/events/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
NOTE: This is overridden by the configuration by the Synapse worker apps, but
6464
for the sake of tests, it is set here because it cannot be configured on the
6565
homeserver object itself.
66+
67+
FIXME: Because of how this option works (changing the underlying types), it causes
68+
subtle downstream bugs that makes type comparisons brittle, tracked by
69+
https://github.com/element-hq/synapse/issues/18117
6670
"""
6771

6872
T = TypeVar("T")

0 commit comments

Comments
 (0)