Disable enable_shared_storage_snapshot_in_query (leads to memory leaks)#90770
Conversation
Some functions stores a copy of `ContextPtr` (not a `weak_ptr` as it should be, but `shared_ptr`), i.e. [`modulo`](https://github.com/ClickHouse/ClickHouse/blob/407e33a47cf707155d1c4f3f12d2bb2291c80009/src/Functions/FunctionBinaryArithmetic.h#L827), but this `IFunction` itself can be stored in `KeyDescription`, which is part of `StorageInMemoryMetadata`. And with metadata cache (`enable_shared_storage_snapshot_in_query=1`) this will create memory leaks (since this `Context` will never be destroyed) As @Michicosun has been told, this cache should never be part of `Context` (but we abuse it often). (Another issue is `IFunction` holds a `ContextPtr` not a `ContextWeakPtr`, but this is another story) Anyway, let's disable it for now (backported to 25.11 is a must).
| enable_scalar_subquery_optimization 1 | ||
| enable_scopes_for_with_statement 1 | ||
| enable_shared_storage_snapshot_in_query 1 | ||
| enable_shared_storage_snapshot_in_query 0 |
There was a problem hiding this comment.
Yes, rewriting the history for critical bugs is ok. The other option would be to set it to false, false in 25.11 and again in 25.12. But since 25.11 is unreleased it's better to just disable it
|
Workflow [PR], commit [6c3ae9b] Summary: ❌
|
|
Let's ask @amosbird. |
|
Interesting, what is the metadata cache, and how does the Context from queries appear to be shared there? |
Maybe we don't need it at all, but
This is also a bug in functions - It should use But this is not the only example (UDF AFAICS also has some issues) So no need to hurry here, let's disable it by default, and fix all the problems |
dd868b0
Some parts of the analyzer use
It's interesting that without |
+1, but maybe it is just pure luck, or maybe it uses correct context, but anyway, it is pure luck |
Indeed. Fortunately, the |
…uery (leads to memory leaks)
Backport #90770 to 25.11: Disable enable_shared_storage_snapshot_in_query (leads to memory leaks)
|
@azat I think an issue to re-enable the setting will be good to have (just to not forget). |
|
There is a private issue (see referenced issues in this PR) |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Disable
enable_shared_storage_snapshot_in_query(leads to memory leaks)Some functions stores a copy of
ContextPtr(not aweak_ptras it should be, butshared_ptr), i.e.modulo, but thisIFunctionitself can be stored inKeyDescription, which is part ofStorageInMemoryMetadata.And with metadata cache (
enable_shared_storage_snapshot_in_query=1) this will create memory leaks (since thisContextwill never be destroyed)As @Michicosun has been told, this cache should never be part of
Context(but we abuse it often).(Another issue is
IFunctionholds aContextPtrnot aContextWeakPtr, but this is another story)Anyway, let's disable it for now (backported to 25.11 is a must).
Repro
And terminate the server - it will trigger same ASan report
Reverts: #82634
Refs: #79471 (cc @amosbird )