Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection leak detected when UserManager.GetUserAsync call #17

Open
xpsdim opened this issue Dec 20, 2019 · 1 comment
Open

Connection leak detected when UserManager.GetUserAsync call #17

xpsdim opened this issue Dec 20, 2019 · 1 comment
Labels

Comments

@xpsdim
Copy link

xpsdim commented Dec 20, 2019

Every call of UserManager.GetUserAsync allocates one connection to postgresql database and doesn't release it. Such action increase connection pool by 1 every time I call it.

public async Task<IActionResult> Test() { var currentUser = await _userManager.GetUserAsync(HttpContext.User); return Ok(currentUser); }

You can control number of the opened connection using SQL:

SELECT * FROM pg_stat_activity

When I do this 100+ times I get fatal error "FATAL: sorry, too many clients already". It happens when DBMS configured by default on my windows platform.

I also noticed that call of GetUserAsync doesn't make any SQL calls into database but opens new connection.

@mesgar
Copy link

mesgar commented Jan 16, 2022

Hi,

I had the same problem calling IsInRoleAsync every minute, I went through the source code and I found that the CloseConnection is commented.
With connection pooling I don't understand why it's commented.
I uncommented and call it from dispose too.
With that I don't have any idle connection anymore.

    public void CloseConnection()
    {
        /*   if (_connection.State == ConnectionState.Open)
           {
          //     _connection.Close();
           }*/
    }

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants