Skip to content

Conversation

@manandre
Copy link
Collaborator

Fixes #4499

@manandre manandre force-pushed the clear-pool-async branch 3 times, most recently from c88aa35 to 858e407 Compare January 10, 2023 21:03
@manandre
Copy link
Collaborator Author

@roji and @vonzshik, your comments are welcome.

Copy link
Contributor

@vonzshik vonzshik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry, was busy with other stuff. Probably a good idea for me to take a look at all pr's we have...

// very unlikely to block (plus locking would need to be worked out)
internal void Close()
{
lock (this)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This particular lock is actually very important. It helps at least with:

  1. Concurrent close
  2. Concurrent keepalive
  3. Concurrent break

I'm not sure whether changing everywhere to use SemaphoreSlim is a good idea, would have to think about that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, still no idea what to do here. @roji maybe you have something on your mind?

try
{
_semaphore.Release();
_semaphore.Dispose();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like if we're not closing the connector (but, for example, breaking it while opening) the semaphore is not going to get disposed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must guarantee that the Dispose/Close method is correctly called once a connector is not usable/used anymore.
Should we check everywhere that this statement is correctly enforced?

// very unlikely to block (plus locking would need to be worked out)
internal void Close()
{
lock (this)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, still no idea what to do here. @roji maybe you have something on your mind?

@roji
Copy link
Member

roji commented Nov 7, 2023

@manandre just to confirm, you're waiting on our review for this right?

If not, can you please rebase and we'll do our best to review and merge ASAP? Not sure this will happen for 8.0 at this point, but we can always try.

@manandre
Copy link
Collaborator Author

manandre commented Nov 7, 2023

@roji I have just rebased. However, I am still not fully confident around the lock replacement in the Close method of the NpgsqlConnector class...
IMHO No hurry is required here, it can wait for next version if safer.

@NinoFloris
Copy link
Member

Same here, let's aim to get this into a patch for 8.0. Thanks @manandre

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.

Implement ClearAsync in data sources

4 participants