Skip to content

Conversation

@rducom
Copy link

@rducom rducom commented May 22, 2020

Fixes #21016
This PR fixs the memory leak in compiled query cache
It introduce a IDiagnosticsLogger clone used in the QueryingEnumerable code paths, so the Closure held by compiled Func<QueryContext,T> never reference Scoped instances via Interceptors.

I have tried to use a IDiagnosticsLogger singleton, but since ILoggerFactory can be either scoped or singleton, going Singleton for DiagnosticsLogger requires breaking changes.
This "clone way" have minimum impact on the existing code base.

@rducom rducom force-pushed the querycache.memory.leak branch 3 times, most recently from 6636883 to a4bdd51 Compare May 22, 2020 12:59
@rducom rducom changed the title Use singleton IDiagnosticsLogger in compiled query cache Use cloned IDiagnosticsLogger in compiled query cache May 22, 2020
@smitpatel
Copy link
Contributor

This is not the right way to fix this issue.

@rducom
Copy link
Author

rducom commented May 22, 2020

Ok, what do you suggest ?

@rducom
Copy link
Author

rducom commented May 22, 2020

I think for 3.1, the fix should implies minimum code changes. If for 5.0 it's possible to do more "breaking" changes, here's what I think it could be :
My main concern is the fact IDiagnosticsLogger are Scoped : I think it should be singleton, or at least, the type injected in each compiled closure should be a singleton (not necessarily IDiagnosticsLogger).
But it requires 3 important changes :

  • enforcing IDiagnosticsLogger are thread-safe : if we go for singleton, this instance will be shared by all compiled queries
  • enforcing ILoggerFactory as singleton (it have a lot of impacts on the registration)
  • moving Interceptors out of IDiagnosticsLogger

Don't hesitate to share insights as I'm certainly missing the best way to implement the fix, and I'll really love trying any other suggested way to fix this.

@rducom
Copy link
Author

rducom commented May 22, 2020

I've submitted another PR, with another way to fix this issue : #21023

@rducom rducom closed this May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants